Split documentation into each file
This commit is contained in:
parent
dfc4b5cf94
commit
4cd9e462d8
16 changed files with 205 additions and 187 deletions
|
|
@ -1,32 +1,41 @@
|
|||
# with friendly help by stylix: https://github.com/danth/stylix/blob/master/docs/default.nix
|
||||
{ pkgs, build_systems, ... }:
|
||||
|
||||
{
|
||||
pkgs,
|
||||
build_systems,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
makeOptionsDoc =
|
||||
configuration:
|
||||
pkgs.nixosOptionsDoc {
|
||||
inherit (configuration) options;
|
||||
|
||||
# Filter out any options not beginning with `stylix`
|
||||
transformOptions =
|
||||
option:
|
||||
option
|
||||
// {
|
||||
visible =
|
||||
builtins.elemAt option.loc 0 != "kernel"
|
||||
&& option.visible
|
||||
&& (builtins.elemAt option.loc 0 == "conf" || builtins.elemAt option.loc 0 == "mods");
|
||||
};
|
||||
};
|
||||
example = makeOptionsDoc (build_systems [ "example" ] ../example/.)."example";
|
||||
makeOptionsDoc = configuration: pkgs.nixosOptionsDoc { options = configuration; };
|
||||
generateDocs = obj: ''
|
||||
touch src/${obj.fst}.md
|
||||
sed '/*Declared by:*/,/^$/d' <${obj.snd.optionsCommonMark} >> src/${obj.fst}.md
|
||||
'';
|
||||
summaryAppend = name: ''
|
||||
echo "- [${name}](${name}.md)" >> src/SUMMARY.md
|
||||
'';
|
||||
system = (build_systems [ "example" ] ../example/.)."example".options;
|
||||
makeOptionsDocPrograms = name: pkgs.nixosOptionsDoc { options = system.mods.${name}; };
|
||||
conf = makeOptionsDoc system.conf;
|
||||
paths = builtins.readDir ../modules/programs;
|
||||
names = lib.lists.remove "default" (
|
||||
map (name: lib.strings.removeSuffix ".nix" name) (lib.attrsets.mapAttrsToList (name: _: name) paths)
|
||||
);
|
||||
mods = map makeOptionsDocPrograms names;
|
||||
docs = lib.strings.concatLines (map generateDocs (lib.lists.zipLists names mods));
|
||||
summary = lib.strings.concatStringsSep " " (map summaryAppend names);
|
||||
in
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "dashNix-book";
|
||||
src = ./.;
|
||||
|
||||
patchPhase = ''
|
||||
sed '/*Declared by:*/,/^$/d' <${example.optionsCommonMark} >> src/dashNix.md
|
||||
sed '/*Declared by:*/,/^$/d' <${conf.optionsCommonMark} >> src/conf.md
|
||||
${docs}
|
||||
echo "[README](README.md)\n # Options\n - [Base Config](conf.md)" >> src/SUMMARY.md
|
||||
${summary}
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
${pkgs.mdbook}/bin/mdbook build --dest-dir $out
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue