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