]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <!-- | |
3 | Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com> | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. | |
6 | (See accompanying file LICENSE_1_0.txt or copy at | |
7 | http://www.boost.org/LICENSE_1_0.txt) | |
8 | --> | |
9 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
10 | xmlns:xi="http://www.w3.org/2001/XInclude" | |
11 | version="1.0"> | |
b32b8144 | 12 | <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/common/common.xsl"/> |
7c673cae FG |
13 | <xsl:include href="reference.xsl"/> |
14 | ||
15 | <xsl:output method="xml" | |
16 | doctype-public="-//OASIS//DTD DocBook XML V4.2//EN" | |
17 | doctype-system="http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"/> | |
18 | ||
b32b8144 FG |
19 | <!-- Generate consistent id values if document is unchanged --> |
20 | <xsl:param name="generate.consistent.ids" select="0"/> | |
21 | ||
7c673cae FG |
22 | <!-- The maximum number of columns allowed in preformatted text --> |
23 | <xsl:param name="max-columns" select="78"/> | |
24 | ||
25 | <!-- The root of the Boost directory --> | |
26 | <xsl:param name="boost.root" select="'../..'"/> | |
27 | ||
28 | <!-- A space-separated list of libraries to include in the | |
29 | output. If this list is empty, all libraries will be included. --> | |
30 | <xsl:param name="boost.include.libraries" select="''"/> | |
31 | ||
32 | <!-- Whether to rewrite relative URL's to point to the website --> | |
33 | <xsl:param name="boost.url.prefix"/> | |
34 | ||
35 | <!-- A space-separated list of xml elements in the input file for which | |
36 | whitespace should be preserved --> | |
37 | <xsl:preserve-space elements="*"/> | |
38 | ||
39 | <!-- The root for boost headers --> | |
40 | <xsl:param name="boost.header.root"> | |
41 | <xsl:if test="$boost.url.prefix"> | |
42 | <xsl:value-of select="$boost.url.prefix"/> | |
43 | <xsl:text>/</xsl:text> | |
44 | </xsl:if> | |
45 | <xsl:value-of select="$boost.root"/> | |
46 | </xsl:param> | |
47 | ||
48 | <!-- The prefix for 'boost:' links. --> | |
49 | <xsl:variable name="boost.protocol.text"> | |
50 | <xsl:if test="($boost.url.prefix != '') and (contains($boost.root, '://') = 0)"> | |
51 | <xsl:value-of select="concat($boost.url.prefix, '/', $boost.root)"/> | |
52 | </xsl:if> | |
53 | <xsl:if test="($boost.url.prefix = '') or contains($boost.root, '://')"> | |
54 | <xsl:value-of select="$boost.root"/> | |
55 | </xsl:if> | |
56 | </xsl:variable> | |
57 | ||
58 | <xsl:template match="library-reference"> | |
59 | <xsl:choose> | |
60 | <xsl:when test="ancestor::library-reference"> | |
61 | <xsl:apply-templates/> | |
62 | </xsl:when> | |
63 | <xsl:otherwise> | |
64 | <section> | |
65 | <xsl:choose> | |
66 | <xsl:when test="@id"> | |
67 | <xsl:attribute name="id"> | |
68 | <xsl:value-of select="@id"/> | |
69 | </xsl:attribute> | |
70 | </xsl:when> | |
71 | <xsl:when test="ancestor::library/attribute::id"> | |
72 | <xsl:attribute name="id"> | |
73 | <xsl:value-of select="ancestor::library/attribute::id"/> | |
74 | <xsl:text>.reference</xsl:text> | |
75 | </xsl:attribute> | |
76 | </xsl:when> | |
77 | </xsl:choose> | |
78 | <xsl:if test="not(title)"> | |
79 | <title> | |
80 | <xsl:text>Reference</xsl:text> | |
81 | </title> | |
82 | </xsl:if> | |
83 | ||
84 | <xsl:if test="concept"> | |
85 | <section> | |
86 | <xsl:choose> | |
87 | <xsl:when test="@id"> | |
88 | <xsl:attribute name="id"> | |
89 | <xsl:value-of select="@id"/> | |
90 | <xsl:text>.concepts</xsl:text> | |
91 | </xsl:attribute> | |
92 | </xsl:when> | |
93 | <xsl:when test="ancestor::library/attribute::id"> | |
94 | <xsl:attribute name="id"> | |
95 | <xsl:value-of select="ancestor::library/attribute::id"/> | |
96 | <xsl:text>.concepts</xsl:text> | |
97 | </xsl:attribute> | |
98 | </xsl:when> | |
99 | </xsl:choose> | |
100 | ||
101 | <title>Concepts</title> | |
102 | ||
103 | <itemizedlist> | |
104 | <xsl:for-each select="concept"> | |
105 | <listitem><simpara> | |
106 | <xsl:call-template name="internal-link"> | |
107 | <xsl:with-param name="to"> | |
108 | <xsl:call-template name="generate.id"/> | |
109 | </xsl:with-param> | |
110 | <xsl:with-param name="text" select="@name"/> | |
111 | </xsl:call-template> | |
112 | </simpara></listitem> | |
113 | </xsl:for-each> | |
114 | </itemizedlist> | |
115 | </section> | |
116 | </xsl:if> | |
117 | ||
118 | <xsl:apply-templates/> | |
119 | </section> | |
120 | </xsl:otherwise> | |
121 | </xsl:choose> | |
122 | </xsl:template> | |
123 | ||
124 | <xsl:template match="header"> | |
125 | <xsl:if test="*"> | |
126 | <section> | |
127 | <xsl:attribute name="id"> | |
128 | <xsl:call-template name="generate.id"/> | |
129 | </xsl:attribute> | |
130 | ||
131 | <title> | |
132 | <xsl:text>Header <</xsl:text> | |
133 | <ulink> | |
134 | <xsl:attribute name="url"> | |
135 | <xsl:value-of select="$boost.header.root"/> | |
136 | <xsl:text>/</xsl:text> | |
137 | <xsl:value-of select="@name"/> | |
138 | </xsl:attribute> | |
139 | <xsl:value-of select="@name"/> | |
140 | </ulink> | |
141 | <xsl:text>></xsl:text> | |
142 | </title> | |
143 | ||
144 | <xsl:apply-templates select="para|section" mode="annotation"/> | |
145 | ||
146 | <xsl:if test="macro"> | |
147 | <xsl:call-template name="synopsis"> | |
148 | <xsl:with-param name="text"> | |
149 | <xsl:apply-templates mode="synopsis" select="macro"> | |
150 | <xsl:with-param name="indentation" select="0"/> | |
151 | </xsl:apply-templates> | |
152 | </xsl:with-param> | |
153 | </xsl:call-template> | |
154 | </xsl:if> | |
155 | ||
156 | <xsl:if test="descendant::class|descendant::struct|descendant::union | |
157 | |descendant::function|descendant::free-function-group | |
158 | |descendant::overloaded-function|descendant::enum | |
159 | |descendant::typedef"> | |
160 | <xsl:call-template name="synopsis"> | |
161 | <xsl:with-param name="text"> | |
162 | <xsl:apply-templates mode="synopsis" | |
163 | select="namespace|class|struct|union | |
164 | |function|free-function-group | |
165 | |overloaded-function|enum | |
166 | |typedef"> | |
167 | <xsl:with-param name="indentation" select="0"/> | |
168 | </xsl:apply-templates> | |
169 | </xsl:with-param> | |
170 | </xsl:call-template> | |
171 | </xsl:if> | |
172 | ||
173 | <xsl:apply-templates mode="namespace-reference"/> | |
174 | </section> | |
175 | </xsl:if> | |
176 | </xsl:template> | |
177 | ||
178 | <xsl:template match="header" mode="generate.id"> | |
179 | <xsl:text>header.</xsl:text> | |
180 | <xsl:value-of select="translate(@name, '/.', '._')"/> | |
181 | </xsl:template> | |
182 | ||
183 | <xsl:template match="*" mode="passthrough"> | |
184 | <xsl:copy-of select="."/> | |
185 | </xsl:template> | |
186 | ||
187 | <xsl:template name="monospaced"> | |
188 | <xsl:param name="text"/> | |
189 | <computeroutput><xsl:value-of select="$text"/></computeroutput> | |
190 | </xsl:template> | |
191 | ||
192 | <!-- Linking --> | |
193 | <xsl:template match="ulink"> | |
194 | <xsl:copy> | |
195 | <xsl:copy-of select="@*"/> | |
196 | <xsl:attribute name="url"> | |
197 | <xsl:choose> | |
198 | <xsl:when test="starts-with(@url, 'boost:/')"> | |
199 | <xsl:value-of select="concat($boost.protocol.text, substring-after(@url, 'boost:'))"/> | |
200 | </xsl:when> | |
201 | <xsl:when test="starts-with(@url, 'boost:')"> | |
202 | <xsl:value-of select="concat($boost.protocol.text, '/', substring-after(@url, 'boost:'))"/> | |
203 | </xsl:when> | |
204 | <xsl:when test="$boost.url.prefix != '' and not(contains(@url, ':') or starts-with(@url, '//'))"> | |
205 | <xsl:value-of select="concat($boost.url.prefix, '/', @url)"/> | |
206 | </xsl:when> | |
207 | <xsl:otherwise> | |
208 | <xsl:value-of select="@url"/> | |
209 | </xsl:otherwise> | |
210 | </xsl:choose> | |
211 | </xsl:attribute> | |
212 | <xsl:apply-templates/> | |
213 | </xsl:copy> | |
214 | </xsl:template> | |
215 | <xsl:template name="internal-link"> | |
216 | <xsl:param name="to"/> | |
217 | <xsl:param name="text"/> | |
218 | <xsl:param name="highlight" select="false()"/> | |
219 | ||
220 | <link linkend="{$to}"> | |
221 | <xsl:if test="$highlight"> | |
222 | <xsl:call-template name="source-highlight"> | |
223 | <xsl:with-param name="text" select="$text"/> | |
224 | </xsl:call-template> | |
225 | </xsl:if> | |
226 | <xsl:if test="not($highlight)"> | |
227 | <xsl:value-of select="string($text)"/> | |
228 | </xsl:if> | |
229 | </link> | |
230 | </xsl:template> | |
231 | ||
232 | <xsl:template name="anchor"> | |
233 | <xsl:param name="to"/> | |
234 | <xsl:param name="text"/> | |
235 | <xsl:param name="highlight" select="false()"/> | |
236 | ||
237 | <anchor id="{$to}"/> | |
238 | <xsl:if test="$highlight"> | |
239 | <xsl:call-template name="source-highlight"> | |
240 | <xsl:with-param name="text" select="$text"/> | |
241 | </xsl:call-template> | |
242 | </xsl:if> | |
243 | <xsl:if test="not($highlight)"> | |
244 | <xsl:value-of select="$text"/> | |
245 | </xsl:if> | |
246 | </xsl:template> | |
247 | ||
248 | <xsl:template name="link-or-anchor"> | |
249 | <xsl:param name="to"/> | |
250 | <xsl:param name="text"/> | |
251 | ||
252 | <!-- True if we should create an anchor, otherwise we will create | |
253 | a link. If you require more control (e.g., with the possibility of | |
254 | having no link or anchor), set link-type instead: if present, it | |
255 | takes precedence. --> | |
256 | <xsl:param name="is-anchor"/> | |
257 | ||
258 | <!-- 'anchor', 'link', or 'none' --> | |
259 | <xsl:param name="link-type"> | |
260 | <xsl:choose> | |
261 | <xsl:when test="$is-anchor"> | |
262 | <xsl:text>anchor</xsl:text> | |
263 | </xsl:when> | |
264 | <xsl:otherwise> | |
265 | <xsl:text>link</xsl:text> | |
266 | </xsl:otherwise> | |
267 | </xsl:choose> | |
268 | </xsl:param> | |
269 | ||
270 | <xsl:param name="highlight" select="false()"/> | |
271 | ||
272 | <xsl:choose> | |
273 | <xsl:when test="$link-type='anchor'"> | |
274 | <xsl:call-template name="anchor"> | |
275 | <xsl:with-param name="to" select="$to"/> | |
276 | <xsl:with-param name="text" select="$text"/> | |
277 | <xsl:with-param name="highlight" select="$highlight"/> | |
278 | </xsl:call-template> | |
279 | </xsl:when> | |
280 | <xsl:when test="$link-type='link'"> | |
281 | <xsl:call-template name="internal-link"> | |
282 | <xsl:with-param name="to" select="$to"/> | |
283 | <xsl:with-param name="text" select="$text"/> | |
284 | <xsl:with-param name="highlight" select="$highlight"/> | |
285 | </xsl:call-template> | |
286 | </xsl:when> | |
287 | <xsl:when test="$link-type='none'"> | |
288 | <xsl:if test="$highlight"> | |
289 | <xsl:call-template name="source-highlight"> | |
290 | <xsl:with-param name="text" select="$text"/> | |
291 | </xsl:call-template> | |
292 | </xsl:if> | |
293 | <xsl:if test="not($highlight)"> | |
294 | <xsl:value-of select="$text"/> | |
295 | </xsl:if> | |
296 | </xsl:when> | |
297 | <xsl:otherwise> | |
298 | <xsl:message> | |
299 | Error: XSL template 'link-or-anchor' called with invalid link-type '<xsl:value-of select="$link-type"/>' | |
300 | </xsl:message> | |
301 | </xsl:otherwise> | |
302 | </xsl:choose> | |
303 | </xsl:template> | |
304 | ||
305 | <xsl:template name="separator"/> | |
306 | ||
307 | <xsl:template name="reference-documentation"> | |
308 | <xsl:param name="name"/> | |
309 | <xsl:param name="refname"/> | |
310 | <xsl:param name="purpose"/> | |
311 | <xsl:param name="anchor"/> | |
312 | <xsl:param name="synopsis"/> | |
313 | <xsl:param name="text"/> | |
314 | ||
315 | <refentry id="{$anchor}"> | |
316 | <refmeta> | |
317 | <refentrytitle><xsl:value-of select="$name"/></refentrytitle> | |
318 | <manvolnum>3</manvolnum> | |
319 | </refmeta> | |
320 | <refnamediv> | |
321 | <refname><xsl:value-of select="$refname"/></refname> | |
322 | <refpurpose> | |
323 | <xsl:apply-templates mode="purpose" select="$purpose"/> | |
324 | </refpurpose> | |
325 | </refnamediv> | |
326 | <refsynopsisdiv> | |
327 | <synopsis> | |
328 | <xsl:copy-of select="$synopsis"/> | |
329 | </synopsis> | |
330 | </refsynopsisdiv> | |
331 | <xsl:if test="not(string($text)='')"> | |
332 | <refsect1> | |
333 | <title>Description</title> | |
334 | <xsl:copy-of select="$text"/> | |
335 | </refsect1> | |
336 | </xsl:if> | |
337 | </refentry> | |
338 | </xsl:template> | |
339 | ||
340 | <xsl:template name="member-documentation"> | |
341 | <xsl:param name="name"/> | |
342 | <xsl:param name="text"/> | |
343 | ||
344 | <refsect2> | |
345 | <title><xsl:copy-of select="$name"/></title> | |
346 | <xsl:copy-of select="$text"/> | |
347 | </refsect2> | |
348 | </xsl:template> | |
349 | ||
350 | <xsl:template name="preformatted"> | |
351 | <xsl:param name="text"/> | |
352 | ||
353 | <literallayout class="monospaced"> | |
354 | <xsl:copy-of select="$text"/> | |
355 | </literallayout> | |
356 | </xsl:template> | |
357 | ||
358 | <xsl:template name="synopsis"> | |
359 | <xsl:param name="text"/> | |
360 | ||
361 | <synopsis> | |
362 | <xsl:copy-of select="$text"/> | |
363 | </synopsis> | |
364 | </xsl:template> | |
365 | ||
366 | <!-- Fallthrough for DocBook elements --> | |
367 | <xsl:template match="*"> | |
368 | <xsl:element name="{name(.)}"> | |
369 | <xsl:for-each select="./@*"> | |
370 | <xsl:choose> | |
371 | <xsl:when test="local-name(.)='last-revision'"> | |
372 | <xsl:attribute | |
373 | name="rev:last-revision" | |
374 | namespace="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"> | |
375 | <xsl:value-of select="."/> | |
376 | </xsl:attribute> | |
377 | </xsl:when> | |
378 | <xsl:otherwise> | |
379 | <xsl:attribute name="{name(.)}"> | |
380 | <xsl:value-of select="."/> | |
381 | </xsl:attribute> | |
382 | </xsl:otherwise> | |
383 | </xsl:choose> | |
384 | </xsl:for-each> | |
385 | <xsl:apply-templates/> | |
386 | </xsl:element> | |
387 | </xsl:template> | |
388 | ||
389 | <xsl:template match="processing-instruction()"> | |
390 | <xsl:copy/> | |
391 | </xsl:template> | |
392 | ||
393 | <xsl:template match="code"> | |
394 | <computeroutput> | |
395 | <xsl:apply-templates mode="annotation"/> | |
396 | </computeroutput> | |
397 | </xsl:template> | |
398 | ||
399 | <xsl:template match="code[@language='jam']"> | |
400 | <computeroutput> | |
401 | <xsl:apply-templates mode="highlight-jam"/> | |
402 | </computeroutput> | |
403 | </xsl:template> | |
404 | ||
405 | <xsl:template match="code[@language='c++']"> | |
406 | <xsl:apply-templates select="." mode="annotation"/> | |
407 | </xsl:template> | |
408 | ||
409 | <xsl:template match="bold"> | |
410 | <emphasis role="bold"> | |
411 | <xsl:apply-templates mode="annotation"/> | |
412 | </emphasis> | |
413 | </xsl:template> | |
414 | ||
415 | <xsl:template match="library"> | |
416 | <xsl:if test="not(@html-only = 1) and | |
417 | ($boost.include.libraries='' or | |
418 | contains($boost.include.libraries, @id))"> | |
419 | <chapter> | |
420 | <xsl:copy-of select="@*[not(contains(' last-revision name dirname html-only url ', concat(' ',local-name(),' ')))]"/> | |
421 | <xsl:if test="not(@id)"> | |
422 | <xsl:attribute name="id"> | |
423 | <xsl:call-template name="generate.id"/> | |
424 | </xsl:attribute> | |
425 | </xsl:if> | |
426 | ||
427 | <xsl:if test="@last-revision"> | |
428 | <xsl:attribute | |
429 | name="rev:last-revision" | |
430 | namespace="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"> | |
431 | <xsl:value-of select="@last-revision"/> | |
432 | </xsl:attribute> | |
433 | </xsl:if> | |
434 | <xsl:apply-templates/> | |
435 | </chapter> | |
436 | </xsl:if> | |
437 | </xsl:template> | |
438 | ||
439 | <xsl:template match="chapter"> | |
440 | <xsl:if test="$boost.include.libraries=''"> | |
441 | <chapter> | |
442 | <xsl:copy-of select="./@*" /> | |
443 | <xsl:apply-templates/> | |
444 | </chapter> | |
445 | </xsl:if> | |
446 | </xsl:template> | |
447 | ||
448 | <xsl:template match="boostbook"> | |
449 | <book> | |
450 | <xsl:copy-of select="@*[not(contains(' last-revision name dirname html-only url ', concat(' ',local-name(),' ')))]"/> | |
451 | <xsl:apply-templates/> | |
452 | </book> | |
453 | </xsl:template> | |
454 | ||
455 | <xsl:template match="programlisting"> | |
456 | <programlisting><xsl:apply-templates/></programlisting> | |
457 | </xsl:template> | |
458 | ||
459 | <xsl:template match="programlisting[@language='jam']"> | |
460 | <programlisting> | |
461 | <xsl:apply-templates mode="highlight-jam"/> | |
462 | </programlisting> | |
463 | </xsl:template> | |
464 | ||
465 | <xsl:template match="programlisting[@language='c++']"> | |
466 | <xsl:apply-templates select="." mode="annotation"/> | |
467 | </xsl:template> | |
468 | ||
469 | <!-- These DocBook elements have special meaning. Use the annotation mode --> | |
470 | <xsl:template match="classname|methodname|functionname|enumname| | |
471 | macroname|headername|globalname"> | |
472 | <computeroutput> | |
473 | <xsl:apply-templates select="." mode="annotation"/> | |
474 | </computeroutput> | |
475 | </xsl:template> | |
476 | ||
477 | <xsl:template match="libraryname|conceptname"> | |
478 | <xsl:apply-templates select="." mode="annotation"/> | |
479 | </xsl:template> | |
480 | ||
481 | <xsl:template match="description"> | |
482 | <xsl:apply-templates mode="annotation"/> | |
483 | </xsl:template> | |
484 | ||
485 | <!-- Swallow using-namespace and using-class directives along with | |
486 | last-revised elements --> | |
487 | <xsl:template match="using-namespace|using-class|last-revised"/> | |
488 | ||
489 | <!-- If there is no "namespace-reference" mode, forward to | |
490 | "reference" mode --> | |
491 | <xsl:template match="*" mode="namespace-reference"> | |
492 | <xsl:apply-templates select="." mode="reference"/> | |
493 | </xsl:template> | |
494 | ||
495 | <!-- Make the various blocks immediately below a "part" be | |
496 | "chapter"-s. Must also take into account turning | |
497 | chapters within chpaters into sections. --> | |
498 | <xsl:template match="part/part|part/article"> | |
499 | <chapter> | |
500 | <xsl:copy-of select="./@*"/> | |
501 | <xsl:apply-templates/> | |
502 | </chapter> | |
503 | </xsl:template> | |
504 | <xsl:template match="part/part/partinfo|part/article/articleinfo"> | |
505 | <chapterinfo><xsl:apply-templates/></chapterinfo> | |
506 | </xsl:template> | |
507 | <xsl:template match="part/part/chapter|part/part/appendix"> | |
508 | <section> | |
509 | <xsl:copy-of select="./@*"/> | |
510 | <xsl:apply-templates/> | |
511 | </section> | |
512 | </xsl:template> | |
513 | <xsl:template match="part/part/chapter/chapterinfo|part/part/appendix/appendixinfo"> | |
514 | <sectioninfo><xsl:apply-templates/></sectioninfo> | |
515 | </xsl:template> | |
516 | ||
517 | <!-- Header link comment to be inserted at the start of a reference page's | |
518 | synopsis --> | |
519 | <xsl:template name="header-link"> | |
520 | <xsl:if test="ancestor::header"> | |
521 | <xsl:call-template name="highlight-comment"> | |
522 | <xsl:with-param name="text"> | |
523 | <xsl:text>// In header: <</xsl:text> | |
524 | <xsl:call-template name="internal-link"> | |
525 | <xsl:with-param name="to"> | |
526 | <xsl:call-template name="generate.id"> | |
527 | <xsl:with-param name="node" select="ancestor::header[1]"/> | |
528 | </xsl:call-template> | |
529 | </xsl:with-param> | |
530 | <xsl:with-param name="text" select="ancestor::header[1]/@name" /> | |
531 | </xsl:call-template> | |
532 | <xsl:text>> </xsl:text> | |
533 | </xsl:with-param> | |
534 | </xsl:call-template> | |
535 | </xsl:if> | |
536 | </xsl:template> | |
537 | </xsl:stylesheet> | |
538 |