2022-12-11 14:56:09 +00:00
|
|
|
# Generates the documentation for library functions via nixdoc.
|
2018-12-30 00:10:19 +00:00
|
|
|
|
2022-12-11 14:56:09 +00:00
|
|
|
{ pkgs, locationsXml, libsets }:
|
2018-12-30 00:10:19 +00:00
|
|
|
|
|
|
|
with pkgs; stdenv.mkDerivation {
|
|
|
|
name = "nixpkgs-lib-docs";
|
2022-12-11 14:56:09 +00:00
|
|
|
src = ../../lib;
|
2018-12-30 00:10:19 +00:00
|
|
|
|
|
|
|
buildInputs = [ nixdoc ];
|
|
|
|
installPhase = ''
|
|
|
|
function docgen {
|
2022-12-12 12:17:47 +00:00
|
|
|
# TODO: wrap lib.$1 in <literal>, make nixdoc not escape it
|
2022-12-23 19:57:49 +00:00
|
|
|
if [[ -e "../lib/$1.nix" ]]; then
|
|
|
|
nixdoc -c "$1" -d "lib.$1: $2" -f "$1.nix" > "$out/$1.xml"
|
|
|
|
else
|
|
|
|
nixdoc -c "$1" -d "lib.$1: $2" -f "$1/default.nix" > "$out/$1.xml"
|
|
|
|
fi
|
2022-12-11 14:56:09 +00:00
|
|
|
echo "<xi:include href='$1.xml' />" >> "$out/index.xml"
|
2018-12-30 00:10:19 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 14:56:09 +00:00
|
|
|
mkdir -p "$out"
|
|
|
|
|
|
|
|
cat > "$out/index.xml" << 'EOF'
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<root xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
EOF
|
|
|
|
|
2022-12-12 11:21:59 +00:00
|
|
|
${lib.concatMapStrings ({ name, description }: ''
|
2022-12-11 14:56:09 +00:00
|
|
|
docgen ${name} ${lib.escapeShellArg description}
|
2022-12-12 11:21:59 +00:00
|
|
|
'') libsets}
|
2018-12-30 00:10:19 +00:00
|
|
|
|
2022-12-11 14:56:09 +00:00
|
|
|
echo "</root>" >> "$out/index.xml"
|
|
|
|
|
|
|
|
ln -s ${locationsXml} $out/locations.xml
|
2018-12-30 00:10:19 +00:00
|
|
|
'';
|
|
|
|
}
|