2022-12-11 15:56:09 +01:00
|
|
|
# Generates the documentation for library functions via nixdoc.
|
2024-07-26 20:34:58 +02:00
|
|
|
# To run this derivation, `nix-build -A nixpkgs-manual.lib-docs`
|
2024-07-26 19:50:26 +02:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenvNoCC,
|
|
|
|
nixdoc,
|
|
|
|
nix,
|
|
|
|
nixpkgs ? { },
|
|
|
|
libsets ? [
|
|
|
|
{
|
|
|
|
name = "asserts";
|
|
|
|
description = "assertion functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "attrsets";
|
|
|
|
description = "attribute set functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "strings";
|
|
|
|
description = "string manipulation functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "versions";
|
|
|
|
description = "version string functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "trivial";
|
|
|
|
description = "miscellaneous functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "fixedPoints";
|
|
|
|
baseName = "fixed-points";
|
|
|
|
description = "explicit recursion functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "lists";
|
|
|
|
description = "list manipulation functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "debug";
|
|
|
|
description = "debugging functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "options";
|
|
|
|
description = "NixOS / nixpkgs option handling";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "path";
|
|
|
|
description = "path functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "filesystem";
|
|
|
|
description = "filesystem functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "fileset";
|
|
|
|
description = "file set functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "sources";
|
|
|
|
description = "source filtering functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "cli";
|
|
|
|
description = "command-line serialization functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "generators";
|
|
|
|
description = "functions that create file formats from nix data structures";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "gvariant";
|
|
|
|
description = "GVariant formatted string serialization functions";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "customisation";
|
|
|
|
description = "Functions to customise (derivation-related) functions, derivatons, or attribute sets";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "meta";
|
|
|
|
description = "functions for derivation metadata";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "derivations";
|
|
|
|
description = "miscellaneous derivation-specific functions";
|
|
|
|
}
|
|
|
|
],
|
|
|
|
}:
|
2023-06-24 22:14:37 +02:00
|
|
|
|
2024-07-26 19:50:26 +02:00
|
|
|
stdenvNoCC.mkDerivation {
|
2018-12-30 01:10:19 +01:00
|
|
|
name = "nixpkgs-lib-docs";
|
2024-07-26 19:50:26 +02:00
|
|
|
|
|
|
|
src = lib.fileset.toSource {
|
2024-07-18 23:33:29 +02:00
|
|
|
root = ../..;
|
|
|
|
fileset = ../../lib;
|
|
|
|
};
|
2018-12-30 01:10:19 +01:00
|
|
|
|
2024-07-26 19:50:26 +02:00
|
|
|
buildInputs = [
|
|
|
|
nixdoc
|
|
|
|
nix
|
|
|
|
];
|
|
|
|
|
2018-12-30 01:10:19 +01:00
|
|
|
installPhase = ''
|
2024-07-18 23:33:29 +02:00
|
|
|
export NIX_STATE_DIR=$(mktemp -d)
|
|
|
|
nix-instantiate --eval --strict --json ${./lib-function-locations.nix} \
|
|
|
|
--arg nixpkgsPath "./." \
|
|
|
|
--argstr revision ${nixpkgs.rev or "master"} \
|
2024-07-26 19:50:26 +02:00
|
|
|
--argstr libsetsJSON ${lib.escapeShellArg (builtins.toJSON libsets)} \
|
2024-07-18 23:33:29 +02:00
|
|
|
> locations.json
|
|
|
|
|
2018-12-30 01:10:19 +01:00
|
|
|
function docgen {
|
2023-07-08 18:43:36 +02:00
|
|
|
name=$1
|
|
|
|
baseName=$2
|
|
|
|
description=$3
|
|
|
|
# TODO: wrap lib.$name in <literal>, make nixdoc not escape it
|
2024-07-18 23:33:29 +02:00
|
|
|
if [[ -e "lib/$baseName.nix" ]]; then
|
|
|
|
nixdoc -c "$name" -d "lib.$name: $description" -l locations.json -f "lib/$baseName.nix" > "$out/$name.md"
|
2022-12-23 20:57:49 +01:00
|
|
|
else
|
2024-07-18 23:33:29 +02:00
|
|
|
nixdoc -c "$name" -d "lib.$name: $description" -l locations.json -f "lib/$baseName/default.nix" > "$out/$name.md"
|
2022-12-23 20:57:49 +01:00
|
|
|
fi
|
2023-07-08 18:43:36 +02:00
|
|
|
echo "$out/$name.md" >> "$out/index.md"
|
2018-12-30 01:10:19 +01:00
|
|
|
}
|
|
|
|
|
2022-12-11 15:56:09 +01:00
|
|
|
mkdir -p "$out"
|
|
|
|
|
2023-03-25 21:38:26 +01:00
|
|
|
cat > "$out/index.md" << 'EOF'
|
2024-01-15 21:07:52 +01:00
|
|
|
```{=include=} sections auto-id-prefix=auto-generated
|
2022-12-11 15:56:09 +01:00
|
|
|
EOF
|
|
|
|
|
2024-07-26 19:50:26 +02:00
|
|
|
${lib.concatMapStrings (
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
baseName ? name,
|
|
|
|
description,
|
|
|
|
}:
|
|
|
|
''
|
|
|
|
docgen ${name} ${baseName} ${lib.escapeShellArg description}
|
|
|
|
''
|
|
|
|
) libsets}
|
2018-12-30 01:10:19 +01:00
|
|
|
|
2023-03-25 21:38:26 +01:00
|
|
|
echo '```' >> "$out/index.md"
|
2018-12-30 01:10:19 +01:00
|
|
|
'';
|
|
|
|
}
|