test: add a second enum to test merging of hierarchies
[gtk-doc.git] / gtk-doc-single.xsl
blob21bb8bd692044ddb5fcd028c102deb4c6fd6c9e4
1 <?xml version='1.0'?> <!--*- mode: xml -*-->
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version="1.0">
5 <!-- import the chunked XSL stylesheet -->
6 <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
7 <xsl:include href="version-greater-or-equal.xsl"/>
9 <xsl:key name="acronym.key"
10 match="glossentry/glossterm"
11 use="."/>
12 <xsl:key name="gallery.key"
13 match="para[@role='gallery']/link"
14 use="@linkend"/>
16 <!-- change some parameters -->
17 <xsl:param name="toc.section.depth">2</xsl:param>
18 <xsl:param name="generate.toc">
19 book toc
20 chapter toc
21 part toc
22 reference toc
23 </xsl:param>
25 <xsl:param name="default.encoding" select="'UTF-8'"/>
26 <xsl:param name="chapter.autolabel" select="0"/>
27 <xsl:param name="use.id.as.filename" select="1"/>
28 <xsl:param name="html.ext" select="'.html'"/>
29 <xsl:param name="refentry.generate.name" select="0"/>
30 <xsl:param name="refentry.generate.title" select="1"/>
32 <!-- use index filtering (if available) -->
33 <xsl:param name="index.on.role" select="1"/>
35 <!-- display variablelists as tables -->
36 <xsl:param name="variablelist.as.table" select="1"/>
38 <!-- this gets set on the command line ... -->
39 <xsl:param name="gtkdoc.version" select="''"/>
40 <xsl:param name="gtkdoc.bookname" select="''"/>
42 <!-- Override the typical template to prevent showing titles -->
43 <xsl:param name="admon.textlabel" select="0"/>
45 <!-- ========================================================= -->
46 <!-- template to create the index.sgml anchor index -->
48 <xsl:template match="book|article">
49 <xsl:variable name="tooldver">
50 <xsl:call-template name="version-greater-or-equal">
51 <xsl:with-param name="ver1" select="$VERSION" />
52 <xsl:with-param name="ver2">1.36</xsl:with-param>
53 </xsl:call-template>
54 </xsl:variable>
55 <xsl:if test="$tooldver = 0">
56 <xsl:message terminate="yes">
57 FATAL-ERROR: You need the DocBook XSL Stylesheets version 1.36 or higher
58 to build the documentation.
59 Get a newer version at http://docbook.sourceforge.net/projects/xsl/
60 </xsl:message>
61 </xsl:if>
62 <xsl:apply-imports/>
64 <!-- generate the index.sgml href index -->
65 <xsl:call-template name="generate.index"/>
66 </xsl:template>
68 <xsl:template name="generate.index">
69 <xsl:call-template name="write.text.chunk">
70 <xsl:with-param name="filename" select="'index.sgml'"/>
71 <xsl:with-param name="content">
72 <xsl:apply-templates select="//releaseinfo/ulink"
73 mode="generate.index.mode"/>
74 <!-- check all anchor and refentry elements -->
75 <!--
76 The obvious way to write this is //anchor|//refentry|etc...
77 The obvious way is slow because it causes multiple traversals
78 in libxslt. This take about half the time.
79 -->
80 <xsl:apply-templates select="//*[name()='anchor' or name()='refentry' or name()='refsect1' or
81 name() = 'refsect2' or name()='refsynopsisdiv']"
82 mode="generate.index.mode"/>
83 </xsl:with-param>
84 <xsl:with-param name="default.encoding" select="'UTF-8'"/>
85 <xsl:with-param name="chunker.output.indent" select="'no'"/>
86 </xsl:call-template>
87 </xsl:template>
89 <xsl:template match="*" mode="generate.index.mode">
90 <xsl:if test="not(@href) and count(@id) > 0">
91 <xsl:text>&lt;ANCHOR id=&quot;</xsl:text>
92 <xsl:value-of select="@id"/>
93 <xsl:text>&quot; href=&quot;</xsl:text>
94 <xsl:if test="$gtkdoc.bookname">
95 <xsl:value-of select="$gtkdoc.bookname"/>
96 <xsl:text>/</xsl:text>
97 </xsl:if>
98 <xsl:call-template name="href.target"/>
99 <xsl:text>&quot;&gt;&#10;</xsl:text>
100 </xsl:if>
101 </xsl:template>
103 <xsl:template match="//releaseinfo/ulink" mode="generate.index.mode">
104 <xsl:if test="@role='online-location'">
105 <xsl:text>&lt;ONLINE href=&quot;</xsl:text>
106 <xsl:value-of select="@url"/>
107 <xsl:text>&quot;&gt;&#10;</xsl:text>
108 </xsl:if>
109 </xsl:template>
111 <!-- ========================================================= -->
112 <!-- template to output gtkdoclink elements for the unknown targets -->
114 <xsl:template match="link">
115 <xsl:choose>
116 <xsl:when test="id(@linkend)">
117 <xsl:apply-imports/>
118 </xsl:when>
119 <xsl:otherwise>
120 <GTKDOCLINK HREF="{@linkend}">
121 <xsl:apply-templates/>
122 </GTKDOCLINK>
123 </xsl:otherwise>
124 </xsl:choose>
125 </xsl:template>
127 <!-- ========================================================= -->
128 <!-- Below are the visual portions of the stylesheet. They provide
129 the normal gtk-doc output style. -->
131 <xsl:param name="shade.verbatim" select="0"/>
132 <xsl:param name="refentry.separator" select="0"/>
134 <xsl:template match="refsect2">
135 <xsl:if test="preceding-sibling::refsect2">
136 <hr/>
137 </xsl:if>
138 <xsl:apply-imports/>
139 </xsl:template>
141 <xsl:template name="user.head.title">
142 <xsl:variable name="home" select="/*[1]"/>
143 <title>
144 <xsl:apply-templates select="$home" mode="object.title.markup"/>: <xsl:copy-of select="$title"/>
145 </title>
146 </xsl:template>
148 <xsl:template name="user.head.content">
149 <xsl:if test="$gtkdoc.version">
150 <meta name="generator"
151 content="GTK-Doc V{$gtkdoc.version} (XML mode)"/>
152 </xsl:if>
153 <link rel="stylesheet" href="style.css" type="text/css"/>
155 <!-- copied from the html.head template in the docbook stylesheets
156 we don't want links for all refentrys, thats just too much
158 <xsl:variable name="this" select="."/>
159 <xsl:for-each select="//part
160 |//reference
161 |//preface
162 |//chapter
163 |//article
164 |//appendix[not(parent::article)]|appendix
165 |//glossary[not(parent::article)]|glossary
166 |//index[not(parent::article)]|index">
167 <link rel="{local-name(.)}">
168 <xsl:attribute name="href">
169 <xsl:call-template name="href.target">
170 <xsl:with-param name="context" select="$this"/>
171 <xsl:with-param name="object" select="."/>
172 </xsl:call-template>
173 </xsl:attribute>
174 <xsl:attribute name="title">
175 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
176 </xsl:attribute>
177 </link>
178 </xsl:for-each>
179 </xsl:template>
181 <xsl:template name="user.footer.content">
182 <div class="footer">
183 <hr />
184 <xsl:choose>
185 <xsl:when test="$gtkdoc.version">
186 Generated by GTK-Doc V<xsl:copy-of select="$gtkdoc.version" />
187 </xsl:when>
188 <xsl:otherwise>
189 Generated by GTK-Doc
190 </xsl:otherwise>
191 </xsl:choose>
192 </div>
193 </xsl:template>
195 <xsl:template match="title" mode="book.titlepage.recto.mode">
196 <table class="navigation" id="top" width="100%"
197 cellpadding="2" cellspacing="0">
198 <tr>
199 <th valign="middle">
200 <p class="{name(.)}">
201 <xsl:value-of select="."/>
202 </p>
203 </th>
204 </tr>
205 </table>
206 </xsl:template>
208 <xsl:template name="header.navigation">
209 <xsl:param name="prev" select="/foo"/>
210 <xsl:param name="next" select="/foo"/>
211 <xsl:variable name="home" select="/*[1]"/>
212 <xsl:variable name="up" select="parent::*"/>
213 <xsl:variable name="sections" select="./refsect1[@role]"/>
214 <xsl:variable name="section_id" select="./@id"/>
215 <xsl:variable name="sect_object_hierarchy" select="./refsect1[@role='object_hierarchy']"/>
216 <xsl:variable name="sect_impl_interfaces" select="./refsect1[@role='impl_interfaces']"/>
217 <xsl:variable name="sect_prerequisites" select="./refsect1[@role='prerequisites']"/>
218 <xsl:variable name="sect_derived_interfaces" select="./refsect1[@role='derived_interfaces']"/>
219 <xsl:variable name="sect_implementations" select="./refsect1[@role='implementations']"/>
220 <xsl:variable name="sect_properties" select="./refsect1[@role='properties']"/>
221 <xsl:variable name="sect_child_properties" select="./refsect1[@role='child_properties']"/>
222 <xsl:variable name="sect_style_properties" select="./refsect1[@role='style_properties']"/>
223 <xsl:variable name="sect_signal_proto" select="./refsect1[@role='signal_proto']"/>
224 <xsl:variable name="sect_desc" select="./refsect1[@role='desc']"/>
225 <xsl:variable name="sect_synopsis" select="./refsynopsisdiv[@role='synopsis']"/>
226 <!--
227 <xsl:variable name="sect_details" select="./refsect1[@id='details']"/>
228 <xsl:variable name="sect_property_details" select="./refsect1[@id='property_details']"/>
229 <xsl:variable name="sect_child_property_details" select="./refsect1[@id='child_property_details']"/>
230 <xsl:variable name="sect_style_property_details" select="./refsect1[@id='style_property_details']"/>
231 <xsl:variable name="sect_signals" select="./refsect1[@id='signals']"/>
234 <xsl:if test="$suppress.navigation = '0' and $home != .">
235 <table class="navigation" id="top" width="100%"
236 summary = "Navigation header" cellpadding="2" cellspacing="10">
237 <tr valign="middle">
238 <td width="100%" align="left" class="shortcuts">
239 <!--<xsl:if test="name()='refentry'"-->
240 <a href="#" class="shortcut">Top</a>
241 <xsl:if test="count($sections) > 0">
242 <xsl:if test="count($sect_desc) > 0">
243 <span id="nav_description">&#160;<span class="dim">|</span>&#160;
244 <a href="#{$section_id}.description" class="shortcut">
245 <xsl:value-of select="./refsect1[@role='desc']/title"/>
246 </a></span>
247 </xsl:if>
248 <xsl:if test="count($sect_object_hierarchy) > 0">
249 <span id="nav_hierarchy">&#160;<span class="dim">|</span>&#160;
250 <a href="#{$section_id}.object-hierarchy" class="shortcut">
251 <xsl:value-of select="./refsect1[@role='object_hierarchy']/title"/>
252 </a></span>
253 </xsl:if>
254 <xsl:if test="count($sect_impl_interfaces) > 0">
255 <span id="nav_interfaces">&#160;<span class="dim">|</span>&#160;
256 <a href="#{$section_id}.implemented-interfaces" class="shortcut">
257 <xsl:value-of select="./refsect1[@role='impl_interfaces']/title"/>
258 </a></span>
259 </xsl:if>
260 <xsl:if test="count($sect_prerequisites) > 0">
261 <span id="nav_prerequisites">&#160;<span class="dim">|</span>&#160;
262 <a href="#{$section_id}.prerequisites" class="shortcut">
263 <xsl:value-of select="./refsect1[@role='prerequisites']/title"/>
264 </a></span>
265 </xsl:if>
266 <xsl:if test="count($sect_derived_interfaces) > 0">
267 <span id="nav_derived_interfaces">&#160;<span class="dim">|</span>&#160;
268 <a href="#{$section_id}.derived-interfaces" class="shortcut">
269 <xsl:value-of select="./refsect1[@role='derived_interfaces']/title"/>
270 </a></span>
271 </xsl:if>
272 <xsl:if test="count($sect_implementations) > 0">
273 <span id="nav_implementations">&#160;<span class="dim">|</span>&#160;
274 <a href="#{$section_id}.implementations" class="shortcut">
275 <xsl:value-of select="./refsect1[@role='implementations']/title"/>
276 </a></span>
277 </xsl:if>
278 <xsl:if test="count($sect_properties) > 0">
279 <span id="nav_properties">&#160;<span class="dim">|</span>&#160;
280 <a href="#{$section_id}.properties" class="shortcut">
281 <xsl:value-of select="./refsect1[@role='properties']/title"/>
282 </a></span>
283 </xsl:if>
284 <xsl:if test="count($sect_child_properties) > 0">
285 <span id="nav_child_properties">&#160;<span class="dim">|</span>&#160;
286 <a href="#{$section_id}.child-properties" class="shortcut">
287 <xsl:value-of select="./refsect1[@role='child_properties']/title"/>
288 </a></span>
289 </xsl:if>
290 <xsl:if test="count($sect_style_properties) > 0">
291 <span id="nav_style_properties">&#160;<span class="dim">|</span>&#160;
292 <a href="#{$section_id}.style-properties" class="shortcut">
293 <xsl:value-of select="./refsect1[@role='style_properties']/title"/>
294 </a></span>
295 </xsl:if>
296 <xsl:if test="count($sect_signal_proto) > 0">
297 <span id="nav_signals">&#160;<span class="dim">|</span>&#160;
298 <a href="#{$section_id}.signals" class="shortcut">
299 <xsl:value-of select="./refsect1[@role='signal_proto']/title"/>
300 </a></span>
301 </xsl:if>
302 </xsl:if>
303 </td>
304 <xsl:choose>
305 <xsl:when test="$home != .">
306 <td>
307 <a accesskey="h">
308 <xsl:attribute name="href">
309 <xsl:call-template name="href.target">
310 <xsl:with-param name="object" select="$home"/>
311 </xsl:call-template>
312 </xsl:attribute>
313 <img src="home.png" width="16" height="16" border="0">
314 <xsl:attribute name="alt">
315 <xsl:call-template name="gentext">
316 <xsl:with-param name="key">nav-home</xsl:with-param>
317 </xsl:call-template>
318 </xsl:attribute>
319 </img>
320 </a>
321 </td>
322 </xsl:when>
323 <xsl:otherwise>
324 <td>&#160;</td>
325 </xsl:otherwise>
326 </xsl:choose>
327 <xsl:choose>
328 <xsl:when test="count($up) > 0 and $up != $home">
329 <td>
330 <a accesskey="u">
331 <xsl:attribute name="href">
332 <xsl:call-template name="href.target">
333 <xsl:with-param name="object" select="$up"/>
334 </xsl:call-template>
335 </xsl:attribute>
336 <img src="up.png" width="16" height="16" border="0">
337 <xsl:attribute name="alt">
338 <xsl:call-template name="gentext">
339 <xsl:with-param name="key">nav-up</xsl:with-param>
340 </xsl:call-template>
341 </xsl:attribute>
342 </img>
343 </a>
344 </td>
345 </xsl:when>
346 <xsl:otherwise>
347 <td><img src="up-insensitive.png" width="16" height="16" border="0"/></td>
348 </xsl:otherwise>
349 </xsl:choose>
350 <xsl:choose>
351 <xsl:when test="count($prev) > 0">
352 <td>
353 <a accesskey="p">
354 <xsl:attribute name="href">
355 <xsl:call-template name="href.target">
356 <xsl:with-param name="object" select="$prev"/>
357 </xsl:call-template>
358 </xsl:attribute>
359 <img src="left.png" width="16" height="16" border="0">
360 <xsl:attribute name="alt">
361 <xsl:call-template name="gentext">
362 <xsl:with-param name="key">nav-prev</xsl:with-param>
363 </xsl:call-template>
364 </xsl:attribute>
365 </img>
366 </a>
367 </td>
368 </xsl:when>
369 <xsl:otherwise>
370 <td><img src="left-insensitive.png" width="16" height="16" border="0"/></td>
371 </xsl:otherwise>
372 </xsl:choose>
373 <xsl:choose>
374 <xsl:when test="count($next) > 0">
375 <td>
376 <a accesskey="n">
377 <xsl:attribute name="href">
378 <xsl:call-template name="href.target">
379 <xsl:with-param name="object" select="$next"/>
380 </xsl:call-template>
381 </xsl:attribute>
382 <img src="right.png" width="16" height="16" border="0">
383 <xsl:attribute name="alt">
384 <xsl:call-template name="gentext">
385 <xsl:with-param name="key">nav-next</xsl:with-param>
386 </xsl:call-template>
387 </xsl:attribute>
388 </img>
389 </a>
390 </td>
391 </xsl:when>
392 <xsl:otherwise>
393 <td><img src="right-insensitive.png" width="16" height="16" border="0"/></td>
394 </xsl:otherwise>
395 </xsl:choose>
396 </tr>
397 </table>
398 </xsl:if>
399 </xsl:template>
401 <xsl:template name="footer.navigation">
402 </xsl:template>
404 <!-- avoid creating multiple identical indices
405 if the stylesheets don't support filtered indices
407 <xsl:template match="index">
408 <xsl:variable name="has-filtered-index">
409 <xsl:call-template name="version-greater-or-equal">
410 <xsl:with-param name="ver1" select="$VERSION" />
411 <xsl:with-param name="ver2">1.66</xsl:with-param>
412 </xsl:call-template>
413 </xsl:variable>
414 <xsl:if test="($has-filtered-index = 1) or (count(@role) = 0)">
415 <xsl:apply-imports/>
416 </xsl:if>
417 </xsl:template>
419 <xsl:template match="index" mode="toc">
420 <xsl:variable name="has-filtered-index">
421 <xsl:call-template name="version-greater-or-equal">
422 <xsl:with-param name="ver1" select="$VERSION" />
423 <xsl:with-param name="ver2">1.66</xsl:with-param>
424 </xsl:call-template>
425 </xsl:variable>
426 <xsl:if test="($has-filtered-index = 1) or (count(@role) = 0)">
427 <xsl:apply-imports/>
428 </xsl:if>
429 </xsl:template>
431 <xsl:template match="para">
432 <xsl:choose>
433 <xsl:when test="@role = 'gallery'">
434 <div class="container">
435 <div class="gallery-spacer"> </div>
436 <xsl:apply-templates mode="gallery.mode"/>
437 <div class="gallery-spacer"> </div>
438 </div>
439 </xsl:when>
440 <xsl:otherwise>
441 <xsl:apply-imports/>
442 </xsl:otherwise>
443 </xsl:choose>
444 </xsl:template>
446 <xsl:template match="link" mode="gallery.mode">
447 <div class="gallery-float">
448 <xsl:apply-templates select="."/>
449 </div>
450 </xsl:template>
452 <!-- add gallery handling to refnamediv template -->
453 <xsl:template match="refnamediv">
454 <div class="{name(.)}">
455 <table width="100%">
456 <tr><td valign="top">
457 <xsl:call-template name="anchor"/>
458 <xsl:choose>
459 <xsl:when test="$refentry.generate.name != 0">
460 <h2>
461 <xsl:call-template name="gentext">
462 <xsl:with-param name="key" select="'RefName'"/>
463 </xsl:call-template>
464 </h2>
465 </xsl:when>
466 <xsl:when test="$refentry.generate.title != 0">
467 <h2>
468 <xsl:choose>
469 <xsl:when test="../refmeta/refentrytitle">
470 <xsl:apply-templates select="../refmeta/refentrytitle"/>
471 </xsl:when>
472 <xsl:otherwise>
473 <xsl:apply-templates select="refname[1]"/>
474 </xsl:otherwise>
475 </xsl:choose>
476 </h2>
477 </xsl:when>
478 </xsl:choose>
480 <xsl:apply-templates/>
481 </p>
482 </td>
483 <td class="gallery_image" valign="top" align="right">
484 <!-- find the gallery image to use here
485 - determine the id of the enclosing refentry
486 - look for an inlinegraphic inside a link with linkend == refentryid inside a para with role == gallery
487 - use it here
489 <xsl:variable name="refentryid" select="../@id"/>
490 <xsl:apply-templates select="key('gallery.key', $refentryid)/inlinegraphic"/>
491 </td></tr>
492 </table>
493 </div>
494 </xsl:template>
496 <!-- Exterminate any trace of indexterms in the main flow -->
497 <xsl:template match="indexterm">
498 </xsl:template>
500 <!-- ==================================================================== -->
502 <xsl:template match="acronym">
503 <xsl:call-template name="generate.acronym.link"/>
504 </xsl:template>
506 <xsl:template name="generate.acronym.link">
507 <xsl:param name="acronym">
508 <xsl:apply-templates/>
509 </xsl:param>
510 <!--
511 We use for-each to change context to the database document because key()
512 only locates elements in the same document as the context node!
515 <xsl:param name="value" >
516 <xsl:value-of select="key('acronym.key', $acronym)/../glossdef/para[1]" />
517 </xsl:param>
518 <xsl:choose>
519 <xsl:when test="$value=''">
520 <!-- debug -->
521 <xsl:message>
522 In gtk-doc.xsl: For acronym (<xsl:value-of select="$acronym"/>) no value found!
523 </xsl:message>
525 <xsl:attribute name="href">
526 <xsl:text>http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=</xsl:text>
527 <xsl:value-of select="$acronym"/>
528 </xsl:attribute>
529 <xsl:call-template name="inline.charseq"/>
530 </a>
531 </xsl:when>
532 <xsl:otherwise>
533 <!-- found -->
534 <acronym>
535 <xsl:attribute name="title">
536 <xsl:value-of select="$value"/>
537 </xsl:attribute>
538 <xsl:call-template name="inline.charseq"/>
539 </acronym>
540 </xsl:otherwise>
541 </xsl:choose>
542 </xsl:template>
544 </xsl:stylesheet>