Announcing ‘mini.doc’

announce
reddit
Generate help files from EmmyLua-like annotations
Author

Evgeni Chasnovski

Published

January 20, 2022

Originally posted on Reddit

Hello people!

I am happy to announce mini.doc - module of mini.nvim for generating help files (what you read when using :help) from EmmyLua-like annotations (not fully complying with this standard but very close). The basic idea is to keep documentation close to Lua implementation and generate help files automatically. It was written mainly to document ‘mini.nvim’ (instead of previous great but not that flexible tjdevries/tree-sitter-lua), but other people can also benefit from this. And not only plugin authors: general user can also document their Neovim Lua setup!

Basically, it works like this:

To give an example, this Lua code …

--- My very first Lua function
---
---@param x number First number.
---@param y number Second number.
---
---@return number Sum of `x` and `y`.
Module.my_fun = function(x, y)
  return x + y
end

… will be converted into these lines (in actual help file they are a bit more colorful):

                                                               *Module.my_fun()*
                           `Module.my_fun`({x}, {y})
My very first Lua function

Parameters~
{x} `(number)` First number.
{y} `(number)` Second number.

Return~
`(number)` Sum of `x` and `y`.

What extra features I consider to be very useful:

For full disclosure, what features are not that great but probably will stay in order to manage complexity:

Give it a try! Feedback is highly welcome (either here or in this dedicated issue). I consider general design to be stable enough with only default behavior subject to change (based on your feedback) before next ‘mini.nvim’ stable release.