diff options
Diffstat (limited to 'scripts/docgen.lua')
| -rw-r--r-- | scripts/docgen.lua | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/scripts/docgen.lua b/scripts/docgen.lua index f39beb8f..fdb77849 100644 --- a/scripts/docgen.lua +++ b/scripts/docgen.lua @@ -74,11 +74,10 @@ local lsp_section_template = [[ ```lua require'lspconfig'.{{template_name}}.setup{} ``` +{{commands}} -**Commands and default values:** -```lua -{{body}} -``` +**Default values:** +{{default_values}} ]] @@ -101,16 +100,16 @@ local function make_lsp_sections() local params = { template_name = template_name, preamble = '', - body = '', + commands = '', + default_values = '', } - params.body = make_section(2, '\n\n', { + params.commands = make_section(0, '\n\n', { function() - if not template_def.commands then + if not template_def.commands or #template_def.commands == 0 then return end - return make_section(0, '\n', { - 'Commands:', + return '**Commands:**\n' .. make_section(0, '\n', { sorted_map_table(template_def.commands, function(name, def) if def.description then return string.format('- %s: %s', name, def.description) @@ -119,12 +118,14 @@ local function make_lsp_sections() end), }) end, + }) + + params.default_values = make_section(2, '\n\n', { function() if not template_def.default_config then return end return make_section(0, '\n', { - 'Default Values:', sorted_map_table(template_def.default_config, function(k, v) local description = ((docs or {}).default_config or {})[k] if description and type(description) ~= 'string' then @@ -147,7 +148,7 @@ local function make_lsp_sections() description = table.concat(root_dir, '\n') description = string.gsub(description, '.*function', 'function') end - return indent(2, string.format('%s = %s', k, description or inspect(v))) + return string.format('- `%s` : \n```lua\n%s\n```', k, description or inspect(v)) end), }) end, |
