1# Generates the documentation for library functions via nixdoc.
2
3{ pkgs, locationsXml, libsets }:
4
5with pkgs; stdenv.mkDerivation {
6 name = "nixpkgs-lib-docs";
7 src = ../../lib;
8
9 buildInputs = [ nixdoc ];
10 installPhase = ''
11 function docgen {
12 # TODO: wrap lib.$1 in <literal>, make nixdoc not escape it
13 if [[ -e "../lib/$1.nix" ]]; then
14 nixdoc -c "$1" -d "lib.$1: $2" -f "$1.nix" > "$out/$1.xml"
15 else
16 nixdoc -c "$1" -d "lib.$1: $2" -f "$1/default.nix" > "$out/$1.xml"
17 fi
18 echo "<xi:include href='$1.xml' />" >> "$out/index.xml"
19 }
20
21 mkdir -p "$out"
22
23 cat > "$out/index.xml" << 'EOF'
24 <?xml version="1.0" encoding="utf-8"?>
25 <root xmlns:xi="http://www.w3.org/2001/XInclude">
26 EOF
27
28 ${lib.concatMapStrings ({ name, description }: ''
29 docgen ${name} ${lib.escapeShellArg description}
30 '') libsets}
31
32 echo "</root>" >> "$out/index.xml"
33
34 ln -s ${locationsXml} $out/locations.xml
35 '';
36}