Skip to content

docs/man: minor cleanup #3336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 17 additions & 29 deletions docs/man/default.nix
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
{
lib,
options-json,
runCommand,
installShellFiles,
nixos-render-docs,
pandoc,
}:
let
manualFilter = ''
local text = pandoc.text

function Header(el)
if el.level == 1 then
return el:walk {
Str = function(el)
return pandoc.Str(text.upper(el.text))
end
}
end
end

function Link(el)
return el.content
end
'';

manHeader =
let
mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})";
in
runCommand "nixvim-general-doc-manpage"
{
nativeBuildInputs = [ pandoc ];
inherit manualFilter;
}
''
function mkMDSection {
file="$1"
pandoc --lua-filter ${./filter.lua} -f gfm -t man "$file"
}
mkdir -p $out
cat \
${./nixvim-header-start.5} \
${mkMDSection ../user-guide/helpers.md} \
${mkMDSection ../user-guide/faq.md} \
${mkMDSection ../user-guide/config-examples.md} \
${./nixvim-header-end.5} \
>$out/nixvim-header.5

(
cat ${./nixvim-header-start.5}

${lib.concatMapStringsSep "\n" (file: "mkMDSection ${file}") [
../user-guide/helpers.md
../user-guide/faq.md
../user-guide/config-examples.md
]}

cat ${./nixvim-header-end.5}
) >$out/nixvim-header.5
'';
in
# FIXME add platform specific docs to manpage
Expand Down
15 changes: 15 additions & 0 deletions docs/man/filter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local text = pandoc.text

function Header(el)
if el.level == 1 then
return el:walk({
Str = function(el)
return pandoc.Str(text.upper(el.text))
end,
})
end
end

function Link(el)
return el.content
end