diff options
Diffstat (limited to 'nixpkgs/nixos/lib/make-options-doc/options-to-docbook.xsl')
-rw-r--r-- | nixpkgs/nixos/lib/make-options-doc/options-to-docbook.xsl | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/nixpkgs/nixos/lib/make-options-doc/options-to-docbook.xsl b/nixpkgs/nixos/lib/make-options-doc/options-to-docbook.xsl index 18d19fddaca2..da4cd164bf20 100644 --- a/nixpkgs/nixos/lib/make-options-doc/options-to-docbook.xsl +++ b/nixpkgs/nixos/lib/make-options-doc/options-to-docbook.xsl @@ -54,7 +54,7 @@ <para> <emphasis>Default:</emphasis> <xsl:text> </xsl:text> - <xsl:apply-templates select="attr[@name = 'default']" mode="top" /> + <xsl:apply-templates select="attr[@name = 'default']/*" mode="top" /> </para> </xsl:if> @@ -62,14 +62,7 @@ <para> <emphasis>Example:</emphasis> <xsl:text> </xsl:text> - <xsl:choose> - <xsl:when test="attr[@name = 'example']/attrs[attr[@name = '_type' and string[@value = 'literalExample']]]"> - <programlisting><xsl:value-of select="attr[@name = 'example']/attrs/attr[@name = 'text']/string/@value" /></programlisting> - </xsl:when> - <xsl:otherwise> - <xsl:apply-templates select="attr[@name = 'example']" mode="top" /> - </xsl:otherwise> - </xsl:choose> + <xsl:apply-templates select="attr[@name = 'example']/*" mode="top" /> </para> </xsl:if> @@ -107,20 +100,37 @@ </xsl:template> - <xsl:template match="*" mode="top"> + <xsl:template match="attrs[attr[@name = '_type' and string[@value = 'literalExpression']]]" mode = "top"> <xsl:choose> - <xsl:when test="string[contains(@value, '
')]"> -<programlisting> -<xsl:text>'' -</xsl:text><xsl:value-of select='str:replace(string/@value, "${", "''${")' /><xsl:text>''</xsl:text></programlisting> + <xsl:when test="contains(attr[@name = 'text']/string/@value, '
')"> + <programlisting><xsl:value-of select="attr[@name = 'text']/string/@value" /></programlisting> </xsl:when> <xsl:otherwise> - <literal><xsl:apply-templates /></literal> + <literal><xsl:value-of select="attr[@name = 'text']/string/@value" /></literal> </xsl:otherwise> </xsl:choose> </xsl:template> + <xsl:template match="attrs[attr[@name = '_type' and string[@value = 'literalDocBook']]]" mode = "top"> + <xsl:value-of disable-output-escaping="yes" select="attr[@name = 'text']/string/@value" /> + </xsl:template> + + + <xsl:template match="string[contains(@value, '
')]" mode="top"> + <programlisting> + <xsl:text>''
</xsl:text> + <xsl:value-of select='str:replace(str:replace(@value, "''", "'''"), "${", "''${")' /> + <xsl:text>''</xsl:text> + </programlisting> + </xsl:template> + + + <xsl:template match="*" mode="top"> + <literal><xsl:apply-templates select="." /></literal> + </xsl:template> + + <xsl:template match="null"> <xsl:text>null</xsl:text> </xsl:template> @@ -129,10 +139,10 @@ <xsl:template match="string"> <xsl:choose> <xsl:when test="(contains(@value, '"') or contains(@value, '\')) and not(contains(@value, '
'))"> - <xsl:text>''</xsl:text><xsl:value-of select='str:replace(@value, "${", "''${")' /><xsl:text>''</xsl:text> + <xsl:text>''</xsl:text><xsl:value-of select='str:replace(str:replace(@value, "''", "'''"), "${", "''${")' /><xsl:text>''</xsl:text> </xsl:when> <xsl:otherwise> - <xsl:text>"</xsl:text><xsl:value-of select="str:replace(str:replace(str:replace(str:replace(@value, '\', '\\'), '"', '\"'), '
', '\n'), '$', '\$')" /><xsl:text>"</xsl:text> + <xsl:text>"</xsl:text><xsl:value-of select="str:replace(str:replace(str:replace(str:replace(@value, '\', '\\'), '"', '\"'), '
', '\n'), '${', '\${')" /><xsl:text>"</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> @@ -163,7 +173,7 @@ </xsl:template> - <xsl:template match="attrs[attr[@name = '_type' and string[@value = 'literalExample']]]"> + <xsl:template match="attrs[attr[@name = '_type' and string[@value = 'literalExpression']]]"> <xsl:value-of select="attr[@name = 'text']/string/@value" /> </xsl:template> |