From 6772d0560bb1ee2233540e01c2dcc0e874a9aa53 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Wed, 28 Feb 2024 19:44:24 +0200 Subject: [PATCH] feat: add docs generator --- Taskfile.yml | 10 ++++++++++ scripts/doc_gen.lua | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index b6810bf..83ddba3 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -37,3 +37,13 @@ tasks: {minimal_init='./scripts/minimal_init.lua' \ ,sequential=true}" \ -c ":qa!" + + docgen: + desc: generate vimhelp + cmds: + - | + nvim --noplugin \ + --headless \ + -u "./scripts/minimal_init.lua" \ + -c "luafile ./scripts/doc_gen.lua" \ + -c "qa!" diff --git a/scripts/doc_gen.lua b/scripts/doc_gen.lua index 2783c06..5ba0b7d 100644 --- a/scripts/doc_gen.lua +++ b/scripts/doc_gen.lua @@ -7,6 +7,23 @@ if not okay then return end +local files = { + "lua/gopher/init.lua", + "lua/gopher/config.lua", +} + minidoc.setup() -MiniDoc.generate({ "lua/gopher" }, "doc/gopher.nvim.txt") +local hooks = vim.deepcopy(minidoc.default_hooks) +hooks.write_pre = function(lines) + -- Remove first two lines with `======` and `------` delimiters to comply + -- with `:h local-additions` template + table.remove(lines, 1) + table.remove(lines, 1) + + return lines +end + +print "Generating documentation...\n" +MiniDoc.generate(files, "doc/gopher.nvim.txt", { hooks = hooks }) +print "Generation complete!\n"