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