2024-06-30 05:43:43 +00:00
|
|
|
# Generates the documentation for library functions via nixdoc.
|
2024-06-30 21:57:03 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-06-30 05:43:43 +00:00
|
|
|
let
|
|
|
|
|
2024-06-30 21:57:03 +00:00
|
|
|
inherit (pkgs) stdenv nixdoc;
|
2024-06-30 05:43:43 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "nixpkgs-lib-docs";
|
|
|
|
src = "${inputs.nixpkgs.outPath}/lib";
|
|
|
|
|
|
|
|
buildInputs = [ nixdoc ];
|
|
|
|
installPhase = ''
|
|
|
|
function docgen {
|
|
|
|
name=$1
|
|
|
|
baseName=$2
|
|
|
|
description=$3
|
|
|
|
# TODO: wrap lib.$name in <literal>, make nixdoc not escape it
|
|
|
|
if [[ -e "../lib/$baseName.nix" ]]; then
|
2024-06-30 21:57:03 +00:00
|
|
|
nixdoc -c "$name" -d "lib.$name: $description" -l ${pkgs.amg.doc-locations-json} -f "$baseName.nix" > "$out/$name.md"
|
2024-06-30 05:43:43 +00:00
|
|
|
else
|
2024-06-30 21:57:03 +00:00
|
|
|
nixdoc -c "$name" -d "lib.$name: $description" -l ${pkgs.amg.doc-locations-json} -f "$baseName/default.nix" > "$out/$name.md"
|
2024-06-30 05:43:43 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
mkdir -p "$out"
|
|
|
|
|
|
|
|
${lib.concatMapStrings (
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
baseName ? name,
|
|
|
|
description,
|
|
|
|
}:
|
|
|
|
''
|
|
|
|
docgen ${name} ${baseName} ${lib.escapeShellArg description}
|
|
|
|
''
|
2024-06-30 21:57:03 +00:00
|
|
|
) lib.amg.libsets}
|
2024-06-30 05:43:43 +00:00
|
|
|
'';
|
|
|
|
}
|