3 <xsl:stylesheet version=
"1.0"
4 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 xmlns:
str=
"http://exslt.org/strings"
6 xmlns:
xlink=
"http://www.w3.org/1999/xlink"
7 xmlns:
nixos=
"tag:nixos.org"
8 xmlns=
"http://docbook.org/ns/docbook"
9 extension-element-prefixes=
"str"
12 <xsl:output method='xml'
encoding=
"UTF-8" />
14 <xsl:param name=
"revision" />
15 <xsl:param name=
"documentType" />
16 <xsl:param name=
"program" />
17 <xsl:param name=
"variablelistId" />
18 <xsl:param name=
"optionIdPrefix" />
21 <xsl:template match=
"/expr/list">
23 <xsl:when test=
"$documentType = 'appendix'">
24 <appendix xml:
id=
"appendix-configuration-options">
25 <title>Configuration Options
</title>
26 <xsl:call-template name=
"variable-list"/>
30 <xsl:call-template name=
"variable-list"/>
35 <xsl:template name=
"variable-list">
37 <xsl:attribute name=
"id" namespace=
"http://www.w3.org/XML/1998/namespace"><xsl:value-of select=
"$variablelistId"/></xsl:attribute>
38 <xsl:for-each select=
"attrs">
39 <xsl:variable name=
"id" select=
"
40 concat($optionIdPrefix,
42 attr[@name = 'name']/string/@value,
47 <term xlink:
href=
"#{$id}">
48 <xsl:attribute name=
"xml:id"><xsl:value-of select=
"$id"/></xsl:attribute>
50 <xsl:value-of select=
"attr[@name = 'name']/string/@value" />
56 <nixos:option-description>
58 <xsl:value-of disable-output-escaping=
"yes"
59 select=
"attr[@name = 'description']/string/@value" />
61 </nixos:option-description>
63 <xsl:if test=
"attr[@name = 'type']">
65 <emphasis>Type:
</emphasis>
66 <xsl:text> </xsl:text>
67 <xsl:value-of select=
"attr[@name = 'type']/string/@value"/>
68 <xsl:if test=
"attr[@name = 'readOnly']/bool/@value = 'true'">
69 <xsl:text> </xsl:text>
70 <emphasis>(read only)
</emphasis>
75 <xsl:if test=
"attr[@name = 'default']">
77 <emphasis>Default:
</emphasis>
78 <xsl:text> </xsl:text>
79 <xsl:apply-templates select=
"attr[@name = 'default']/*" mode=
"top" />
83 <xsl:if test=
"attr[@name = 'example']">
85 <emphasis>Example:
</emphasis>
86 <xsl:text> </xsl:text>
87 <xsl:apply-templates select=
"attr[@name = 'example']/*" mode=
"top" />
91 <xsl:if test=
"attr[@name = 'relatedPackages']">
93 <emphasis>Related packages:
</emphasis>
94 <xsl:text> </xsl:text>
95 <xsl:value-of disable-output-escaping=
"yes"
96 select=
"attr[@name = 'relatedPackages']/string/@value" />
100 <xsl:if test=
"count(attr[@name = 'declarations']/list/*) != 0">
102 <emphasis>Declared by:
</emphasis>
104 <xsl:apply-templates select=
"attr[@name = 'declarations']" />
107 <xsl:if test=
"count(attr[@name = 'definitions']/list/*) != 0">
109 <emphasis>Defined by:
</emphasis>
111 <xsl:apply-templates select=
"attr[@name = 'definitions']" />
124 <xsl:template match=
"attrs[attr[@name = '_type' and string[@value = 'literalExpression']]]" mode =
"top">
126 <xsl:when test=
"contains(attr[@name = 'text']/string/@value, '
')">
127 <programlisting><xsl:value-of select=
"attr[@name = 'text']/string/@value" /></programlisting>
130 <literal><xsl:value-of select=
"attr[@name = 'text']/string/@value" /></literal>
136 <xsl:template match=
"attrs[attr[@name = '_type' and string[@value = 'literalDocBook']]]" mode =
"top">
137 <xsl:value-of disable-output-escaping=
"yes" select=
"attr[@name = 'text']/string/@value" />
141 <xsl:template match=
"string[contains(@value, '
')]" mode=
"top">
143 <xsl:text>''

</xsl:text>
144 <xsl:value-of select='str:replace(str:replace(@value,
"''",
"'''"),
"${",
"''${")'
/>
145 <xsl:text>''
</xsl:text>
150 <xsl:template match=
"*" mode=
"top">
151 <literal><xsl:apply-templates select=
"." /></literal>
155 <xsl:template match=
"null">
156 <xsl:text>null
</xsl:text>
160 <xsl:template match=
"string">
162 <xsl:when test=
"(contains(@value, '"') or contains(@value, '\')) and not(contains(@value, '
'))">
163 <xsl:text>''
</xsl:text><xsl:value-of select='str:replace(str:replace(@value,
"''",
"'''"),
"${",
"''${")'
/><xsl:text>''
</xsl:text>
166 <xsl:text>"</xsl:text><xsl:value-of select="str:replace(str:replace(str:replace(str:replace(@value, '\', '\\'), '
"', '\
"'), '

', '\n'), '${', '\${')
" /><xsl:text>"</xsl:text>
172 <xsl:template match=
"int">
173 <xsl:value-of select=
"@value" />
177 <xsl:template match=
"bool[@value = 'true']">
178 <xsl:text>true
</xsl:text>
182 <xsl:template match=
"bool[@value = 'false']">
183 <xsl:text>false
</xsl:text>
187 <xsl:template match=
"list">
189 <xsl:for-each select=
"*">
190 <xsl:apply-templates select=
"." />
191 <xsl:text> </xsl:text>
197 <xsl:template match=
"attrs[attr[@name = '_type' and string[@value = 'literalExpression']]]">
198 <xsl:value-of select=
"attr[@name = 'text']/string/@value" />
202 <xsl:template match=
"attrs">
204 <xsl:for-each select=
"attr">
205 <xsl:value-of select=
"@name" />
206 <xsl:text> =
</xsl:text>
207 <xsl:apply-templates select=
"*" /><xsl:text>;
</xsl:text>
213 <xsl:template match=
"attrs[attr[@name = '_type' and string[@value = 'derivation']]]">
214 <replaceable>(build of
<xsl:value-of select=
"attr[@name = 'name']/string/@value" />)
</replaceable>
217 <xsl:template match=
"attr[@name = 'declarations' or @name = 'definitions']">
221 opt.declarations = [ { name = "foo/bar.nix"; url = "https://github.com/....."; } ];
223 <xsl:for-each select=
"list/attrs[attr[@name = 'name']]">
225 <xsl:if test=
"attr[@name = 'url']">
226 <xsl:attribute name=
"xlink:href"><xsl:value-of select=
"attr[@name = 'url']/string/@value"/></xsl:attribute>
228 <xsl:value-of select=
"attr[@name = 'name']/string/@value"/>
233 When the declarations/definitions are raw strings,
234 fall back to hardcoded location logic, specific to Nixpkgs.
236 <xsl:for-each select=
"list/string">
238 <!-- Hyperlink the filename either to the NixOS Subversion
239 repository (if it’s a module and we have a revision number),
240 or to the local filesystem. -->
242 <xsl:when test=
"not(starts-with(@value, '/'))">
244 <xsl:when test=
"$revision = 'local'">
245 <xsl:attribute name=
"xlink:href">https://github.com/NixOS/nixpkgs/blob/master/
<xsl:value-of select=
"@value"/></xsl:attribute>
248 <xsl:attribute name=
"xlink:href">https://github.com/NixOS/nixpkgs/blob/
<xsl:value-of select=
"$revision"/>/
<xsl:value-of select=
"@value"/></xsl:attribute>
252 <xsl:when test=
"$revision != 'local' and $program = 'nixops' and contains(@value, '/nix/')">
253 <xsl:attribute name=
"xlink:href">https://github.com/NixOS/nixops/blob/
<xsl:value-of select=
"$revision"/>/nix/
<xsl:value-of select=
"substring-after(@value, '/nix/')"/></xsl:attribute>
256 <xsl:attribute name=
"xlink:href">file://
<xsl:value-of select=
"@value"/></xsl:attribute>
259 <!-- Print the filename and make it user-friendly by replacing the
260 /nix/store/<hash> prefix by the default location of nixos
263 <xsl:when test=
"not(starts-with(@value, '/'))">
264 <nixpkgs/
<xsl:value-of select=
"@value"/>>
266 <xsl:when test=
"contains(@value, 'nixops') and contains(@value, '/nix/')">
267 <nixops/
<xsl:value-of select=
"substring-after(@value, '/nix/')"/>>
270 <xsl:value-of select=
"@value" />
279 <xsl:template match=
"function">
280 <xsl:text>λ
</xsl:text>