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