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 nixdoc -c "$1" -d "lib.$1: $2" -f "$1.nix" > "$out/$1.xml"
14 echo "<xi:include href='$1.xml' />" >> "$out/index.xml"
15 }
16
17 mkdir -p "$out"
18
19 cat > "$out/index.xml" << 'EOF'
20 <?xml version="1.0" encoding="utf-8"?>
21 <root xmlns:xi="http://www.w3.org/2001/XInclude">
22 EOF
23
24 ${lib.concatMapStrings ({ name, description }: ''
25 docgen ${name} ${lib.escapeShellArg description}
26 '') libsets}
27
28 echo "</root>" >> "$out/index.xml"
29
30 ln -s ${locationsXml} $out/locations.xml
31 '';
32}