blob: 3c0d2bfb739eef14b052aae1cb3fda0200e4dd52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:ng="http://docbook.org/docbook-ng"
xmlns:db="http://docbook.org/ns/docbook"
exclude-result-prefixes="exsl"
version='1.0'>
<xsl:output method="text"
encoding="UTF-8"
indent="no"/>
<xsl:strip-space elements="arg"/>
<xsl:template match="/">
<!-- Pull out cmdsynopsis to show the command usage line. -->Usage:
<xsl:value-of select="refentry/refsynopsisdiv/cmdsynopsis/command"/>
<xsl:text> </xsl:text>
<xsl:for-each select="refentry/refsynopsisdiv/cmdsynopsis/arg">
<xsl:if test="@choice='opt'">[</xsl:if>
<xsl:apply-templates select="." />
<xsl:if test="@choice='opt'">]</xsl:if>
<xsl:text> </xsl:text>
</xsl:for-each>
<xsl:text> </xsl:text>
<!-- List options (any variable list in a section called "Options"). -->
<xsl:for-each select=".//*[title='Options']/variablelist">
<xsl:if test="position() = 1"> Options: </xsl:if>
<xsl:for-each select="varlistentry">
<xsl:text> </xsl:text>
<xsl:for-each select=".//term">
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">, </xsl:if>
</xsl:for-each><xsl:text> </xsl:text>
</xsl:for-each>
</xsl:for-each>
<!-- Any paragraphs which have been marked as role="usage" (principally for global flags). -->
<xsl:text> </xsl:text>
<xsl:for-each select="//para[@role='usage']">
<xsl:value-of select="normalize-space(.)"/><xsl:text> </xsl:text>
</xsl:for-each>
<!-- List commands (any first-level variable list in a section called "Commands"). -->
<xsl:for-each select=".//*[title='Commands']/variablelist | .//*[title='Commands']/refsect2/variablelist">
<xsl:if test="position() = 1">Commands: </xsl:if>
<xsl:for-each select="varlistentry">
<xsl:text> </xsl:text>
<xsl:apply-templates select="term"/>
<xsl:text> </xsl:text>
</xsl:for-each>
<xsl:text> </xsl:text>
</xsl:for-each>
<!-- Any second-level variable lists (for options for subcommands). -->
<xsl:for-each select=".//*[title='Commands']//varlistentry[@role='usage-has-option-list']">
<<xsl:value-of select="term/option[@role='usage-option-list']/replaceable"/>> must be a member of the list [<xsl:for-each select="listitem/variablelist/varlistentry"><xsl:apply-templates select="term"/><xsl:if test="not(position() = last())">, </xsl:if></xsl:for-each>].
</xsl:for-each>
</xsl:template>
<xsl:template match="option">[<xsl:apply-templates/>]</xsl:template>
<xsl:template match="replaceable"><<xsl:value-of select="normalize-space(.)"/>></xsl:template>
</xsl:stylesheet>
|