docs: separate public and internal modules

This commit is contained in:
DavHau 2024-03-07 15:35:30 +07:00 committed by mergify[bot]
parent 1633930077
commit 3b9e0780a0
2 changed files with 49 additions and 8 deletions

View File

@ -307,6 +307,14 @@ in {
Remove local anchor links, a workaround for proper {option}`` support in the doc tooling.
'';
};
chapter = mkOption {
type = types.str;
default = "Chapter";
description = ''
Name of the chapter to put this modules docs in.
'';
};
};
config = {
_nixosOptionsDoc = pkgs.nixosOptionsDoc {
@ -373,14 +381,33 @@ in {
# Summary
# - [Reference Documentation]()
# - [core (built in)](./options/core.md)
generated-summary-md = pkgs.writeText "SUMMARY.md" ''
${
lib.concatStringsSep "\n"
(lib.mapAttrsToList
(name: inputCfg: " - [${inputCfg.sourceName}](./options/${name}.md)")
cfg.inputs)
}
'';
generated-summary-md = let
chapters = lib.zipAttrs (
lib.mapAttrsToList
(name: inputCfg: {
${inputCfg.chapter} = inputCfg // {inherit name;};
})
cfg.inputs
);
in
pkgs.writeText "SUMMARY.md" ''
${
lib.concatStringsSep "\n"
(
lib.flatten (
lib.mapAttrsToList
(
chapter: inputs:
[" - [${chapter}]()"]
++ (map
(inputCfg: " - [${inputCfg.sourceName}](./options/${inputCfg.name}.md)")
inputs)
)
chapters
)
)
}
'';
generated-docs =
pkgs.runCommand "generated-docs"
{

View File

@ -21,6 +21,16 @@
# doesn't need to be rendered
"_template"
];
public = lib.genAttrs [
"nodejs-devshell-v3"
"nodejs-node-modules-v3"
"nodejs-package-json-v3"
"nodejs-package-lock-v3"
"php-composer-lock"
"pip"
"rust-cargo-lock"
"rust-crane"
] (name: null);
in {
render.inputs =
lib.flip lib.mapAttrs
@ -48,6 +58,10 @@
else "";
baseUrl = "https://github.com/nix-community/dream2nix/blob/master";
separateEval = true;
chapter =
if public ? ${name}
then "Modules"
else "Modules (Internal + Experimental)";
});
};
}