Fix segfault setting MenuFace pixmap style for menus.
[fvwm.git] / doc / docbook-xsl / manpages / synop.xsl
blobc935d5ed59123d6a488b212d9e8f6c3966e63e02
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:exsl="http://exslt.org/common"
4 exclude-result-prefixes="exsl"
5 version='1.0'>
7 <!-- ********************************************************************
8 $Id: synop.xsl,v 1.1 2007/03/10 05:15:34 scott Exp $
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://docbook.sf.net/release/xsl/current/ for
13 copyright and other information.
15 ******************************************************************** -->
17 <xsl:variable name="arg.or.sep"> |</xsl:variable>
19 <!-- * Note: If you're looking for the *Synopsis* element, you won't -->
20 <!-- * find any code here for handling it. It's a "verbatim" -->
21 <!-- * environment; see the block.xsl file instead. -->
23 <xsl:template match="synopfragmentref">
24 <xsl:variable name="target" select="key('id',@linkend)"/>
25 <xsl:variable name="snum">
26 <xsl:apply-templates select="$target" mode="synopfragment.number"/>
27 </xsl:variable>
28 <xsl:text>(</xsl:text>
29 <xsl:value-of select="$snum"/>
30 <xsl:text>)</xsl:text>
31 <xsl:text>&#x2580;</xsl:text>
32 <xsl:variable name="synopfragmentref">
33 <FragRefContents><xsl:value-of select="normalize-space(.)"/></FragRefContents>
34 </xsl:variable>
35 <xsl:apply-templates select="exsl:node-set($synopfragmentref)" mode="italic"/>
36 </xsl:template>
38 <xsl:template match="synopfragment" mode="synopfragment.number">
39 <xsl:number format="1"/>
40 </xsl:template>
42 <xsl:template match="synopfragment">
43 <xsl:variable name="snum">
44 <xsl:apply-templates select="." mode="synopfragment.number"/>
45 </xsl:variable>
46 <xsl:text>&#10;</xsl:text>
47 <!-- * If we have a group of Synopgfragments, we only want to output a -->
48 <!-- * line of space before the first; so when we find a Synopfragment -->
49 <!-- * whose first preceding sibling is another Synopfragment, we back -->
50 <!-- * up one line vertically to negate the line of vertical space -->
51 <!-- * that's added by the .HP macro -->
52 <xsl:if test="preceding-sibling::*[1][self::synopfragment]">
53 <xsl:text>.sp -1n&#10;</xsl:text>
54 </xsl:if>
55 <xsl:text>.HP </xsl:text>
56 <!-- * For each Synopfragment, make a hanging paragraph, with the -->
57 <!-- * indent calculated from the length of the generated number -->
58 <!-- * used as a reference + pluse 3 characters (for the open and -->
59 <!-- * close parens around the number, plus a space). -->
60 <xsl:value-of select="string-length (normalize-space ($snum)) + 3"/>
61 <xsl:text>&#10;</xsl:text>
62 <xsl:text>(</xsl:text>
63 <xsl:value-of select="$snum"/>
64 <xsl:text>)</xsl:text>
65 <xsl:text> </xsl:text>
66 <xsl:apply-templates/>
67 </xsl:template>
69 <xsl:template match="group|arg" name="group-or-arg">
70 <xsl:variable name="choice" select="@choice"/>
71 <xsl:variable name="rep" select="@rep"/>
72 <xsl:variable name="sepchar">
73 <xsl:choose>
74 <xsl:when test="ancestor-or-self::*/@sepchar">
75 <xsl:value-of select="ancestor-or-self::*/@sepchar"/>
76 </xsl:when>
77 <xsl:otherwise>
78 <xsl:text> </xsl:text>
79 </xsl:otherwise>
80 </xsl:choose>
81 </xsl:variable>
82 <xsl:if test="position()>1 and
83 not(preceding-sibling::*[1][self::sbr])"
84 ><xsl:value-of select="$sepchar"/></xsl:if>
85 <xsl:choose>
86 <xsl:when test="$choice='plain'">
87 <!-- * do nothing -->
88 </xsl:when>
89 <xsl:when test="$choice='req'">
90 <xsl:value-of select="$arg.choice.req.open.str"/>
91 </xsl:when>
92 <xsl:when test="$choice='opt'">
93 <xsl:value-of select="$arg.choice.opt.open.str"/>
94 </xsl:when>
95 <xsl:otherwise>
96 <xsl:value-of select="$arg.choice.def.open.str"/>
97 </xsl:otherwise>
98 </xsl:choose>
99 <xsl:variable name="arg">
100 <xsl:apply-templates/>
101 </xsl:variable>
102 <xsl:choose>
103 <xsl:when test="local-name(.) = 'arg' and not(ancestor::arg)">
104 <!-- * Prevent arg contents from getting wrapped and broken up -->
105 <xsl:variable name="arg.wrapper">
106 <Arg><xsl:value-of select="normalize-space($arg)"/></Arg>
107 </xsl:variable>
108 <xsl:apply-templates mode="prevent.line.breaking"
109 select="exsl:node-set($arg.wrapper)"/>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:value-of select="$arg"/>
113 </xsl:otherwise>
114 </xsl:choose>
115 <xsl:choose>
116 <xsl:when test="$rep='repeat'">
117 <xsl:value-of select="$arg.rep.repeat.str"/>
118 </xsl:when>
119 <xsl:when test="$rep='norepeat'">
120 <xsl:value-of select="$arg.rep.norepeat.str"/>
121 </xsl:when>
122 <xsl:otherwise>
123 <xsl:value-of select="$arg.rep.def.str"/>
124 </xsl:otherwise>
125 </xsl:choose>
126 <xsl:choose>
127 <xsl:when test="$choice='plain'">
128 <xsl:if test='arg'>
129 <xsl:value-of select="$arg.choice.plain.close.str"/>
130 </xsl:if>
131 </xsl:when>
132 <xsl:when test="$choice='req'">
133 <xsl:value-of select="$arg.choice.req.close.str"/>
134 </xsl:when>
135 <xsl:when test="$choice='opt'">
136 <xsl:value-of select="$arg.choice.opt.close.str"/>
137 </xsl:when>
138 <xsl:otherwise>
139 <xsl:value-of select="$arg.choice.def.close.str"/>
140 </xsl:otherwise>
141 </xsl:choose>
142 </xsl:template>
144 <xsl:template match="group/arg">
145 <xsl:variable name="choice" select="@choice"/>
146 <xsl:variable name="rep" select="@rep"/>
147 <xsl:if test="position()>1"><xsl:value-of select="$arg.or.sep"/></xsl:if>
148 <xsl:call-template name="group-or-arg"/>
149 </xsl:template>
151 <xsl:template match="sbr">
152 <xsl:text>&#x2592;</xsl:text>
153 <xsl:text>.br&#x2592;</xsl:text>
154 </xsl:template>
156 <xsl:template match="cmdsynopsis">
157 <!-- * if justification is enabled by default, turn it off temporarily -->
158 <xsl:if test="$man.justify != 0">
159 <xsl:text>.ad l&#10;</xsl:text>
160 </xsl:if>
161 <!-- * if hyphenation is enabled by default, turn it off temporarily -->
162 <xsl:if test="$man.hyphenate != 0">
163 <xsl:text>.hy 0&#10;</xsl:text>
164 </xsl:if>
165 <xsl:text>.HP </xsl:text>
166 <xsl:value-of select="string-length (normalize-space (command)) + 1"/>
167 <xsl:text>&#10;</xsl:text>
168 <xsl:apply-templates/>
169 <xsl:text>&#10;</xsl:text>
170 <!-- * if justification is enabled by default, turn it back on -->
171 <xsl:if test="$man.justify != 0">
172 <xsl:text>.ad&#10;</xsl:text>
173 </xsl:if>
174 <!-- * if hyphenation is enabled by default, turn it back on -->
175 <xsl:if test="$man.hyphenate != 0">
176 <xsl:text>.hy&#10;</xsl:text>
177 </xsl:if>
178 </xsl:template>
180 <!-- ==================================================================== -->
181 <!-- * Funcsynopis hierarchy starts here -->
182 <!-- ==================================================================== -->
184 <!-- * Note: If you're looking for the *Funcsynopsisinfo* element, -->
185 <!-- * you won't find any code here for handling it. It's a "verbatim" -->
186 <!-- * environment; see the block.xsl file instead. -->
188 <!-- * Within funcsynopis output, disable hyphenation, and use -->
189 <!-- * left-aligned filling for the duration of the synopsis, so that -->
190 <!-- * line breaks only occur between separate paramdefs. -->
191 <xsl:template match="funcsynopsis">
192 <!-- * if justification is enabled by default, turn it off temporarily -->
193 <xsl:if test="$man.justify != 0">
194 <xsl:text>.ad l&#10;</xsl:text>
195 </xsl:if>
196 <!-- * if hyphenation is enabled by default, turn it off temporarily -->
197 <xsl:if test="$man.hyphenate != 0">
198 <xsl:text>.hy 0&#10;</xsl:text>
199 </xsl:if>
200 <xsl:apply-templates/>
201 <!-- * if justification is enabled by default, turn it back on -->
202 <xsl:if test="$man.justify != 0">
203 <xsl:text>.ad&#10;</xsl:text>
204 </xsl:if>
205 <!-- * if hyphenation is enabled by default, turn it back on -->
206 <xsl:if test="$man.hyphenate != 0">
207 <xsl:text>.hy&#10;</xsl:text>
208 </xsl:if>
209 </xsl:template>
211 <!-- * All Funcprototype content is by default rendered in bold, -->
212 <!-- * because the man(7) man page says this: -->
213 <!-- * -->
214 <!-- * For functions, the arguments are always specified using -->
215 <!-- * italics, even in the SYNOPSIS section, where the rest of -->
216 <!-- * the function is specified in bold -->
217 <!-- * -->
218 <!-- * Look through the contents of the man/man2 and man3 directories -->
219 <!-- * on your system, and you'll see that most existing pages do follow -->
220 <!-- * this "bold everything in function synopsis" rule. -->
221 <!-- * -->
222 <!-- * Users who don't want the bold output can choose to adjust the -->
223 <!-- * man.font.funcprototype parameter on their own. So even if you -->
224 <!-- * don't personally like the way it looks, please don't change the -->
225 <!-- * default to be non-bold - because it's a convention that's -->
226 <!-- * followed is the vast majority of existing man pages that document -->
227 <!-- * functions, and we need to follow it by default, like it or no. -->
228 <xsl:template match="funcprototype">
229 <xsl:variable name="funcprototype.string.value">
230 <xsl:value-of select="funcdef"/>
231 </xsl:variable>
232 <xsl:variable name="funcprototype">
233 <xsl:apply-templates select="funcdef"/>
234 </xsl:variable>
235 <xsl:text>.HP </xsl:text>
236 <!-- * Hang Paragraph by length of string value of <funcdef> + 1 -->
237 <!-- * (because funcdef is always followed by one open paren char) -->
238 <xsl:value-of select="string-length (normalize-space ($funcprototype.string.value)) + 1"/>
239 <xsl:text>&#10;</xsl:text>
240 <xsl:text>.</xsl:text>
241 <xsl:value-of select="$man.font.funcprototype"/>
242 <xsl:text> </xsl:text>
243 <!-- * The following quotation mark (and the one further below) are -->
244 <!-- * needed to properly delimit the parts of the Funcprototype that -->
245 <!-- * should be rendered in the prevailing font (either Bold or Roman) -->
246 <!-- * from Parameter output that needs to be alternately rendered in -->
247 <!-- * italic. -->
248 <xsl:text>"</xsl:text>
249 <xsl:value-of select="normalize-space($funcprototype)"/>
250 <xsl:text>(</xsl:text>
251 <xsl:apply-templates select="*[local-name() != 'funcdef']"/>
252 <xsl:text>"</xsl:text>
253 <xsl:text>&#10;</xsl:text>
254 </xsl:template>
256 <xsl:template match="funcdef">
257 <xsl:apply-templates mode="prevent.line.breaking"/>
258 </xsl:template>
260 <xsl:template match="funcdef/function">
261 <xsl:apply-templates/>
262 </xsl:template>
264 <xsl:template match="void">
265 <xsl:text>void);</xsl:text>
266 </xsl:template>
268 <xsl:template match="varargs">
269 <xsl:text>...);</xsl:text>
270 </xsl:template>
272 <xsl:template match="paramdef">
273 <xsl:apply-templates mode="prevent.line.breaking" select="."/>
274 <xsl:choose>
275 <xsl:when test="following-sibling::*">
276 <xsl:text>, </xsl:text>
277 </xsl:when>
278 <xsl:otherwise>
279 <xsl:text>);</xsl:text>
280 </xsl:otherwise>
281 </xsl:choose>
282 </xsl:template>
284 <xsl:template match="paramdef/parameter">
285 <!-- * We use U+2591 here in place of a normal space, because if we -->
286 <!-- * were to just use a normal space, it would get replaced with a -->
287 <!-- * non-breaking space when we run the whole Paramdef through the -->
288 <!-- * prevent.line.breaking template. And as far as why we're -->
289 <!-- * inserting the space and quotation marks around each Parameter -->
290 <!-- * to begin with, the reason is that we need to because we are -->
291 <!-- * outputting Funcsynopsis in either the "BI" or "RI" font, and -->
292 <!-- * the space and quotation marks delimit the text as the -->
293 <!-- * "alternate" or "I" text that needs to be rendered in italic. -->
294 <xsl:text>"&#x2591;"</xsl:text>
295 <xsl:apply-templates/>
296 <xsl:text>"&#x2591;"</xsl:text>
297 </xsl:template>
299 <xsl:template match="funcparams">
300 <xsl:text>(</xsl:text>
301 <xsl:apply-templates/>
302 <xsl:text>)</xsl:text>
303 </xsl:template>
305 </xsl:stylesheet>