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,
|
stdenvNoCC,
|
||||||
mdbook,
|
mdbook,
|
||||||
nixdoc,
|
nixdoc,
|
||||||
|
nixosOptionsDoc,
|
||||||
lib,
|
lib,
|
||||||
excluded ? [
|
excluded ? [
|
||||||
".*flake\\.nix$"
|
".*flake\\.nix$"
|
||||||
|
|
@ -45,8 +46,9 @@ stdenvNoCC.mkDerivation {
|
||||||
docs = 0;
|
docs = 0;
|
||||||
flake = 1;
|
flake = 1;
|
||||||
devShells = 2;
|
devShells = 2;
|
||||||
hosts = 3;
|
modules = 3;
|
||||||
users = 4;
|
hosts = 4;
|
||||||
|
users = 5;
|
||||||
};
|
};
|
||||||
order = orderMap.${lib.head (lib.splitString "/" (relPath file))};
|
order = orderMap.${lib.head (lib.splitString "/" (relPath file))};
|
||||||
|
|
||||||
|
|
@ -66,6 +68,18 @@ stdenvNoCC.mkDerivation {
|
||||||
in
|
in
|
||||||
if dirPart == "." then 0 else lib.length (lib.splitString "/" dirPart);
|
if dirPart == "." then 0 else lib.length (lib.splitString "/" dirPart);
|
||||||
indent = lib.concatStringsSep "" (lib.genList (x: " ") depth);
|
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
|
in
|
||||||
{
|
{
|
||||||
script = ''
|
script = ''
|
||||||
|
|
@ -76,6 +90,12 @@ stdenvNoCC.mkDerivation {
|
||||||
--description "${title}" \
|
--description "${title}" \
|
||||||
--anchor-prefix "" \
|
--anchor-prefix "" \
|
||||||
--file "${file}" > "src/${mdPath}"
|
--file "${file}" > "src/${mdPath}"
|
||||||
|
''
|
||||||
|
+ lib.optionalString isModule ''
|
||||||
|
{
|
||||||
|
echo
|
||||||
|
cat ${moduleOptionsDoc}
|
||||||
|
} >> src/${mdPath}
|
||||||
'';
|
'';
|
||||||
summaryLine = "${indent}- [${title}](${mdPath})";
|
summaryLine = "${indent}- [${title}](${mdPath})";
|
||||||
sortKey = toString order + mdPath;
|
sortKey = toString order + mdPath;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue