mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 21:06:46 +00:00
docs: migrating docs from readme
This commit is contained in:
parent
eec66ae9f7
commit
692ac7a301
15 changed files with 861 additions and 48 deletions
|
@ -1,5 +1,39 @@
|
|||
local Docs = require("lazy.docs")
|
||||
local Util = require("lazy.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
---@param path string
|
||||
local function dir(path)
|
||||
local plugin, extra = path:match("([^/]+)(.*)")
|
||||
return require("lazy.core.config").plugins[plugin].dir .. extra
|
||||
end
|
||||
|
||||
M.extract = {
|
||||
installation = {
|
||||
bootstrap = {
|
||||
lang = 'lua title="lua/config/lazy.lua"',
|
||||
content = Docs.extract(dir("lazy.nvim/lua/lazy/init.lua"), "function M%.bootstrap%(%)\n(.-)\nend"),
|
||||
},
|
||||
},
|
||||
["configuration/index"] = {
|
||||
config = Docs.extract(dir("lazy.nvim/lua/lazy/core/config.lua"), "\nM%.defaults = ({.-\n})")
|
||||
:gsub("%s*debug = false.\n", "\n"),
|
||||
},
|
||||
["configuration/highlights"] = {
|
||||
colors = Docs.colors({
|
||||
path = dir("lazy.nvim/lua/lazy/view/colors.lua"),
|
||||
}),
|
||||
},
|
||||
["spec/examples"] = {
|
||||
examples = Util.read_file(dir("lazy.nvim/lua/lazy/example.lua")),
|
||||
},
|
||||
["usage/index"] = {
|
||||
stats = Docs.extract(dir("lazy.nvim/lua/lazy/stats.lua"), "\nM%._stats = ({.-\n})"),
|
||||
commands = Docs.commands(),
|
||||
},
|
||||
}
|
||||
|
||||
local function exec(cmd)
|
||||
return vim.system(vim.split(cmd, " "), { text = true }):wait()
|
||||
end
|
||||
|
@ -10,8 +44,24 @@ function M.themes()
|
|||
exec("cp -r .nvim/plugins/tokyonight.nvim/extras/prism src/themes/prism")
|
||||
end
|
||||
|
||||
function M.docs()
|
||||
for name, data in pairs(M.extract) do
|
||||
local md = "docs/" .. name .. ".md"
|
||||
print("Building " .. md)
|
||||
Docs.save(data, md)
|
||||
end
|
||||
end
|
||||
|
||||
function M._old()
|
||||
M.save({
|
||||
stats = M.extract("lua/lazy/stats.lua", "\nM%._stats = ({.-\n})"),
|
||||
commands = M.commands(),
|
||||
})
|
||||
end
|
||||
|
||||
function M.update()
|
||||
M.themes()
|
||||
M.docs()
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue