docs: Lua docstrings guidance #25345

Recommend adding a space after i.e. `--- @see`.

The "space" variant is common for the vast majority of docstring formats
such as doxygen, javadoc and typescript.
This commit is contained in:
dundargoc 2023-09-28 06:57:22 +02:00 committed by GitHub
parent e46f5aab89
commit 1913041518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -308,11 +308,11 @@ types, etc. See [:help dev-doc-lua][dev-doc-lua].
--- ---
--- {Long explanation} --- {Long explanation}
--- ---
---@param arg1 type {description} --- @param arg1 type {description}
---@param arg2 type {description} --- @param arg2 type {description}
--- ... --- ...
--- ---
---@return type {description} --- @return type {description}
``` ```
- If possible, add type information (`table`, `string`, `number`, ...). Multiple valid types are separated by a bar (`string|table`). Indicate optional parameters via `type|nil`. - If possible, add type information (`table`, `string`, `number`, ...). Multiple valid types are separated by a bar (`string|table`). Indicate optional parameters via `type|nil`.
- If a function in your Lua module should _not_ be documented, add `@nodoc`. - If a function in your Lua module should _not_ be documented, add `@nodoc`.

View File

@ -232,10 +232,11 @@ Lua documentation lives in the source code, as docstrings on the function
definitions. The |lua-vim| :help is generated from the docstrings. definitions. The |lua-vim| :help is generated from the docstrings.
Docstring format: Docstring format:
- Use LuaLS annotations: https://github.com/LuaLS/lua-language-server/wiki/Annotations - Use LuaLS annotations (with minor adjustments, which will be explained
- Lines in the main description start with `---` below): https://luals.github.io/wiki/annotations/
- Special tokens start with `---@` followed by the token name: - Lines in the main description start with `--- `
`---@see`, `---@param`, `---@returns` - Special tokens start with `--- @` followed by the token name: `--- @see`,
`--- @param`, `--- @returns`. Note the space between `---` and `@`.
- Limited markdown is supported. - Limited markdown is supported.
- List-items start with `-` (useful to nest or "indent") - List-items start with `-` (useful to nest or "indent")
- Use ``` for code samples. - Use ``` for code samples.
@ -258,11 +259,11 @@ vim.paste in runtime/lua/vim/_editor.lua like this: >
--- end)() --- end)()
--- ``` --- ```
--- ---
---@see |paste| --- @see |paste|
--- ---
---@param lines ... --- @param lines ...
---@param phase ... --- @param phase ...
---@returns false if client should cancel the paste. --- @returns false if client should cancel the paste.
LUA STDLIB DESIGN GUIDELINES *dev-lua* LUA STDLIB DESIGN GUIDELINES *dev-lua*