Docu#29
Conversation
eproxus
left a comment
There was a problem hiding this comment.
Thanks a lot! ❤️ Kraft is indeed in need of documentation since there is practically none. 😅
However, I think this PR is too large in scope and documents things in a very literal way, not really made for a user trying to use Kraft but often explaining irrelevant internal details of the implementation itself instead.
I suspect much of the documentation is AI generated (please correct me if I'm wrong) and it feels very inconsistent. Some if it just a sentence, some of it is wrong and some of it is very long detailed Markdown sections (often focusing on irrelevant implementation details). All this is very understandable since an AI doesn't understand why things are the way they are, only how things are. I'm not suggesting not to use AI at all, but this feels more in the ballpark of asking AI to "please add documentation for all modules" rather than "here's documentation for a web framework, can you review this module documentation from a Erlang beginner perspective and suggest improvements?"
I feel that this initiative would be better served by smaller, more user focused documentation PRs that can be reviewed in isolation. A good place to start would be to go through the examples and strictly document the API surface used there only, and review it from a user point of view.
What do you think?
|
|
||
| Kraft module provides the primary interface for starting, stopping, and managing | ||
| Kraft web servers, as well as rendering templates programmatically. | ||
|
|
| -moduledoc """ | ||
| Core API module for the Kraft web framework. | ||
|
|
||
| Kraft module provides the primary interface for starting, stopping, and managing |
There was a problem hiding this comment.
Grammatically, this should probably be something like "This module provides...".
| body/0, | ||
| response/0, | ||
| route_def/0 | ||
| ]). |
There was a problem hiding this comment.
Can you please remove any code refactoring not strictly related to adding documentation? Feel free to open another PR in case you think this is needed.
| start(Opts) -> start(Opts, []). | ||
|
|
||
| -doc """ | ||
| Starts a web server with the specified `Opts` options and `Routes` route definitions. |
There was a problem hiding this comment.
The first line summary should be shorter and can avoid obvious explanations such as describing the variable names.
| Ref. | ||
|
|
||
| stop(Ref) -> kraft_instance:stop(Ref). | ||
| %%------------------------------------------------------------------------------ |
There was a problem hiding this comment.
Can you remove these delimiters? I'd like them only between "sections" (e.g. types, macros, exported functions, internal functions etc.)
|
|
||
| ## See Also | ||
|
|
||
| - `kraft_template:render/3` - For advanced template operations |
There was a problem hiding this comment.
It was some time ago, but I believe my intention is that the user should always go through kraft:... functions, so referring to the internal function is not really helpful here.
| -module(kraft_app). | ||
|
|
||
| -moduledoc """ | ||
| Kraft public API. |
There was a problem hiding this comment.
This is not true, the Kraft public API is the kraft module.
| Kraft public API. | ||
|
|
||
| This module is the entry point for the Kraft application. It starts the | ||
| supervisor and stops the application. |
There was a problem hiding this comment.
This is also not really a user facing module so I wouldn't document it at all at this point to be honest.
| -moduledoc """ | ||
| Template-based controller handler for Kraft framework. | ||
|
|
||
| This module provides a simplified controller for rendering HTML templates. |
There was a problem hiding this comment.
I don't get this sentence. A controllers purpose is not to just "render HTML templates". It is to process the whole request/response cycle.
| Template-based controller handler for Kraft framework. | ||
|
|
||
| This module provides a simplified controller for rendering HTML templates. | ||
| It implements the `kraft_handler` behaviour and is designed for pages that need |
There was a problem hiding this comment.
I don't think the user needs to know what behaviors the current module implements, as that is an implementation detail. I would prefer if the documentation is more user focused.
You’re right that I used AI, especially to help rephrase things I initially wrote in my native language, or to refine content that I had already drafted myself. In some modules, I also used it to help me understand the structure or intent after reading through them, and also I asked it to explain parts in simpler terms. That said, it wasn’t a case of just asking the AI to generate documentation automatically for everything. There was a manual review of all content, though of course, that doesn’t automatically mean the review was great 😅. I had about a few days to dig into everything and couldn’t afford much more time, so my main goal was to understand how Kraft works from a user’s perspective and document that learning process (including AI parts which from my point of view helps me a lot) — even if that sometimes led to exploring internal details that may not have been strictly necessary. Just as a side note: there isn’t much long-standing public documentation on using ex_doc with Erlang, so relying on AI to generate directly proper ex_doc-style docs for Erlang isn’t very reliable. Thank you for your feedback — I really appreciate you taking the time to read this PR.
Sure, that sounds great and I think that would be less chaotic 😊 Would you suggest starting with:
🔍 Based on your comments, here’s what I think should be kept, but cleaned up and better documented per file:
🗑 Candidate for removal:
I’d really like to keep the “See also” sections — I find them super helpful when navigating and connecting pieces together. Let me know what you’d prioritize, and I’m happy to start iterating based on that. 😊 |
|
Would it make sense to agree on a format to keep module documentation consistent — both in Example format for module docs: Idk if you prefer to remove Usage No idea what to use for functions without being really verbose. Elixir function docs are like: |
|
Anyway, first of all, I'm going to fix all the comments that you did :) to have a better starting point |
Hi! 👋
I’ve been exploring this framework since we use it a lot at Stritzinger, and while learning, I decided to add documentation—it helped me understand it better, and I think it could help others too.
Let me know what you think!
Changes
README
Updated to include a detailed description of the framework,
Quick Start,How it works>Kraft HTTP HandlersandKraft Websocket HandlerandCowboy Handlers, andDocumentation.Modules
Documented:
Not documented:
🔧 Issues:
kraft_cachewhen generating the docs