Currently, the best API docs are in lua_api.md. However, those docs don't strictly follow any schema aside from "valid Markdown." They are easy to read as people, but hard to transform into other docs like a TypeScript API or something for a language server to provide IntelliSense.
To make the docs parsable, we need two things:
- An agreement on a consistent format to present the API (how to present function names, arg names, arg types, descriptions, tables, etc.)
- Content that aligns to that agreement
For the consistent format, there are multiple approaches:
- defining a stricter Markdown schema for lua_api.md and enforcing it via CI
- adding comment headers to the actual engine code and parsing that
- other approaches?
From there, we'd need to update the content no matter what choice we have.
Once the API docs (or, at least the core namespace reference) are programmatically parsable, we can focus on providing a Language Server plugin (e.g. a LuaLS addon) so that modders can get insights while editing in an IDE instead of waiting to try to run their mod. However, this hasn't been discussed so I won't create a new issue for it.
Related issues:
Related efforts:
Considered approaches (basic thoughts noted, Markdown accepted, see comments and #315):
- EmmyLua: still Lua, decent underlying parser, development recently picked up. Not expressive enough.
- JSON: tons of tooling support. No clear schema, hard to handwrite.
- LuaCATS: still Lua, has decent underlying parser. Not expressive enough, underlying parser development stalling
- Markdown: very expressive, tons of tooling support. No clear schema yet defined, no parser built.
- Teal: still Lua, more type support. Underlying development stalling
- TOML: not explored
- TypeScript: extremely complex types supported, tons of tooling support. Not Lua, not used elsewhere in Luanti repo
- XML/XSD: not explored, would be very verbose to handwrite. XSD = XML Schema Definition
- YAML: tons of tooling support. No clear schema, can be easy to make mistakes
Currently, the best API docs are in lua_api.md. However, those docs don't strictly follow any schema aside from "valid Markdown." They are easy to read as people, but hard to transform into other docs like a TypeScript API or something for a language server to provide IntelliSense.
To make the docs parsable, we need two things:
For the consistent format, there are multiple approaches:
From there, we'd need to update the content no matter what choice we have.
Once the API docs (or, at least the core namespace reference) are programmatically parsable, we can focus on providing a Language Server plugin (e.g. a LuaLS addon) so that modders can get insights while editing in an IDE instead of waiting to try to run their mod. However, this hasn't been discussed so I won't create a new issue for it.
Related issues:
Related efforts:
Considered approaches (basic thoughts noted, Markdown accepted, see comments and #315):