Skip to content

Commit

Permalink
ci: better docgen
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Mar 27, 2024
1 parent e888d5b commit e753eb6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lua/lazy/docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,15 @@ function M.table(lines)
return table.concat(ret, "\n")
end

---@param opts? {name?:string, path?:string, modname?:string}
---@return ReadmeBlock
function M.colors()
local str = M.extract("lua/lazy/view/colors.lua", "\nM%.colors = ({.-\n})")
function M.colors(opts)
opts = vim.tbl_extend("force", {
name = "Lazy",
path = "lua/lazy/view/colors.lua",
modname = "lazy.view.colors",
}, opts or {})
local str = M.extract(opts.path, "\nM%.colors = ({.-\n})")
---@type table<string,string>
local comments = {}
for _, line in ipairs(vim.split(str, "\n")) do
Expand All @@ -124,8 +130,8 @@ function M.colors()
{ "Highlight Group", "Default Group", "Description" },
{ "---", "---", "---" },
}
Util.foreach(require("lazy.view.colors").colors, function(group, link)
lines[#lines + 1] = { "**Lazy" .. group .. "**", "***" .. link .. "***", comments[group] or "" }
Util.foreach(require(opts.modname).colors, function(group, link)
lines[#lines + 1] = { "**" .. opts.name .. group .. "**", "***" .. link .. "***", comments[group] or "" }
end)
return { content = M.table(lines) }
end
Expand Down

0 comments on commit e753eb6

Please sign in to comment.