feat(docs): modules docgen

This commit is contained in:
Sk7Str1p3 2026-07-26 19:09:46 +00:00
parent 403cd57c21
commit 4b91758f07
Signed by: Sk7Str1p3
SSH key fingerprint: SHA256:GcXqjfo0IHK280c6aH9o5SmcOWyqMS8gjfOtDQ3gr/Q

View file

@ -2,6 +2,7 @@
stdenvNoCC,
mdbook,
nixdoc,
nixosOptionsDoc,
lib,
excluded ? [
".*flake\\.nix$"
@ -45,8 +46,9 @@ stdenvNoCC.mkDerivation {
docs = 0;
flake = 1;
devShells = 2;
hosts = 3;
users = 4;
modules = 3;
hosts = 4;
users = 5;
};
order = orderMap.${lib.head (lib.splitString "/" (relPath file))};
@ -66,6 +68,18 @@ stdenvNoCC.mkDerivation {
in
if dirPart == "." then 0 else lib.length (lib.splitString "/" dirPart);
indent = lib.concatStringsSep "" (lib.genList (x: " ") depth);
isModule = (r: lib.hasPrefix "modules/os" r || lib.hasPrefix "modules/home" r) relPath;
modulesEval = lib.evalModules {
modules = [
file
{ _module.check = false; }
];
};
moduleOptionsDoc =
(nixosOptionsDoc {
options = lib.removeAttrs modulesEval.options [ "_module" ];
}).optionsCommonMark;
in
{
script = ''
@ -76,6 +90,12 @@ stdenvNoCC.mkDerivation {
--description "${title}" \
--anchor-prefix "" \
--file "${file}" > "src/${mdPath}"
''
+ lib.optionalString isModule ''
{
echo
cat ${moduleOptionsDoc}
} >> src/${mdPath}
'';
summaryLine = "${indent}- [${title}](${mdPath})";
sortKey = toString order + mdPath;