1 <?xml version="1.0" encoding="UTF-8"?>
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:exsl="http://exslt.org/common"
5 extension-element-prefixes="exsl"
6 exclude-result-prefixes="exsl"
10 method="xml" indent="yes"
11 doctype-public="-//OASIS//DTD DocBook XML V4.5//EN"
12 doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"/>
14 <xsl:template name="write.api.overview.contents">
16 <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'variable' or memberdef/@kind = 'typedef']) > 0">
18 <title>Variable and Type Definitions</title>
20 <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'variable' or memberdef/@kind = 'typedef']">
23 <xsl:value-of select="header"/>
26 <xsl:apply-templates select="description"/>
27 <xsl:apply-templates select="memberdef[@kind = 'variable' or @kind = 'typedef']"/>
33 <xsl:if test="count(ancestor::*/innerclass) > 0">
35 <title>Structure Definitions</title>
37 <xsl:for-each select="ancestor::*/innerclass">
38 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
43 <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'define' or @kind = 'define']) > 0">
45 <title>Macro Definitions</title>
47 <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'define' or @kind = 'define']">
50 <xsl:value-of select="header"/>
53 <xsl:apply-templates select="description"/>
54 <xsl:apply-templates select="memberdef[@kind = 'define']"/>
60 <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'function']) > 0">
62 <title>Function Definitions</title>
64 <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'function']">
67 <xsl:value-of select="header"/>
70 <xsl:apply-templates select="description"/>
71 <xsl:apply-templates select="memberdef[@kind = 'function']"/>
77 <xsl:if test="count(ancestor::*/sectiondef[@kind = 'enum']) > 0">
79 <title>Enumeration Definitions</title>
81 <xsl:apply-templates select="ancestor::*/sectiondef[@kind = 'enum']"/>
87 <xsl:template match="compounddef">
88 <!-- Discard compounddef elements unless a later template matches -->
91 <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
92 <section id="{@id}" xreflabel="{compoundname}">
95 <xsl:when test="@kind = 'struct'">
96 <xsl:text>Struct </xsl:text>
98 <xsl:when test="@kind = 'union'">
99 <xsl:text>Union </xsl:text>
103 <xsl:value-of select="compoundname"/>
106 <xsl:apply-templates select="detaileddescription"/>
108 <xsl:for-each select="sectiondef[@kind = 'public-attrib']">
109 <informaltable tabstyle="striped">
115 <entry>Description</entry>
119 <xsl:for-each select="memberdef">
120 <row id="{@id}" xreflabel="{name}">
122 <xsl:apply-templates select="type"/>
125 <xsl:value-of select="name"/>
126 <xsl:if test="starts-with(argsstring, '[')">
127 <xsl:text>[]</xsl:text>
131 <xsl:apply-templates select="detaileddescription" mode="struct"/>
143 <xsl:template match="memberdef[@kind = 'function']">
144 <section id="{@id}" xreflabel="{name}">
145 <title> Function <xsl:value-of select="name"/>() </title>
148 <emphasis role="italic">
149 <xsl:value-of select="briefdescription"/>
153 <programlisting language="c">
154 <xsl:value-of select="definition"/>
155 <xsl:text> 		</xsl:text>
156 <xsl:apply-templates select="argsstring"/>
159 <xsl:apply-templates select="detaileddescription"/>
165 <xsl:template match="memberdef[@kind = 'enum']">
166 <section id="{@id}" xreflabel="{name}">
167 <title> Enum <xsl:value-of select="name"/> </title>
169 <xsl:apply-templates select="detaileddescription"/>
171 <informaltable tabstyle="striped">
175 <entry>Enum Value</entry>
176 <entry>Description</entry>
180 <xsl:for-each select="enumvalue">
183 <para id="{@id}" xreflabel="{name}">
184 <xsl:value-of select="name"/>
188 <xsl:apply-templates select="detaileddescription"/>
200 <xsl:template match="memberdef[@kind = 'define']">
201 <section id="{@id}" xreflabel="{name}">
202 <title> Macro <xsl:value-of select="name"/> </title>
204 <programlisting language="c">
205 <xsl:text>#define </xsl:text>
206 <xsl:value-of select="name"/>
207 <xsl:if test="count(param) > 0">
208 <xsl:text>(</xsl:text>
209 <xsl:for-each select="param/defname">
210 <xsl:if test="position() > 1">
211 <xsl:text>, </xsl:text>
213 <xsl:value-of select="."/>
215 <xsl:text>)</xsl:text>
217 <xsl:text> </xsl:text>
219 <!-- Split long macro definitions across multiple lines -->
220 <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">
221 <xsl:text>\ 		</xsl:text>
224 <xsl:value-of select="initializer"/>
227 <xsl:apply-templates select="detaileddescription"/>
233 <xsl:template match="memberdef[@kind = 'variable' or @kind = 'typedef']">
234 <section id="{@id}" xreflabel="{name}">
236 <!-- Doxygen gets confused and thinks function pointer type definitions
237 are variables, so we need to map them to this common section and
238 check the definition to see which of the two it is. -->
240 <xsl:when test="contains(definition,'typedef')">
241 <xsl:text>Type </xsl:text>
245 <xsl:text>Variable </xsl:text>
249 <xsl:value-of select="name"/>
252 <programlisting language="c">
253 <xsl:value-of select="definition"/>
256 <xsl:apply-templates select="detaileddescription"/>
262 <xsl:template match="sectiondef">
264 <xsl:value-of select="description"/>
267 <xsl:apply-templates select="memberdef"/>
270 <xsl:template match="simplesect" mode="struct">
272 <xsl:apply-templates select="para"/>
276 <xsl:template match="simplesect">
278 <xsl:when test="@kind = 'warning'">
280 <title>Warning</title>
281 <xsl:apply-templates select="para"/>
285 <xsl:when test="@kind = 'return'">
287 <title>Returns</title>
288 <xsl:apply-templates select="para"/>
292 <xsl:when test="@kind = 'pre'">
294 <title>Precondition</title>
295 <xsl:apply-templates select="para"/>
299 <xsl:when test="@kind = 'par'">
302 <xsl:value-of select="title"/>
304 <xsl:apply-templates select="para"/>
308 <xsl:when test="@kind = 'see'">
310 <title>See also</title>
311 <xsl:apply-templates select="para"/>
315 <xsl:when test="@kind = 'note'">
316 <!-- Notes can have special prefix keywords to transform them into
317 special styles for training documents ("AlfonsoNotes(TM)") -->
318 <xsl:variable name="note.prefix" select="substring-before(para[1]/text(), ' ')"/>
322 <xsl:when test="$note.prefix = 'TODO:'">
323 <xsl:attribute name="role">todo</xsl:attribute>
327 <xsl:when test="$note.prefix = 'TIP:'">
328 <xsl:attribute name="role">tip</xsl:attribute>
332 <xsl:when test="$note.prefix = 'INFO:'">
333 <xsl:attribute name="role">info</xsl:attribute>
337 <xsl:when test="$note.prefix = 'RESULT:'">
338 <xsl:attribute name="role">result</xsl:attribute>
339 <title>Result</title>
342 <xsl:when test="$note.prefix = 'EXECUTE:'">
343 <xsl:attribute name="role">execute</xsl:attribute>
344 <title>Execute</title>
347 <xsl:when test="$note.prefix = 'WARNING:'">
348 <xsl:attribute name="role">warning</xsl:attribute>
349 <title>Warning</title>
355 <xsl:apply-templates select="para"/>
362 <!-- Strip off the special note type prefix from the special training document
363 style notes ("AlfonsoNotes(TM)") if one is present. -->
364 <xsl:template match="para[parent::simplesect/@kind='note']/text()">
365 <xsl:variable name="note.prefix" select="substring-before(., ' ')"/>
366 <xsl:variable name="note.content" select="substring-after(., ' ')"/>
369 <xsl:when test="$note.prefix = 'TODO:'">
370 <xsl:value-of select="$note.content"/>
373 <xsl:when test="$note.prefix = 'TIP:'">
374 <xsl:value-of select="$note.content"/>
377 <xsl:when test="$note.prefix = 'INFO:'">
378 <xsl:value-of select="$note.content"/>
381 <xsl:when test="$note.prefix = 'RESULT:'">
382 <xsl:value-of select="$note.content"/>
385 <xsl:when test="$note.prefix = 'EXECUTE:'">
386 <xsl:value-of select="$note.content"/>
389 <xsl:when test="$note.prefix = 'WARNING:'">
390 <xsl:value-of select="$note.content"/>
394 <xsl:value-of select="."/>
399 <xsl:template match="parameterlist[@kind = 'param']">
400 <table tabstyle="striped">
401 <title>Parameters</title>
405 <entry>Data Direction</entry>
406 <entry>Parameter Name</entry>
407 <entry>Description</entry>
411 <xsl:for-each select="parameteritem">
413 <xsl:apply-templates select="."/>
421 <xsl:template match="parameterlist[@kind = 'retval']">
422 <table tabstyle="striped">
423 <title>Return Values</title>
427 <entry>Return Value</entry>
428 <entry>Description</entry>
432 <xsl:for-each select="parameteritem">
434 <xsl:apply-templates select="."/>
442 <xsl:template match="parameteritem">
443 <xsl:if test="parent::parameterlist/@kind = 'param'">
447 <xsl:when test="not(descendant::parametername/@direction)">
448 <emphasis role="italic">?</emphasis>
451 <emphasis role="bold">[<xsl:value-of select="descendant::parametername/@direction"/>]</emphasis>
460 <xsl:value-of select="parameternamelist/parametername"/>
465 <xsl:apply-templates select="parameterdescription"/>
469 <xsl:template match="type">
470 <xsl:apply-templates/>
473 <xsl:template match="sect1">
474 <section id="{@id}" xreflabel="{title}">
476 <xsl:value-of select="title"/>
479 <xsl:apply-templates select="para"/>
480 <xsl:apply-templates select="sect2"/>
484 <xsl:template match="sect2">
485 <section id="{@id}" xreflabel="{title}">
487 <xsl:value-of select="title"/>
490 <xsl:apply-templates select="para"/>
491 <xsl:apply-templates select="sect3"/>
495 <xsl:template match="sect3">
496 <section id="{@id}" xreflabel="{title}">
498 <xsl:value-of select="title"/>
501 <xsl:apply-templates select="para"/>
505 <xsl:template match="detaileddescription">
506 <xsl:apply-templates select="para"/>
507 <xsl:apply-templates select="sect1"/>
510 <xsl:template match="para">
512 <xsl:apply-templates/>
516 <xsl:template match="bold">
517 <emphasis role="bold">
518 <xsl:value-of select="."/>
522 <xsl:template match="emphasis">
523 <emphasis role="italic">
524 <xsl:value-of select="."/>
528 <xsl:template match="computeroutput">
530 <xsl:value-of select="."/>
534 <xsl:template match="ulink">
536 <xsl:value-of select="."/>
540 <xsl:template match="registered">
541 <xsl:text>®</xsl:text>
544 <xsl:template match="copy">
545 <xsl:text>©</xsl:text>
548 <xsl:template match="trademark">
549 <xsl:text>™</xsl:text>
552 <xsl:template match="ref">
554 <!-- Don't show links inside program listings -->
555 <xsl:when test="ancestor::programlisting">
556 <xsl:value-of select="."/>
559 <!-- Show links outside program listings -->
561 <link linkend="{@refid}" xrefstyle="nopage">
562 <xsl:value-of select="text()"/>
568 <xsl:template match="formula">
570 <!-- LaTeX equation generation requires JLatexMath and its associated
571 FOP plugin, or you will get missing equations in the output -->
572 <latex align="center" xmlns="http://forge.scilab.org/p/jlatexmath">
573 <xsl:value-of select="."/>
578 <xsl:template match="table">
580 <xsl:when test="caption">
581 <table tabstyle="striped">
583 <xsl:value-of select="caption"/>
585 <xsl:call-template name="write.table.content"/>
589 <informaltable tabstyle="striped">
590 <xsl:call-template name="write.table.content"/>
596 <xsl:template name="write.table.content">
597 <tgroup cols="{@cols}">
599 <xsl:for-each select="row[1]">
601 <xsl:for-each select="entry">
603 <xsl:apply-templates select="."/>
610 <xsl:for-each select="row[position() != 1]">
612 <xsl:for-each select="entry">
614 <xsl:apply-templates select="."/>
623 <xsl:template match="itemizedlist">
625 <xsl:apply-templates select="listitem"/>
629 <xsl:template match="orderedlist">
631 <xsl:apply-templates select="listitem"/>
635 <xsl:template match="listitem">
637 <xsl:apply-templates/>
641 <xsl:template match="programlisting">
642 <programlisting language="c">
643 <xsl:for-each select="codeline[position() > 1 or highlight]">
644 <xsl:apply-templates select="."/>
645 <xsl:text> </xsl:text>
650 <xsl:template match="highlight">
652 <xsl:attribute name="role">
653 <xsl:value-of select="@class"/>
655 <xsl:apply-templates/>
659 <xsl:template match="sp[ancestor::codeline]">
661 <!-- Need to check if this is the first part of the line - if so we may
662 need to strip off any leading <sp/> element indentation -->
663 <xsl:when test="ancestor::highlight = ancestor::codeline/highlight[1]">
664 <!-- Doxygen retains a level of indentation in some code fragments - obtain
665 the base indentation level by counting the leading <sp/> elements of the
666 first code line, and use that to remove the indentation on the rest -->
667 <xsl:variable name="leading.spaces" select="count(ancestor::programlisting/codeline[highlight][1]/highlight[1]/sp[not(preceding-sibling::text())])"/>
669 <xsl:if test="position() > $leading.spaces">
670 <xsl:text> </xsl:text>
675 <xsl:text> </xsl:text>
680 <xsl:template match="image">
683 <xsl:value-of select="."/>
688 <imagedata scalefit="1" width="{@width}">
689 <xsl:attribute name="fileref">html/<xsl:value-of select="@name"/></xsl:attribute>
696 <xsl:template match="anchor">
700 <xsl:template match="dot">
701 <!-- We get raw DOT syntax rather than a rendered image: write the DOT code
702 to a new unique file, and make a image reference to a SVG version of
703 that file. The build system should then call dot to render all generated
704 DOT files into their SVG equivalents before rendering the PDF. -->
705 <xsl:variable name="filename" select="generate-id(.)" />
706 <exsl:document href="{$filename}.dot" method="text">
707 <xsl:value-of select="." />
712 <xsl:value-of select="ancestor::*/title"/>
716 <imagedata format="SVG">
717 <xsl:attribute name="fileref">
718 <xsl:value-of select="$filename" />
719 <xsl:text>.svg</xsl:text>
727 <xsl:template match="argsstring" name="split.functions.args">
728 <xsl:param name="text" select="."/>
729 <xsl:value-of select="substring-before(concat($text,','),',')"/>
730 <xsl:if test="contains($text,',')">
731 <xsl:text>, 		</xsl:text>
732 <xsl:call-template name="split.functions.args">
733 <xsl:with-param name="text" select="substring-after($text,',')"/>