nix-community.nixvim/docs/man/default.nix

66 lines
1.5 KiB
Nix
Raw Permalink Normal View History

{
options-json,
runCommand,
installShellFiles,
nixos-render-docs,
pandoc,
2024-05-05 19:39:35 +02:00
}:
let
2024-02-18 15:56:18 +01:00
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
2024-02-18 15:56:18 +01:00
function Link(el)
return el.content
end
'';
2024-05-05 19:39:35 +02:00
manHeader =
let
mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})";
in
runCommand "nixvim-general-doc-manpage"
{
nativeBuildInputs = [ pandoc ];
inherit manualFilter;
}
''
mkdir -p $out
cat \
${./nixvim-header-start.5} \
${mkMDSection ../user-guide/helpers.md} \
${mkMDSection ../user-guide/faq.md} \
${mkMDSection ../user-guide/config-examples.md} \
2024-05-05 19:39:35 +02:00
${./nixvim-header-end.5} \
>$out/nixvim-header.5
'';
in
2024-05-05 19:39:35 +02:00
# FIXME add platform specific docs to manpage
runCommand "nixvim-configuration-reference-manpage"
{
nativeBuildInputs = [
installShellFiles
nixos-render-docs
];
}
''
# Generate man-pages
mkdir -p $out/share/man/man5
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
--revision unstable \
--header ${manHeader}/nixvim-header.5 \
--footer ${./nixvim-footer.5} \
${options-json}/share/doc/nixos/options.json \
$out/share/man/man5/nixvim.5
compressManPages $out
''