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