Skip to content

Commit

Permalink
feat(docgen): add module page generator
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Feb 3, 2023
1 parent a0cd1a2 commit 17496a8
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docgen/docgen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,54 @@ docgen.generators = {

return docgen.evaluate_functions(structure)
end,

--- Generates the page for any Neorg module
---@param modules Modules #The list of currently loaded modules
---@param module Module #The module we want to generate the page for
---@param configuration string[] #An array of markdown strings detailing the configuration options for the module
---@return string[] #A table of markdown strings representing the page
module = function(modules, module, configuration)
local structure = {
'<div align="center">',
"",
"# `" .. module.parsed.name .. "`",
"",
"### " .. (module.top_comment_data.title or ""),
"",
module.top_comment_data.description or "",
"",
module.top_comment_data.embed and ("![module-showcase](" .. module.top_comment_data.embed .. ")") or "",
"",
"</div>",
"",
function()
if module.top_comment_data.markdown and not vim.tbl_isempty(module.top_comment_data.markdown) then
return vim.list_extend({
"# Overview",
"",
}, module.top_comment_data.markdown)
end

return {}
end,
"",
"# Configuration",
"",
function()
if vim.tbl_isempty(configuration) then
return {
"# Configuration",
"",
"This module provides no configuration options!",
}
else
return configuration
end
end,
}

return docgen.evaluate_functions(structure)
end,
}

--- Check the integrity of the description comments found in configuration blocks
Expand Down

0 comments on commit 17496a8

Please sign in to comment.