mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
docs: use nixosOptionDocs
NixOS 23.11 is deprecating DocBook option documentation. Following home-manager in this change is probably a good idea
This commit is contained in:
parent
e498331ce7
commit
3de5f1ba39
10 changed files with 91 additions and 30 deletions
|
@ -29,25 +29,68 @@
|
|||
];
|
||||
};
|
||||
|
||||
githubDeclaration = user: repo: subpath: let
|
||||
urlRef = "main";
|
||||
in {
|
||||
url = "https://github.com/${user}/${repo}/blob/${urlRef}/${subpath}";
|
||||
name = "<${repo}/${subpath}>";
|
||||
};
|
||||
|
||||
dontCheckDefinitions = {_module.check = false;};
|
||||
|
||||
nvimModuleDocs = nmd.buildModulesDocs {
|
||||
nvimPath = toString ./..;
|
||||
|
||||
buildOptionsDocs = args @ {
|
||||
modules,
|
||||
includeModuleSystemsOptions ? true,
|
||||
...
|
||||
}: let
|
||||
options = (lib.evalModules {inherit modules;}).options;
|
||||
in
|
||||
pkgs.buildPackages.nixosOptionsDoc
|
||||
({
|
||||
options =
|
||||
if includeModuleSystemsOptions
|
||||
then options
|
||||
else builtins.removeAttrs (options ["_module"]);
|
||||
transformOptions = opt:
|
||||
opt
|
||||
// {
|
||||
# Clean up declaration sites to not refer to local source tree
|
||||
declarations =
|
||||
map
|
||||
(decl:
|
||||
if lib.hasPrefix nvimPath (toString decl)
|
||||
then
|
||||
githubDeclaration "notashelf" "neovim-flake"
|
||||
(lib.removePrefix "/" (lib.removePrefix nvimPath (toString decl)))
|
||||
else decl)
|
||||
opt.declarations;
|
||||
};
|
||||
}
|
||||
// builtins.removeAttrs args ["modules" "includeModuleSystemsOptions"]);
|
||||
|
||||
nvimModuleDocs = buildOptionsDocs {
|
||||
modules =
|
||||
import ../modules/modules.nix {
|
||||
import ../modules/modules.nix
|
||||
{
|
||||
inherit pkgs lib;
|
||||
check = false;
|
||||
}
|
||||
++ [scrubbedPkgsModule dontCheckDefinitions];
|
||||
moduleRootPaths = [./..];
|
||||
mkModuleUrl = path: "https://github.com/notashelf/neovim-flake/blob/main/${path}#blob-path";
|
||||
channelName = "neovim-flake";
|
||||
docBook.id = "neovim-flake-options";
|
||||
++ [scrubbedPkgsModule];
|
||||
variablelistId = "neovim-flake-options";
|
||||
};
|
||||
|
||||
docs = nmd.buildDocBookDocs {
|
||||
pathName = "neovim-flake";
|
||||
projectName = "neovim-flake";
|
||||
modulesDocs = [nvimModuleDocs];
|
||||
modulesDocs = [
|
||||
{
|
||||
docBook = pkgs.linkFarm "nvim-module-docs-for-nmd" {
|
||||
"nmd-result/neovim-flake-options.xml" = nvimModuleDocs.optionsDocBook;
|
||||
};
|
||||
}
|
||||
];
|
||||
documentsDirectory = ./.;
|
||||
documentType = "book";
|
||||
chunkToc = ''
|
||||
|
@ -65,7 +108,24 @@
|
|||
'';
|
||||
};
|
||||
in {
|
||||
options.json = nvimModuleDocs.json.override {path = "share/doc/neovim-flake/options.json";};
|
||||
manPages = docs.manPages;
|
||||
options.json =
|
||||
pkgs.runCommand "options.json"
|
||||
# TODO: Use `nvimOptionsDoc.optionsJSON` directly once upstream
|
||||
# `nixosOptionsDoc` is more customizable
|
||||
{
|
||||
meta.description = "List of neovim-flake options in JSON format";
|
||||
} ''
|
||||
mkdir -p $out/{share/doc,nix-support}
|
||||
cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/neovim-flake
|
||||
substitute \
|
||||
${nvimModuleDocs.optionsJSON}/nix-support/hydra-build-products \
|
||||
$out/nix-support/hydra-build-products \
|
||||
--replace \
|
||||
'${nvimModuleDocs.optionsJSON}/share/doc/nixos' \
|
||||
"$out/share/doc/neovim-flake"
|
||||
'';
|
||||
|
||||
inherit (docs) manPages;
|
||||
|
||||
manual = {inherit (docs) html htmlOpenTool;};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue