source: trunk/Distribution/XSL/manpages/synop.xsl

Last change on this file was 2, checked in by jkacer, 18 years ago

Added all DocBook Framework stuff:

  • DocBook DTD
  • Transformation software FOP 0.20.5 and Saxon 6
  • XSL styles
  • Rexx scripts

Also added some WarpIN-related stuff for creation of WarpIN installation packages.
This state corresponds to version 1.0.0 from November 2005, just slightly modified to carry versioning information (Rexx scripts).

File size: 9.8 KB
Line 
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'>
6
7<!-- ********************************************************************
8 $Id: synop.xsl,v 1.21 2005/07/13 03:48:44 xmldoc Exp $
9 ********************************************************************
10
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.
14
15 ******************************************************************** -->
16
17<!-- * Note: If you are looking for the <synopsis> element, you won't -->
18<!-- * find any code here for handling it. It is a _verbatim_ -->
19<!-- * environment; check the block.xsl file instead. -->
20
21<xsl:template match="synopfragment">
22 <xsl:text>.PP&#10;</xsl:text>
23 <xsl:apply-templates/>
24</xsl:template>
25
26<xsl:template match="group|arg">
27 <xsl:variable name="choice" select="@choice"/>
28 <xsl:variable name="rep" select="@rep"/>
29 <xsl:variable name="sepchar">
30 <xsl:choose>
31 <xsl:when test="ancestor-or-self::*/@sepchar">
32 <xsl:value-of select="ancestor-or-self::*/@sepchar"/>
33 </xsl:when>
34 <xsl:otherwise>
35 <xsl:text> </xsl:text>
36 </xsl:otherwise>
37 </xsl:choose>
38 </xsl:variable>
39 <xsl:if test="position()>1"><xsl:value-of select="$sepchar"/></xsl:if>
40 <xsl:choose>
41 <xsl:when test="$choice='plain'">
42 <!-- * do nothing -->
43 </xsl:when>
44 <xsl:when test="$choice='req'">
45 <xsl:value-of select="$arg.choice.req.open.str"/>
46 </xsl:when>
47 <xsl:when test="$choice='opt'">
48 <xsl:value-of select="$arg.choice.opt.open.str"/>
49 </xsl:when>
50 <xsl:otherwise>
51 <xsl:value-of select="$arg.choice.def.open.str"/>
52 </xsl:otherwise>
53 </xsl:choose>
54 <xsl:variable name="arg">
55 <xsl:apply-templates/>
56 </xsl:variable>
57 <xsl:choose>
58 <xsl:when test="local-name(.) = 'arg' and not(ancestor::arg)">
59 <!-- * Prevent arg contents from getting wrapped and broken up -->
60 <xsl:variable name="arg.wrapper">
61 <Arg><xsl:value-of select="normalize-space($arg)"/></Arg>
62 </xsl:variable>
63 <xsl:apply-templates mode="prevent.line.breaking"
64 select="exsl:node-set($arg.wrapper)"/>
65 </xsl:when>
66 <xsl:otherwise>
67 <xsl:value-of select="$arg"/>
68 </xsl:otherwise>
69 </xsl:choose>
70 <xsl:choose>
71 <xsl:when test="$rep='repeat'">
72 <xsl:value-of select="$arg.rep.repeat.str"/>
73 </xsl:when>
74 <xsl:when test="$rep='norepeat'">
75 <xsl:value-of select="$arg.rep.norepeat.str"/>
76 </xsl:when>
77 <xsl:otherwise>
78 <xsl:value-of select="$arg.rep.def.str"/>
79 </xsl:otherwise>
80 </xsl:choose>
81 <xsl:choose>
82 <xsl:when test="$choice='plain'">
83 <xsl:if test='arg'>
84 <xsl:value-of select="$arg.choice.plain.close.str"/>
85 </xsl:if>
86 </xsl:when>
87 <xsl:when test="$choice='req'">
88 <xsl:value-of select="$arg.choice.req.close.str"/>
89 </xsl:when>
90 <xsl:when test="$choice='opt'">
91 <xsl:value-of select="$arg.choice.opt.close.str"/>
92 </xsl:when>
93 <xsl:otherwise>
94 <xsl:value-of select="$arg.choice.def.close.str"/>
95 </xsl:otherwise>
96 </xsl:choose>
97</xsl:template>
98
99<xsl:template match="command">
100 <xsl:call-template name="suppress.hyphenation"/>
101 <xsl:apply-templates mode="bold" select="."/>
102</xsl:template>
103
104<xsl:template match="function[not(ancestor::command)]">
105 <xsl:call-template name="suppress.hyphenation"/>
106 <xsl:apply-templates mode="bold" select="."/>
107</xsl:template>
108
109<xsl:template match="parameter[not(ancestor::command)]">
110 <xsl:call-template name="suppress.hyphenation"/>
111 <xsl:apply-templates mode="italic" select="."/>
112</xsl:template>
113
114<xsl:template match="sbr">
115 <xsl:text>&#10;</xsl:text>
116 <xsl:text>.br&#10;</xsl:text>
117</xsl:template>
118
119<xsl:template match="cmdsynopsis">
120 <!-- * if justification is enabled by default, turn it off temporarily -->
121 <xsl:if test="$man.justify != 0">
122 <xsl:text>.ad l&#10;</xsl:text>
123 </xsl:if>
124 <!-- * if hyphenation is enabled by default, turn it off temporarily -->
125 <xsl:if test="$man.hyphenate != 0">
126 <xsl:text>.hy 0&#10;</xsl:text>
127 </xsl:if>
128 <xsl:text>.HP </xsl:text>
129 <xsl:value-of select="string-length (normalize-space (command)) + 1"/>
130 <xsl:text>&#10;</xsl:text>
131 <xsl:apply-templates/>
132 <xsl:text>&#10;</xsl:text>
133 <!-- * if justification is enabled by default, turn it back on -->
134 <xsl:if test="$man.justify != 0">
135 <xsl:text>.ad&#10;</xsl:text>
136 </xsl:if>
137 <!-- * if hyphenation is enabled by default, turn it back on -->
138 <xsl:if test="$man.hyphenate != 0">
139 <xsl:text>.hy&#10;</xsl:text>
140 </xsl:if>
141</xsl:template>
142
143<!-- ==================================================================== -->
144
145<!-- * Within funcsynopis output, disable hyphenation, and use -->
146<!-- * left-aligned filling for the duration of the synopsis, so that -->
147<!-- * line breaks only occur between separate paramdefs. -->
148<xsl:template match="funcsynopsis">
149 <!-- * if justification is enabled by default, turn it off temporarily -->
150 <xsl:if test="$man.justify != 0">
151 <xsl:text>.ad l&#10;</xsl:text>
152 </xsl:if>
153 <!-- * if hyphenation is enabled by default, turn it off temporarily -->
154 <xsl:if test="$man.hyphenate != 0">
155 <xsl:text>.hy 0&#10;</xsl:text>
156 </xsl:if>
157 <xsl:apply-templates/>
158 <!-- * if justification is enabled by default, turn it back on -->
159 <xsl:if test="$man.justify != 0">
160 <xsl:text>.ad&#10;</xsl:text>
161 </xsl:if>
162 <!-- * if hyphenation is enabled by default, turn it back on -->
163 <xsl:if test="$man.hyphenate != 0">
164 <xsl:text>.hy&#10;</xsl:text>
165 </xsl:if>
166</xsl:template>
167
168<!-- * NOTE TO DEVELOPERS: Below you will find many "bold" calls. -->
169<!-- * -->
170<!-- * The reason is that we need to bold each bit of Funcsynopsis -->
171<!-- * separately, to get around the limitations of not being able -->
172<!-- * to do \fBfoo \fBbar\fI baz\fR and have "baz" get bolded. -->
173<!-- * -->
174<!-- * And the reason we need to bold so much stuff is that the -->
175<!-- * man(7) man page says this: -->
176<!-- * -->
177<!-- * For functions, the arguments are always specified using -->
178<!-- * italics, even in the SYNOPSIS section, where the rest of -->
179<!-- * the function is specified in bold: -->
180<!-- * -->
181<!-- * And if you take a look through the contents of the man/man2 -->
182<!-- * directory on your system, you'll see that most existing pages -->
183<!-- * do follow this "bold everything in function synopsis " rule. -->
184<!-- * -->
185<!-- * So even if you don't personally like the way it looks, please -->
186<!-- * don't change it to be non-bold - because it is a convention -->
187<!-- * that is followed is the vast majority of existing man pages -->
188<!-- * that document functions, and there's no good reason for us to -->
189<!-- * be following it. -->
190
191<xsl:template match="funcsynopsisinfo">
192 <xsl:text>.PP&#10;</xsl:text>
193 <xsl:apply-templates mode="bold" select="."/>
194 <xsl:text>&#10;</xsl:text>
195</xsl:template>
196
197<xsl:template match="funcprototype">
198 <xsl:variable name="funcprototype.string.value">
199 <xsl:value-of select="funcdef"/>
200 </xsl:variable>
201 <xsl:variable name="funcprototype">
202 <xsl:apply-templates select="funcdef"/>
203 </xsl:variable>
204 <xsl:text>.HP </xsl:text>
205 <!-- * Hang Paragraph by length of string value of <funcdef> + 1 -->
206 <!-- * (because funcdef is always followed by one open paren char) -->
207 <xsl:value-of select="string-length (normalize-space ($funcprototype.string.value)) + 1"/>
208 <xsl:text>&#10;</xsl:text>
209 <xsl:value-of select="normalize-space ($funcprototype)"/>
210 <xsl:variable name="funcdef.suffix">
211 <Funcdef.Suffix>(</Funcdef.Suffix>
212 </xsl:variable>
213 <xsl:apply-templates mode="bold" select="exsl:node-set($funcdef.suffix)"/>
214 <xsl:apply-templates select="*[local-name() != 'funcdef']"/>
215 <xsl:text>&#10;</xsl:text>
216</xsl:template>
217
218<xsl:template match="funcdef">
219 <xsl:variable name="funcdef">
220 <Funcdef>
221 <xsl:apply-templates select="." mode="prevent.line.breaking"/>
222 </Funcdef>
223 </xsl:variable>
224 <xsl:apply-templates mode="bold" select="exsl:node-set($funcdef)"/>
225</xsl:template>
226
227<xsl:template match="funcdef/function">
228 <xsl:apply-templates mode="bold" select="."/>
229</xsl:template>
230
231<xsl:template match="void">
232 <xsl:variable name="void">
233 <Void>void);</Void>
234 </xsl:variable>
235 <xsl:apply-templates mode="bold" select="exsl:node-set($void)"/>
236</xsl:template>
237
238<xsl:template match="varargs">
239 <xsl:variable name="varargs">
240 <Varargs>...);</Varargs>
241 </xsl:variable>
242 <xsl:apply-templates mode="bold" select="exsl:node-set($varargs)"/>
243</xsl:template>
244
245<xsl:template match="paramdef">
246 <xsl:variable name="paramdef">
247 <Paramdef>
248 <xsl:apply-templates mode="bold" select="." />
249 </Paramdef>
250 </xsl:variable>
251 <xsl:apply-templates mode="prevent.line.breaking" select="exsl:node-set($paramdef)"/>
252 <xsl:variable name="paramdef.suffix">
253 <Paramdef.Suffix>
254 <xsl:choose>
255 <xsl:when test="following-sibling::*">
256 <xsl:text>, </xsl:text>
257 </xsl:when>
258 <xsl:otherwise>
259 <xsl:text>);</xsl:text>
260 </xsl:otherwise>
261 </xsl:choose>
262 </Paramdef.Suffix>
263 </xsl:variable>
264 <xsl:apply-templates mode="bold" select="exsl:node-set($paramdef.suffix)"/>
265</xsl:template>
266
267<xsl:template match="paramdef/parameter">
268 <xsl:apply-templates mode="italic" select="."/>
269</xsl:template>
270
271<xsl:template match="funcparams">
272 <xsl:variable name="funcparams.prefix">
273 <Funcparams.Prefix>(</Funcparams.Prefix>
274 </xsl:variable>
275 <xsl:apply-templates mode="bold" select="exsl:node-set($funcparams.prefix)"/>
276 <xsl:apply-templates mode="bold" select="."/>
277 <xsl:variable name="funcparams.suffix">
278 <Funcparams.Suffix>)</Funcparams.Suffix>
279 </xsl:variable>
280 <xsl:apply-templates mode="bold" select="exsl:node-set($funcparams.suffix)"/>
281</xsl:template>
282
283</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.