patch by: David Nečas <yeti@physics.muni.cz>
[gtk-doc.git] / gtk-doc.xsl
blobe57ef92d940a6f6e2362bdb2b688dc54f2974d77
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/chunk.xsl"/>
7 <xsl:include href="devhelp.xsl"/>
8 <xsl:include href="devhelp2.xsl"/>
9 <xsl:include href="version-greater-or-equal.xsl"/>
11 <!-- change some parameters -->
12 <!-- http://docbook.sourceforge.net/release/xsl/current/doc/html/index.html -->
13 <xsl:param name="toc.section.depth">2</xsl:param>
14 <xsl:param name="generate.toc">
15 book toc
16 chapter toc
17 part toc
18 reference toc
19 </xsl:param>
21 <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
22 <xsl:param name="chunker.output.indent" select="'yes'"/>
23 <xsl:param name="chunker.output.doctype-public" select="'-//W3C//DTD HTML 4.01 Transitional//EN'"/>
24 <xsl:param name="chunk.fast" select="1"/>
26 <xsl:param name="default.encoding" select="'UTF-8'"/>
27 <xsl:param name="chapter.autolabel" select="0"/>
28 <xsl:param name="use.id.as.filename" select="1"/>
29 <xsl:param name="html.ext" select="'.html'"/>
30 <xsl:param name="refentry.generate.name" select="0"/>
31 <xsl:param name="refentry.generate.title" select="1"/>
33 <!-- use index filtering (if available) -->
34 <xsl:param name="index.on.role" select="1"/>
36 <!-- display variablelists as tables -->
37 <xsl:param name="variablelist.as.table" select="1"/>
39 <!-- new things to consider
40 <xsl:param name="glossterm.auto.link" select="0"></xsl:param>
41 -->
43 <!-- this gets set on the command line ... -->
44 <xsl:param name="gtkdoc.version" select="''"/>
45 <xsl:param name="gtkdoc.bookname" select="''"/>
47 <!-- ========================================================= -->
48 <!-- template to create the index.sgml anchor index -->
50 <xsl:template match="book|article">
51 <xsl:variable name="tooldver">
52 <xsl:call-template name="version-greater-or-equal">
53 <xsl:with-param name="ver1" select="$VERSION" />
54 <xsl:with-param name="ver2">1.36</xsl:with-param>
55 </xsl:call-template>
56 </xsl:variable>
57 <xsl:if test="$tooldver = 0">
58 <xsl:message terminate="yes">
59 FATAL-ERROR: You need the DocBook XSL Stylesheets version 1.36 or higher
60 to build the documentation.
61 Get a newer version at http://docbook.sourceforge.net/projects/xsl/
62 </xsl:message>
63 </xsl:if>
64 <xsl:apply-imports/>
66 <!-- generate the index.sgml href index -->
67 <xsl:call-template name="generate.index"/>
68 <xsl:call-template name="generate.devhelp"/>
69 <xsl:call-template name="generate.devhelp2"/>
70 </xsl:template>
72 <xsl:template name="generate.index">
73 <xsl:call-template name="write.text.chunk">
74 <xsl:with-param name="filename" select="'index.sgml'"/>
75 <xsl:with-param name="content">
76 <xsl:apply-templates select="//releaseinfo/ulink"
77 mode="generate.index.mode"/>
78 <!-- check all anchor and refentry elements -->
79 <xsl:apply-templates select="//anchor|//refentry|//refsect1|//refsect2|//refsynopsisdiv"
80 mode="generate.index.mode"/>
81 </xsl:with-param>
82 <xsl:with-param name="default.encoding" select="'UTF-8'"/>
83 <xsl:with-param name="chunker.output.indent" select="'no'"/>
84 </xsl:call-template>
85 </xsl:template>
87 <xsl:template match="*" mode="generate.index.mode">
88 <xsl:if test="not(@href) and count(@id) > 0">
89 <xsl:text>&lt;ANCHOR id=&quot;</xsl:text>
90 <xsl:value-of select="@id"/>
91 <xsl:text>&quot; href=&quot;</xsl:text>
92 <xsl:if test="$gtkdoc.bookname">
93 <xsl:value-of select="$gtkdoc.bookname"/>
94 <xsl:text>/</xsl:text>
95 </xsl:if>
96 <xsl:call-template name="href.target"/>
97 <xsl:text>&quot;&gt;&#10;</xsl:text>
98 </xsl:if>
99 </xsl:template>
101 <xsl:template match="//releaseinfo/ulink" mode="generate.index.mode">
102 <xsl:if test="@role='online-location'">
103 <xsl:text>&lt;ONLINE href=&quot;</xsl:text>
104 <xsl:value-of select="@url"/>
105 <xsl:text>&quot;&gt;&#10;</xsl:text>
106 </xsl:if>
107 </xsl:template>
109 <!-- ========================================================= -->
110 <!-- template to output gtkdoclink elements for the unknown targets -->
112 <xsl:template match="link">
113 <xsl:choose>
114 <xsl:when test="id(@linkend)">
115 <xsl:apply-imports/>
116 </xsl:when>
117 <xsl:otherwise>
118 <GTKDOCLINK HREF="{@linkend}">
119 <xsl:apply-templates/>
120 </GTKDOCLINK>
121 </xsl:otherwise>
122 </xsl:choose>
123 </xsl:template>
125 <!-- ========================================================= -->
126 <!-- Below are the visual portions of the stylesheet. They provide
127 the normal gtk-doc output style. -->
129 <xsl:param name="shade.verbatim" select="0"/>
130 <xsl:param name="refentry.separator" select="0"/>
132 <xsl:template match="refsect2">
133 <xsl:if test="preceding-sibling::refsect2">
134 <hr/>
135 </xsl:if>
136 <xsl:apply-imports/>
137 </xsl:template>
139 <xsl:template name="user.head.content">
140 <xsl:if test="$gtkdoc.version">
141 <meta name="generator"
142 content="GTK-Doc V{$gtkdoc.version} (XML mode)"/>
143 </xsl:if>
144 <link rel="stylesheet" href="style.css" type="text/css"/>
146 <!-- copied from the html.head template in the docbook stylesheets
147 we don't want links for all refentrys, thats just too much
149 <xsl:variable name="this" select="."/>
150 <xsl:for-each select="//part
151 |//reference
152 |//preface
153 |//chapter
154 |//article
155 |//appendix[not(parent::article)]|appendix
156 |//glossary[not(parent::article)]|glossary
157 |//index[not(parent::article)]|index">
158 <link rel="{local-name(.)}">
159 <xsl:attribute name="href">
160 <xsl:call-template name="href.target">
161 <xsl:with-param name="context" select="$this"/>
162 <xsl:with-param name="object" select="."/>
163 </xsl:call-template>
164 </xsl:attribute>
165 <xsl:attribute name="title">
166 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
167 </xsl:attribute>
168 </link>
169 </xsl:for-each>
170 </xsl:template>
172 <xsl:template name="user.footer.content">
173 <div class="footer">
174 <hr />
175 <xsl:choose>
176 <xsl:when test="$gtkdoc.version">
177 Generated by GTK-Doc V<xsl:copy-of select="$gtkdoc.version" />
178 </xsl:when>
179 <xsl:otherwise>
180 Generated by GTK-Doc
181 </xsl:otherwise>
182 </xsl:choose>
183 </div>
184 </xsl:template>
186 <xsl:template match="title" mode="book.titlepage.recto.mode">
187 <table class="navigation" id="top" width="100%"
188 cellpadding="2" cellspacing="0">
189 <tr>
190 <th valign="middle">
191 <p class="{name(.)}">
192 <xsl:value-of select="."/>
193 </p>
194 </th>
195 </tr>
196 </table>
197 </xsl:template>
199 <xsl:template name="header.navigation">
200 <xsl:param name="prev" select="/foo"/>
201 <xsl:param name="next" select="/foo"/>
202 <xsl:variable name="home" select="/*[1]"/>
203 <xsl:variable name="up" select="parent::*"/>
204 <xsl:variable name="refsections" select="./refsect1[@role]"/>
205 <xsl:variable name="glssections" select="./glossdiv/title"/>
206 <xsl:variable name="idxsections" select="./indexdiv/indexdiv/title"/>
207 <xsl:variable name="section_id" select="./@id"/>
208 <xsl:variable name="sect_object_hierarchy" select="./refsect1[@role='object_hierarchy']"/>
209 <xsl:variable name="sect_impl_interfaces" select="./refsect1[@role='impl_interfaces']"/>
210 <xsl:variable name="sect_prerequisites" select="./refsect1[@role='prerequisites']"/>
211 <xsl:variable name="sect_derived_interfaces" select="./refsect1[@role='derived_interfaces']"/>
212 <xsl:variable name="sect_implementations" select="./refsect1[@role='implementations']"/>
213 <xsl:variable name="sect_properties" select="./refsect1[@role='properties']"/>
214 <xsl:variable name="sect_child_properties" select="./refsect1[@role='child_properties']"/>
215 <xsl:variable name="sect_style_properties" select="./refsect1[@role='style_properties']"/>
216 <xsl:variable name="sect_signal_proto" select="./refsect1[@role='signal_proto']"/>
217 <xsl:variable name="sect_desc" select="./refsect1[@role='desc']"/>
218 <xsl:variable name="sect_synopsis" select="./refsynopsisdiv[@role='synopsis']"/>
219 <!--
220 <xsl:variable name="sect_details" select="./refsect1[@id='details']"/>
221 <xsl:variable name="sect_property_details" select="./refsect1[@id='property_details']"/>
222 <xsl:variable name="sect_child_property_details" select="./refsect1[@id='child_property_details']"/>
223 <xsl:variable name="sect_style_property_details" select="./refsect1[@id='style_property_details']"/>
224 <xsl:variable name="sect_signals" select="./refsect1[@id='signals']"/>
227 <xsl:if test="$suppress.navigation = '0' and $home != .">
228 <table class="navigation" id="top" width="100%"
229 summary = "Navigation header" cellpadding="2" cellspacing="2">
230 <tr valign="middle">
231 <xsl:choose>
232 <xsl:when test="count($prev) > 0">
233 <td>
234 <a accesskey="p">
235 <xsl:attribute name="href">
236 <xsl:call-template name="href.target">
237 <xsl:with-param name="object" select="$prev"/>
238 </xsl:call-template>
239 </xsl:attribute>
240 <img src="left.png" width="24" height="24" border="0">
241 <xsl:attribute name="alt">
242 <xsl:call-template name="gentext">
243 <xsl:with-param name="key">nav-prev</xsl:with-param>
244 </xsl:call-template>
245 </xsl:attribute>
246 </img>
247 </a>
248 </td>
249 </xsl:when>
250 <xsl:otherwise>
251 <td>&#160;</td>
252 </xsl:otherwise>
253 </xsl:choose>
254 <xsl:choose>
255 <xsl:when test="count($up) > 0 and $up != $home">
256 <td>
257 <a accesskey="u">
258 <xsl:attribute name="href">
259 <xsl:call-template name="href.target">
260 <xsl:with-param name="object" select="$up"/>
261 </xsl:call-template>
262 </xsl:attribute>
263 <img src="up.png" width="24" height="24" border="0">
264 <xsl:attribute name="alt">
265 <xsl:call-template name="gentext">
266 <xsl:with-param name="key">nav-up</xsl:with-param>
267 </xsl:call-template>
268 </xsl:attribute>
269 </img>
270 </a>
271 </td>
272 </xsl:when>
273 <xsl:otherwise>
274 <td>&#160;</td>
275 </xsl:otherwise>
276 </xsl:choose>
277 <xsl:choose>
278 <xsl:when test="$home != .">
279 <td>
280 <a accesskey="h">
281 <xsl:attribute name="href">
282 <xsl:call-template name="href.target">
283 <xsl:with-param name="object" select="$home"/>
284 </xsl:call-template>
285 </xsl:attribute>
286 <img src="home.png" width="24" height="24" border="0">
287 <xsl:attribute name="alt">
288 <xsl:call-template name="gentext">
289 <xsl:with-param name="key">nav-home</xsl:with-param>
290 </xsl:call-template>
291 </xsl:attribute>
292 </img>
293 </a>
294 </td>
295 </xsl:when>
296 <xsl:otherwise>
297 <td>&#160;</td>
298 </xsl:otherwise>
299 </xsl:choose>
300 <th width="100%" align="center">
301 <xsl:apply-templates select="$home" mode="object.title.markup"/>
302 </th>
303 <xsl:choose>
304 <xsl:when test="count($next) > 0">
305 <td>
306 <a accesskey="n">
307 <xsl:attribute name="href">
308 <xsl:call-template name="href.target">
309 <xsl:with-param name="object" select="$next"/>
310 </xsl:call-template>
311 </xsl:attribute>
312 <img src="right.png" width="24" height="24" border="0">
313 <xsl:attribute name="alt">
314 <xsl:call-template name="gentext">
315 <xsl:with-param name="key">nav-next</xsl:with-param>
316 </xsl:call-template>
317 </xsl:attribute>
318 </img>
319 </a>
320 </td>
321 </xsl:when>
322 <xsl:otherwise>
323 <td>&#160;</td>
324 </xsl:otherwise>
325 </xsl:choose>
326 </tr>
327 <!--<xsl:if test="name()='refentry'"-->
328 <xsl:choose>
329 <xsl:when test="count($refsections) > 0">
330 <tr>
331 <td colspan="5" class="shortcuts">
332 <xsl:if test="count($sect_synopsis) > 0">
333 <a href="#{$section_id}.synopsis" class="shortcut">Top</a>
334 </xsl:if>
335 <xsl:if test="count($sect_desc) > 0">
336 &#160;|&#160;
337 <a href="#{$section_id}.description" class="shortcut">
338 <xsl:value-of select="./refsect1[@role='desc']/title"/>
339 </a>
340 </xsl:if>
341 <xsl:if test="count($sect_object_hierarchy) > 0">
342 &#160;|&#160;
343 <a href="#{$section_id}.object-hierarchy" class="shortcut">
344 <xsl:value-of select="./refsect1[@role='object_hierarchy']/title"/>
345 </a>
346 </xsl:if>
347 <xsl:if test="count($sect_impl_interfaces) > 0">
348 &#160;|&#160;
349 <a href="#{$section_id}.implemented-interfaces" class="shortcut">
350 <xsl:value-of select="./refsect1[@role='impl_interfaces']/title"/>
351 </a>
352 </xsl:if>
353 <xsl:if test="count($sect_prerequisites) > 0">
354 &#160;|&#160;
355 <a href="#{$section_id}.prerequisites" class="shortcut">
356 <xsl:value-of select="./refsect1[@role='prerequisites']/title"/>
357 </a>
358 </xsl:if>
359 <xsl:if test="count($sect_derived_interfaces) > 0">
360 &#160;|&#160;
361 <a href="#{$section_id}.derived-interfaces" class="shortcut">
362 <xsl:value-of select="./refsect1[@role='derived_interfaces']/title"/>
363 </a>
364 </xsl:if>
365 <xsl:if test="count($sect_implementations) > 0">
366 &#160;|&#160;
367 <a href="#{$section_id}.implementations" class="shortcut">
368 <xsl:value-of select="./refsect1[@role='implementations']/title"/>
369 </a>
370 </xsl:if>
371 <xsl:if test="count($sect_properties) > 0">
372 &#160;|&#160;
373 <a href="#{$section_id}.properties" class="shortcut">
374 <xsl:value-of select="./refsect1[@role='properties']/title"/>
375 </a>
376 </xsl:if>
377 <xsl:if test="count($sect_child_properties) > 0">
378 &#160;|&#160;
379 <a href="#{$section_id}.child-properties" class="shortcut">
380 <xsl:value-of select="./refsect1[@role='child_properties']/title"/>
381 </a>
382 </xsl:if>
383 <xsl:if test="count($sect_style_properties) > 0">
384 &#160;|&#160;
385 <a href="#{$section_id}.style-properties" class="shortcut">
386 <xsl:value-of select="./refsect1[@role='style_properties']/title"/>
387 </a>
388 </xsl:if>
389 <xsl:if test="count($sect_signal_proto) > 0">
390 &#160;|&#160;
391 <a href="#{$section_id}.signals" class="shortcut">
392 <xsl:value-of select="./refsect1[@role='signal_proto']/title"/>
393 </a>
394 </xsl:if>
395 <!--
396 <xsl:if test="count($sect_details) > 0">
397 <a href="#details" class="shortcut">
398 <xsl:value-of select="./refsect1[@id='details']/title"/>
399 </a>
400 &#160;|&#160;
401 </xsl:if>
402 <xsl:if test="count($sect_property_details) > 0">
403 <a href="#property_details" class="shortcut">
404 <xsl:value-of select="./refsect1[@id='property_details']/title"/>
405 </a>
406 &#160;|&#160;
407 </xsl:if>
408 <xsl:if test="count($sect_child_property_details) > 0">
409 <a href="#child_property_details" class="shortcut">
410 <xsl:value-of select="./refsect1[@id='property_child_details']/title"/>
411 </a>
412 &#160;|&#160;
413 </xsl:if>
414 <xsl:if test="count($sect_style_property_details) > 0">
415 <a href="#style_property_details" class="shortcut">
416 <xsl:value-of select="./refsect1[@id='style_property_details']/title"/>
417 </a>
418 &#160;|&#160;
419 </xsl:if>
420 <xsl:if test="count($sect_signals) > 0">
421 <a href="#signals" class="shortcut">
422 <xsl:value-of select="./refsect1[@id='signals']/title"/>
423 </a>
424 &#160;|&#160;
425 </xsl:if>
427 </td>
428 </tr>
429 </xsl:when>
430 <!-- this is not yet very nice, as it requires all glossdic/indexdiv
431 elements having a anchor element. maybe we can customize the xsl
432 to automaticaly create local anchors
434 <xsl:when test="count($glssections) > 0">
435 <tr>
436 <td colspan="5" class="shortcuts">
437 <xsl:for-each select="./glossdiv">
438 <xsl:if test="position() > 1">
439 &#160;|&#160;
440 </xsl:if>
441 <a class="shortcut">
442 <xsl:attribute name="href">#gls<xsl:value-of select="./title"/></xsl:attribute>
443 <xsl:value-of select="./title"/>
444 </a>
445 </xsl:for-each>
446 </td>
447 </tr>
448 </xsl:when>
449 <xsl:when test="count($idxsections) > 0">
450 <tr>
451 <td colspan="5" class="shortcuts">
452 <xsl:for-each select="./indexdiv/indexdiv">
453 <xsl:if test="position() > 1">
454 &#160;|&#160;
455 </xsl:if>
456 <a class="shortcut">
457 <xsl:attribute name="href">#idx<xsl:value-of select="./title"/></xsl:attribute>
458 <xsl:value-of select="./title"/>
459 </a>
460 </xsl:for-each>
461 </td>
462 </tr>
463 </xsl:when>
464 </xsl:choose>
465 </table>
466 </xsl:if>
467 </xsl:template>
469 <xsl:template name="footer.navigation">
470 </xsl:template>
472 <!-- avoid creating multiple identical indices
473 if the stylesheets don't support filtered indices
475 <xsl:template match="index">
476 <xsl:variable name="has-filtered-index">
477 <xsl:call-template name="version-greater-or-equal">
478 <xsl:with-param name="ver1" select="$VERSION" />
479 <xsl:with-param name="ver2">1.66</xsl:with-param>
480 </xsl:call-template>
481 </xsl:variable>
482 <xsl:if test="($has-filtered-index = 1) or (count(@role) = 0)">
483 <xsl:apply-imports/>
484 </xsl:if>
485 </xsl:template>
487 <xsl:template match="index" mode="toc">
488 <xsl:variable name="has-filtered-index">
489 <xsl:call-template name="version-greater-or-equal">
490 <xsl:with-param name="ver1" select="$VERSION" />
491 <xsl:with-param name="ver2">1.66</xsl:with-param>
492 </xsl:call-template>
493 </xsl:variable>
494 <xsl:if test="($has-filtered-index = 1) or (count(@role) = 0)">
495 <xsl:apply-imports/>
496 </xsl:if>
497 </xsl:template>
499 <xsl:template match="para">
500 <xsl:choose>
501 <xsl:when test="@role = 'gallery'">
502 <div class="container">
503 <div class="gallery-spacer"> </div>
504 <xsl:apply-templates mode="gallery.mode"/>
505 <div class="gallery-spacer"> </div>
506 </div>
507 </xsl:when>
508 <xsl:otherwise>
509 <xsl:apply-imports/>
510 </xsl:otherwise>
511 </xsl:choose>
512 </xsl:template>
514 <xsl:template match="link" mode="gallery.mode">
515 <div class="gallery-float">
516 <xsl:apply-templates select="."/>
517 </div>
518 </xsl:template>
520 <!-- add gallery handling to refnamediv template -->
521 <xsl:template match="refnamediv">
522 <div class="{name(.)}">
523 <table width="100%">
524 <tr><td valign="top">
525 <xsl:call-template name="anchor"/>
526 <xsl:choose>
527 <xsl:when test="$refentry.generate.name != 0">
528 <h2>
529 <xsl:call-template name="gentext">
530 <xsl:with-param name="key" select="'RefName'"/>
531 </xsl:call-template>
532 </h2>
533 </xsl:when>
534 <xsl:when test="$refentry.generate.title != 0">
535 <h2>
536 <xsl:choose>
537 <xsl:when test="../refmeta/refentrytitle">
538 <xsl:apply-templates select="../refmeta/refentrytitle"/>
539 </xsl:when>
540 <xsl:otherwise>
541 <xsl:apply-templates select="refname[1]"/>
542 </xsl:otherwise>
543 </xsl:choose>
544 </h2>
545 </xsl:when>
546 </xsl:choose>
548 <xsl:apply-templates/>
549 </p>
550 </td>
551 <td valign="top" align="right">
552 <!-- find the gallery image to use here
553 - determine the id of the enclosing refentry
554 - look for an inlinegraphic inside a link with linkend == refentryid inside a para with role == gallery
555 - use it here
557 <xsl:variable name="refentryid" select="../@id"/>
558 <xsl:apply-templates select="//para[@role = 'gallery']/link[@linkend = $refentryid]/inlinegraphic"/>
559 </td></tr>
560 </table>
561 </div>
562 </xsl:template>
564 <xsl:template match="indexdiv">
565 <a><xsl:attribute name="name">idx<xsl:value-of select="./title"/></xsl:attribute></a>
566 <xsl:apply-templates/>
567 </xsl:template>
569 <xsl:template match="glossdiv">
570 <a><xsl:attribute name="name">gls<xsl:value-of select="./title"/></xsl:attribute></a>
571 <xsl:apply-templates/>
572 </xsl:template>
574 <!-- Exterminate any trace of indexterms in the main flow -->
575 <xsl:template match="indexterm">
576 </xsl:template>
578 <!-- ==================================================================== -->
580 <xsl:template match="acronym">
581 <xsl:call-template name="generate.acronym.link"/>
582 </xsl:template>
584 <xsl:template name="generate.acronym.link">
585 <xsl:param name="acronym">
586 <xsl:apply-templates/>
587 </xsl:param>
588 <!--
589 We use for-each to change context to the database document because key()
590 only locates elements in the same document as the context node!
593 <xsl:param name="value" >
594 <xsl:value-of select="//glossentry/glossterm[text()=$acronym]/../glossdef/para[1]" />
595 </xsl:param>
596 <xsl:choose>
597 <xsl:when test="$value=''">
598 <!-- debug -->
599 <xsl:message>
600 In gtk-doc.xsl: For acronym (<xsl:value-of select="$acronym"/>) no value found!
601 </xsl:message>
603 <xsl:attribute name="href">
604 <xsl:text>http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=</xsl:text>
605 <xsl:value-of select="$acronym"/>
606 </xsl:attribute>
607 <xsl:call-template name="inline.charseq"/>
608 </a>
609 </xsl:when>
610 <xsl:otherwise>
611 <!-- found -->
612 <acronym>
613 <xsl:attribute name="title">
614 <xsl:value-of select="$value"/>
615 </xsl:attribute>
616 <xsl:call-template name="inline.charseq"/>
617 </acronym>
618 </xsl:otherwise>
619 </xsl:choose>
620 </xsl:template>
622 </xsl:stylesheet>