docs: added recipes

This commit is contained in:
Folke Lemaitre 2023-02-07 19:42:01 +01:00
parent 0968e24f82
commit 9131897b61
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -129,6 +129,34 @@ import TabItem from '@theme/TabItem';
return { content = table.concat(lines, "\n") }
end
function M.recipes()
local src = Util.read_file(vim.fs.normalize("~/projects/lazyvim.github.io/lua/recipes.lua"))
local lines = vim.split(src, "\n")
local ret = {}
local header = {} ---@type string[]
local block = {} ---@type string[]
for _, line in ipairs(lines) do
local comment = line:match("^ %-%- (.*)")
if comment then
header[#header + 1] = comment
elseif line:find("^ {") then
block = { "{" }
elseif line:find("^ }") then
block[#block + 1] = " }"
vim.list_extend(ret, header)
ret[#ret + 1] = "\n```lua"
local code = Docs.fix_indent(table.concat(block, "\n"))
ret[#ret + 1] = code
ret[#ret + 1] = "```\n"
header = {}
block = {}
else
block[#block + 1] = line
end
end
return { content = table.concat(ret, "\n") }
end
function M.update2()
local docs = vim.fs.normalize("~/projects/lazyvim.github.io/docs")
@ -136,6 +164,10 @@ function M.update2()
general = M.general(),
}, docs .. "/configuration/general.md")
Docs.save({
recipes = M.recipes(),
}, docs .. "/configuration/recipes.md")
Docs.save({
lazy = {
content = [[```lua title="lua/config/lazy.lua"]] .. "\n" .. Util.read_file(