feat(docs): modules docgen
This commit is contained in:
parent
403cd57c21
commit
4b91758f07
1 changed files with 22 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue