1 <?xml version="1.0" encoding="utf-8"?>
3 Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
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)
9 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:xi="http://www.w3.org/2001/XInclude"
12 <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/common/common.xsl"/>
13 <xsl:include href="reference.xsl"/>
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"/>
19 <!-- Generate consistent id values if document is unchanged -->
20 <xsl:param name="generate.consistent.ids" select="0"/>
22 <!-- The maximum number of columns allowed in preformatted text -->
23 <xsl:param name="max-columns" select="78"/>
25 <!-- The root of the Boost directory -->
26 <xsl:param name="boost.root" select="'../..'"/>
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="''"/>
32 <!-- Whether to rewrite relative URL's to point to the website -->
33 <xsl:param name="boost.url.prefix"/>
35 <!-- A space-separated list of xml elements in the input file for which
36 whitespace should be preserved -->
37 <xsl:preserve-space elements="*"/>
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>
45 <xsl:value-of select="$boost.root"/>
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)"/>
53 <xsl:if test="($boost.url.prefix = '') or contains($boost.root, '://')">
54 <xsl:value-of select="$boost.root"/>
58 <xsl:template match="library-reference">
60 <xsl:when test="ancestor::library-reference">
61 <xsl:apply-templates/>
67 <xsl:attribute name="id">
68 <xsl:value-of select="@id"/>
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>
78 <xsl:if test="not(title)">
80 <xsl:text>Reference</xsl:text>
84 <xsl:if test="concept">
88 <xsl:attribute name="id">
89 <xsl:value-of select="@id"/>
90 <xsl:text>.concepts</xsl:text>
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>
101 <title>Concepts</title>
104 <xsl:for-each select="concept">
106 <xsl:call-template name="internal-link">
107 <xsl:with-param name="to">
108 <xsl:call-template name="generate.id"/>
110 <xsl:with-param name="text" select="@name"/>
112 </simpara></listitem>
118 <xsl:apply-templates/>
124 <xsl:template match="header">
127 <xsl:attribute name="id">
128 <xsl:call-template name="generate.id"/>
132 <xsl:text>Header <</xsl:text>
134 <xsl:attribute name="url">
135 <xsl:value-of select="$boost.header.root"/>
136 <xsl:text>/</xsl:text>
137 <xsl:value-of select="@name"/>
139 <xsl:value-of select="@name"/>
141 <xsl:text>></xsl:text>
144 <xsl:apply-templates select="para|section" mode="annotation"/>
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>
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
167 <xsl:with-param name="indentation" select="0"/>
168 </xsl:apply-templates>
173 <xsl:apply-templates mode="namespace-reference"/>
178 <xsl:template match="header" mode="generate.id">
179 <xsl:text>header.</xsl:text>
180 <xsl:value-of select="translate(@name, '/.', '._')"/>
183 <xsl:template match="*" mode="passthrough">
184 <xsl:copy-of select="."/>
187 <xsl:template name="monospaced">
188 <xsl:param name="text"/>
189 <computeroutput><xsl:value-of select="$text"/></computeroutput>
193 <xsl:template match="ulink">
195 <xsl:copy-of select="@*"/>
196 <xsl:attribute name="url">
198 <xsl:when test="starts-with(@url, 'boost:/')">
199 <xsl:value-of select="concat($boost.protocol.text, substring-after(@url, 'boost:'))"/>
201 <xsl:when test="starts-with(@url, 'boost:')">
202 <xsl:value-of select="concat($boost.protocol.text, '/', substring-after(@url, 'boost:'))"/>
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)"/>
208 <xsl:value-of select="@url"/>
212 <xsl:apply-templates/>
215 <xsl:template name="internal-link">
216 <xsl:param name="to"/>
217 <xsl:param name="text"/>
218 <xsl:param name="highlight" select="false()"/>
220 <link linkend="{$to}">
221 <xsl:if test="$highlight">
222 <xsl:call-template name="source-highlight">
223 <xsl:with-param name="text" select="$text"/>
226 <xsl:if test="not($highlight)">
227 <xsl:value-of select="string($text)"/>
232 <xsl:template name="anchor">
233 <xsl:param name="to"/>
234 <xsl:param name="text"/>
235 <xsl:param name="highlight" select="false()"/>
238 <xsl:if test="$highlight">
239 <xsl:call-template name="source-highlight">
240 <xsl:with-param name="text" select="$text"/>
243 <xsl:if test="not($highlight)">
244 <xsl:value-of select="$text"/>
248 <xsl:template name="link-or-anchor">
249 <xsl:param name="to"/>
250 <xsl:param name="text"/>
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"/>
258 <!-- 'anchor', 'link', or 'none' -->
259 <xsl:param name="link-type">
261 <xsl:when test="$is-anchor">
262 <xsl:text>anchor</xsl:text>
265 <xsl:text>link</xsl:text>
270 <xsl:param name="highlight" select="false()"/>
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"/>
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"/>
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"/>
293 <xsl:if test="not($highlight)">
294 <xsl:value-of select="$text"/>
299 Error: XSL template 'link-or-anchor' called with invalid link-type '<xsl:value-of select="$link-type"/>'
305 <xsl:template name="separator"/>
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"/>
315 <refentry id="{$anchor}">
317 <refentrytitle><xsl:value-of select="$name"/></refentrytitle>
318 <manvolnum>3</manvolnum>
321 <refname><xsl:value-of select="$refname"/></refname>
323 <xsl:apply-templates mode="purpose" select="$purpose"/>
328 <xsl:copy-of select="$synopsis"/>
331 <xsl:if test="not(string($text)='')">
333 <title>Description</title>
334 <xsl:copy-of select="$text"/>
340 <xsl:template name="member-documentation">
341 <xsl:param name="name"/>
342 <xsl:param name="text"/>
345 <title><xsl:copy-of select="$name"/></title>
346 <xsl:copy-of select="$text"/>
350 <xsl:template name="preformatted">
351 <xsl:param name="text"/>
353 <literallayout class="monospaced">
354 <xsl:copy-of select="$text"/>
358 <xsl:template name="synopsis">
359 <xsl:param name="text"/>
362 <xsl:copy-of select="$text"/>
366 <!-- Fallthrough for DocBook elements -->
367 <xsl:template match="*">
368 <xsl:element name="{name(.)}">
369 <xsl:for-each select="./@*">
371 <xsl:when test="local-name(.)='last-revision'">
373 name="rev:last-revision"
374 namespace="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision">
375 <xsl:value-of select="."/>
379 <xsl:attribute name="{name(.)}">
380 <xsl:value-of select="."/>
385 <xsl:apply-templates/>
389 <xsl:template match="processing-instruction()">
393 <xsl:template match="code">
395 <xsl:apply-templates mode="annotation"/>
399 <xsl:template match="code[@language='jam']">
401 <xsl:apply-templates mode="highlight-jam"/>
405 <xsl:template match="code[@language='c++']">
406 <xsl:apply-templates select="." mode="annotation"/>
409 <xsl:template match="bold">
410 <emphasis role="bold">
411 <xsl:apply-templates mode="annotation"/>
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))">
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"/>
427 <xsl:if test="@last-revision">
429 name="rev:last-revision"
430 namespace="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision">
431 <xsl:value-of select="@last-revision"/>
434 <xsl:apply-templates/>
439 <xsl:template match="chapter">
440 <xsl:if test="$boost.include.libraries=''">
442 <xsl:copy-of select="./@*" />
443 <xsl:apply-templates/>
448 <xsl:template match="boostbook">
450 <xsl:copy-of select="@*[not(contains(' last-revision name dirname html-only url ', concat(' ',local-name(),' ')))]"/>
451 <xsl:apply-templates/>
455 <xsl:template match="programlisting">
456 <programlisting><xsl:apply-templates/></programlisting>
459 <xsl:template match="programlisting[@language='jam']">
461 <xsl:apply-templates mode="highlight-jam"/>
465 <xsl:template match="programlisting[@language='c++']">
466 <xsl:apply-templates select="." mode="annotation"/>
469 <!-- These DocBook elements have special meaning. Use the annotation mode -->
470 <xsl:template match="classname|methodname|functionname|enumname|
471 macroname|headername|globalname">
473 <xsl:apply-templates select="." mode="annotation"/>
477 <xsl:template match="libraryname|conceptname">
478 <xsl:apply-templates select="." mode="annotation"/>
481 <xsl:template match="description">
482 <xsl:apply-templates mode="annotation"/>
485 <!-- Swallow using-namespace and using-class directives along with
486 last-revised elements -->
487 <xsl:template match="using-namespace|using-class|last-revised"/>
489 <!-- If there is no "namespace-reference" mode, forward to
491 <xsl:template match="*" mode="namespace-reference">
492 <xsl:apply-templates select="." mode="reference"/>
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">
500 <xsl:copy-of select="./@*"/>
501 <xsl:apply-templates/>
504 <xsl:template match="part/part/partinfo|part/article/articleinfo">
505 <chapterinfo><xsl:apply-templates/></chapterinfo>
507 <xsl:template match="part/part/chapter|part/part/appendix">
509 <xsl:copy-of select="./@*"/>
510 <xsl:apply-templates/>
513 <xsl:template match="part/part/chapter/chapterinfo|part/part/appendix/appendixinfo">
514 <sectioninfo><xsl:apply-templates/></sectioninfo>
517 <!-- Header link comment to be inserted at the start of a reference page's
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]"/>
530 <xsl:with-param name="text" select="ancestor::header[1]/@name" />
532 <xsl:text>> </xsl:text>