From e753eb602539bdad9f0709066d5893a788cb5db9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 27 Mar 2024 22:58:58 +0100 Subject: [PATCH] ci: better docgen --- lua/lazy/docs.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/lazy/docs.lua b/lua/lazy/docs.lua index bf42e98..c38d047 100644 --- a/lua/lazy/docs.lua +++ b/lua/lazy/docs.lua @@ -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 local comments = {} for _, line in ipairs(vim.split(str, "\n")) do @@ -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