nixos/lib/make-options-doc: implement literalDocBook
This commit is contained in:
parent
52a2e4136e
commit
330b1e08b8
@ -54,7 +54,7 @@
|
|||||||
<para>
|
<para>
|
||||||
<emphasis>Default:</emphasis>
|
<emphasis>Default:</emphasis>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="attr[@name = 'default']" mode="top" />
|
<xsl:apply-templates select="attr[@name = 'default']/*" mode="top" />
|
||||||
</para>
|
</para>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
|
||||||
@ -62,14 +62,7 @@
|
|||||||
<para>
|
<para>
|
||||||
<emphasis>Example:</emphasis>
|
<emphasis>Example:</emphasis>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:choose>
|
<xsl:apply-templates select="attr[@name = 'example']/*" mode="top" />
|
||||||
<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>
|
|
||||||
</para>
|
</para>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
|
||||||
@ -107,20 +100,37 @@
|
|||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
<xsl:template match="*" mode="top">
|
<xsl:template match="attrs[attr[@name = '_type' and string[@value = 'literalExpression']]]" mode = "top">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="string[contains(@value, '
')]">
|
<xsl:when test="contains(attr[@name = 'text']/string/@value, '
')">
|
||||||
<programlisting>
|
<programlisting><xsl:value-of select="attr[@name = 'text']/string/@value" /></programlisting>
|
||||||
<xsl:text>''
|
|
||||||
</xsl:text><xsl:value-of select='str:replace(string/@value, "${", "''${")' /><xsl:text>''</xsl:text></programlisting>
|
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<literal><xsl:apply-templates /></literal>
|
<literal><xsl:value-of select="attr[@name = 'text']/string/@value" /></literal>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:template>
|
</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:template match="null">
|
||||||
<xsl:text>null</xsl:text>
|
<xsl:text>null</xsl:text>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
@ -129,10 +139,10 @@
|
|||||||
<xsl:template match="string">
|
<xsl:template match="string">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="(contains(@value, '"') or contains(@value, '\')) and not(contains(@value, '
'))">
|
<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:when>
|
||||||
<xsl:otherwise>
|
<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:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
@ -163,7 +173,7 @@
|
|||||||
</xsl:template>
|
</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:value-of select="attr[@name = 'text']/string/@value" />
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user