-
Notifications
You must be signed in to change notification settings - Fork 190
feat(doc): move to structured format #762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Closes #632 Having a structured "source of truth" for these would also allow generating meta files that can be ingested by structural analysis tools (lua-language-server, emmylua-rust-analyzer) as a maintained replacement of https://github.com/LuaCATS/luv. (This can be automated with a GH workflow to ensure that docs and meta files are always updated and consistent.) |
10c97d0
to
45c65bc
Compare
e70f53b
to
fdac57a
Compare
This change introduces the files `docs.lua` and `docgen.lua` which are used to generate `docs.md`. `docs.lua` use a bespoke format designed so it can emit the `docs.md` as close to the original version. `docgen.lua` takes `docs.lua` as an input an emits `docs.md`. To regenerate the `docs.md`, simply run `lua docgen.lua`. Closes luvit#632
What does moving from docs.md to a structured docs.lua gain that wouldn't be gained by moving all of the documentation to inline (using something like ldoc, and then potentially our own docgen so we maintain the current style), so the documentation for each function is as close to its source as possible, to decrease likelihood that the code and documentation become out of sync. |
What do you mean by inline?
Ldoc is pretty useless for what we want here. The goal is to also generate https://github.com/LuaCATS/luv which I've got a working script for, I can add that to this PR.
This PR already does this, and does so whilst making minimal changes to We could have https://github.com/LuaCATS/luv as source, but parsing that is non-trivial and realistically requires external tools. This PR only depends on Lua. I'll also mention there has already been agreement to do exactly what this PR implements. |
Adjacent to the C code that implements the function.
The tool is, definitely; the format is well adjusted to documenting C modules though, especially if we allow diverging from the format. Or consider adapting another format like LuaCATS to be reasonable to use in C code.
This documentation moves the source of truth for documentation from docs.md to docs.lua, not from docs.md to the implementations in the C code.
Don't get me wrong, I agree and this is a good step in the right direction, but this is a good chance to think deeper about how this can be implemented such that we never have to think about it again. |
Having the docs in the C code would be ideal. However, I do not have a strategy on how to achieve that. E.g. how would you handle the async and sync variations of functions? Documenting the structures of all the different table inputs/outputs. Union types? Doc hierarchy? Constants? My goals here are:
If it helps, I wouldn't mind this PR being viewed as a stop-gap solution until something more sophisticated is introduced. |
Looks great to me, thanks for doing this! Very cool to see that the |
This change introduces the files
docs.lua
anddocgen.lua
which are used to generate
docs.md
.docs.lua
use a bespoke format designed so it can emit thedocs.md
as close to the original version.
docgen.lua
takesdocs.lua
as an input an emitsdocs.md
.To regenerate the
docs.md
, simply runlua docgen.lua
.Closes #632