mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
docs/man: minor cleanup
- Move lua filter to separate file - Use a subshell to write `nixvim-header.5` - Use bash function to avoid repetition
This commit is contained in:
parent
2a4719f275
commit
61c44d7a7f
2 changed files with 32 additions and 29 deletions
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
lib,
|
||||||
options-json,
|
options-json,
|
||||||
runCommand,
|
runCommand,
|
||||||
installShellFiles,
|
installShellFiles,
|
||||||
|
@ -6,42 +7,29 @@
|
||||||
pandoc,
|
pandoc,
|
||||||
}:
|
}:
|
||||||
let
|
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 =
|
manHeader =
|
||||||
let
|
|
||||||
mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})";
|
|
||||||
in
|
|
||||||
runCommand "nixvim-general-doc-manpage"
|
runCommand "nixvim-general-doc-manpage"
|
||||||
{
|
{
|
||||||
nativeBuildInputs = [ pandoc ];
|
nativeBuildInputs = [ pandoc ];
|
||||||
inherit manualFilter;
|
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
|
function mkMDSection {
|
||||||
|
file="$1"
|
||||||
|
pandoc --lua-filter ${./filter.lua} -f gfm -t man "$file"
|
||||||
|
}
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cat \
|
|
||||||
${./nixvim-header-start.5} \
|
(
|
||||||
${mkMDSection ../user-guide/helpers.md} \
|
cat ${./nixvim-header-start.5}
|
||||||
${mkMDSection ../user-guide/faq.md} \
|
|
||||||
${mkMDSection ../user-guide/config-examples.md} \
|
${lib.concatMapStringsSep "\n" (file: "mkMDSection ${file}") [
|
||||||
${./nixvim-header-end.5} \
|
../user-guide/helpers.md
|
||||||
>$out/nixvim-header.5
|
../user-guide/faq.md
|
||||||
|
../user-guide/config-examples.md
|
||||||
|
]}
|
||||||
|
|
||||||
|
cat ${./nixvim-header-end.5}
|
||||||
|
) >$out/nixvim-header.5
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
# FIXME add platform specific docs to manpage
|
# FIXME add platform specific docs to manpage
|
||||||
|
|
15
docs/man/filter.lua
Normal file
15
docs/man/filter.lua
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue