Luals2dox is an input filter for Doxygen that filters Lua files.
Lua files shall be annotated for use with LuaLS, the Lua Language Server, that is a necessary requirement for Luals2dox.
Doxyfile, Doxygen configuration file.doc.json, documentation file created by LuaLS.
Put these files into your project documentation directory where you want to compile the documentation.
Create a standard Doxyfile with
$ doxygen -gand edit this file as described in Section Configuration in Doxygen.
Run the following command in your project documentation directory to create file doc.json.
$ lua-language-server --doc path/to/src/code/ --doc_out_path ./Run doxygen to generate the documentation.
$ doxygenAll you have to do to update the documentation is to rerun Doxygen. You do not need to update doc.json manually, as this is done by luals2dox automatically.
For using luals2dox in Doxygen apply the following configuration settings, either manually or by using doxywizard.
Add .lua file name extension to FILE_PATTERNS.
(See Section Expert/Input in doxywizard.)
FILE_PATTERNS = *.luaAdd luals2dox as a filter for .lua files.
(See Section Expert/Project in doxywizard.)
FILTER_PATTERNS = *.lua=luals2doxSince luals2dox creates pseudo C++ code, you have to tell doxygen to use its C++ parser to understand .lua files.
(See Section Expert/Project in doxywizard.)
EXTENSION_MAPPING = .lua=C++Luals2dox uses Unicode characters that are not defined in LaTeX by default. Therefore it’s necessary
to define these characters in a user defined LaTeX style file, e.g. mystyle.sty.
(See Section Expert/LaTeX in doxywizard.)
LATEX_EXTRA_STYLESHEET = mystyle.styFile mystyle.sty shall contain the following definitions:
\DeclareUnicodeCharacter{2772}{[}
\DeclareUnicodeCharacter{2773}{]}A summary page of asynchronous functions, functions marked with @async (see LuaLS annotations), can be created with the following alias.
(See Section Export/Project in doxywizard.)
ALIASES = "async=@xrefitem note \"Asyncronous Function\" \"Asyncronous Functions List\"You can call luals2dox from the command line to check the pseudo C++ code that it creates.
$ luals2dox path/to/file.luaIt’s common to write LuaLS annotations without any whitespace characters between --- and @.
E.g. ---@param foo string. While this works fine with LuaLS specific @-commands, it doesn’t work with doxygen specific @-commands.
The following does not work:
---@code{.lua}
--- foo = { a = 1 }
---@endcodeIn order to use doxygen specific @-commands you have to put a whitespace character between --- and @.
--- @code{.lua}
--- foo = { a = 1 }
--- @endcodeTo be more specific: This is an issue if the comment block is passed through LuaLS’ doc.json file.
However, some comment blocks, like @file, are read directly from the lua file (not via doc.json), where this is not an issue. Anyway it’s always save to add a whitespace character for doxygen specific @-commands.