mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-15 03:34:31 +02:00
docs: Allow to generate man pages for nixvim (#686)
This commit is contained in:
parent
2031834990
commit
229fe85d6b
5 changed files with 213 additions and 1 deletions
50
man-docs/default.nix
Normal file
50
man-docs/default.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
pkgs,
|
||||
modules,
|
||||
}: let
|
||||
nixvimPath = toString ./..;
|
||||
|
||||
gitHubDeclaration = user: repo: subpath: {
|
||||
url = "https://github.com/${user}/${repo}/blob/master/${subpath}";
|
||||
name = "<${repo}/${subpath}>";
|
||||
};
|
||||
in rec {
|
||||
nixvim-render-docs = pkgs.callPackage ./nixvim-render-docs {};
|
||||
|
||||
man-docs = let
|
||||
eval = pkgs.lib.evalModules {
|
||||
inherit modules;
|
||||
};
|
||||
|
||||
options = pkgs.nixosOptionsDoc {
|
||||
inherit (eval) options;
|
||||
warningsAreErrors = false;
|
||||
transformOptions = opt:
|
||||
opt
|
||||
// {
|
||||
declarations =
|
||||
map (
|
||||
decl:
|
||||
if pkgs.lib.hasPrefix nixvimPath (toString decl)
|
||||
then
|
||||
gitHubDeclaration "nix-community" "nixvim"
|
||||
(pkgs.lib.removePrefix "/" (pkgs.lib.removePrefix nixvimPath (toString decl)))
|
||||
else if decl == "lib/modules.nix"
|
||||
then gitHubDeclaration "NixOS" "nixpkgs" decl
|
||||
else decl
|
||||
)
|
||||
opt.declarations;
|
||||
};
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "nixvim-configuration-reference-manpage" {
|
||||
nativeBuildInputs = with pkgs; [installShellFiles nixvim-render-docs];
|
||||
} ''
|
||||
# Generate man-pages
|
||||
mkdir -p $out/share/man/man5
|
||||
nixvim-render-docs -j $NIX_BUILD_CORES options manpage \
|
||||
--revision unstable \
|
||||
${options.optionsJSON}/share/doc/nixos/options.json \
|
||||
$out/share/man/man5/nixvim.5
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue