Hide the donation Pledgie image from the HV1 output, as Doxygen incorrectly strips...
[pub/USBasp.git] / LUFA / StudioIntegration / HV1 / lufa_docbook_transform.xslt
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
4
5 <xsl:output method="xml" indent="no"/>
6
7 <xsl:param name="keyword.namespace" select="'Atmel.Language.C'"/>
8
9 <xsl:template name="generate.book.title">
10 <xsl:text>LUFA Library</xsl:text>
11 </xsl:template>
12
13 <xsl:template name="generate.book.id">
14 <xsl:param name="book.title"/>
15 <xsl:choose>
16 <xsl:when test="@id">
17 <xsl:value-of select="@id"/>
18 </xsl:when>
19 <xsl:otherwise>
20 <xsl:value-of select="translate($book.title, ' ','')"/>
21 </xsl:otherwise>
22 </xsl:choose>
23 </xsl:template>
24
25 <xsl:template name="generate.index.id">
26 <xsl:param name="name"/>
27 <xsl:variable name="book.title">
28 <xsl:call-template name="generate.book.title"/>
29 </xsl:variable>
30 <xsl:variable name="book.id">
31 <xsl:call-template name="generate.book.id">
32 <xsl:with-param name="book.title" select="$book.title"/>
33 </xsl:call-template>
34 </xsl:variable>
35
36 <indexterm id="{$keyword.namespace}.{$name}">
37 <primary>
38 <xsl:value-of select="$book.title"/>
39 </primary>
40 <secondary>
41 <xsl:value-of select="$name"/>
42 </secondary>
43 </indexterm>
44 </xsl:template>
45
46 <xsl:template match="doxygen">
47 <xsl:variable name="book.title">
48 <xsl:call-template name="generate.book.title"/>
49 </xsl:variable>
50
51 <xsl:variable name="book.id">
52 <xsl:call-template name="generate.book.id">
53 <xsl:with-param name="book.title" select="$book.title"/>
54 </xsl:call-template>
55 </xsl:variable>
56
57 <book id="{$book.id}">
58 <title>
59 <xsl:value-of select="$book.title"/>
60 </title>
61
62 <!-- Add index chapter -->
63 <xsl:call-template name="generate.top.level.page">
64 <xsl:with-param name="top.level.page" select="compounddef[@kind = 'page' and @id = 'indexpage']"/>
65 <xsl:with-param name="top.level.page.title" select="'Library Information'"/>
66 </xsl:call-template>
67
68 <!-- Add free-floating chapters -->
69 <xsl:for-each select="compounddef[@kind = 'page' and not(@id = 'indexpage')]">
70 <xsl:if test="not(//innerpage/@refid = current()/@id)">
71 <xsl:call-template name="generate.top.level.page">
72 <xsl:with-param name="top.level.page" select="current()"/>
73 </xsl:call-template>
74 </xsl:if>
75 </xsl:for-each>
76
77 <!-- Add Modules chapter -->
78 <chapter>
79 <title>Modules</title>
80 <xsl:for-each select="compounddef[@kind = 'group']">
81 <xsl:if test="not(//innergroup/@refid = current()/@id)">
82 <xsl:apply-templates select="current()"/>
83 </xsl:if>
84 </xsl:for-each>
85 </chapter>
86 </book>
87 </xsl:template>
88
89 <xsl:template name="generate.top.level.page">
90 <xsl:param name="top.level.page"/>
91 <xsl:param name="top.level.page.title" select="$top.level.page/title"/>
92
93 <chapter id="{$top.level.page/@id}">
94 <title>
95 <xsl:value-of select="$top.level.page.title"/>
96 </title>
97
98 <xsl:apply-templates select="$top.level.page/detaileddescription"/>
99
100 <xsl:for-each select="$top.level.page/innerpage">
101 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
102 </xsl:for-each>
103 </chapter>
104 </xsl:template>
105
106 <xsl:template match="compounddef[@kind = 'page']">
107 <section id="{@id}">
108 <title>
109 <xsl:value-of select="title"/>
110 </title>
111
112 <xsl:apply-templates select="detaileddescription"/>
113
114 <xsl:for-each select="innerpage">
115 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
116 </xsl:for-each>
117 </section>
118 </xsl:template>
119
120 <xsl:template match="compounddef[@kind = 'group']">
121 <section id="{@id}">
122 <title>
123 <xsl:value-of select="title"/>
124 </title>
125
126 <xsl:variable name="name">
127 <xsl:value-of select="translate(compoundname, '_', '/')"/>
128 <xsl:text>.h</xsl:text>
129 </xsl:variable>
130
131 <xsl:variable name="name.escaped">
132 <xsl:value-of select="translate(compoundname, '_', '.')"/>
133 <xsl:text>.h</xsl:text>
134 </xsl:variable>
135
136 <indexterm id="{$keyword.namespace}.{$name.escaped}">
137 <primary>Header</primary>
138 <secondary>
139 <xsl:value-of select="$name"/>
140 </secondary>
141 </indexterm>
142
143 <xsl:call-template name="generate.index.id">
144 <xsl:with-param name="name" select="$name"/>
145 </xsl:call-template>
146
147 <indexterm>
148 <primary>
149 <xsl:value-of select="$name"/>
150 </primary>
151 </indexterm>
152
153 <xsl:apply-templates select="detaileddescription"/>
154
155 <xsl:apply-templates select="sectiondef"/>
156
157 <xsl:for-each select="innerclass">
158 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
159 </xsl:for-each>
160
161 <xsl:for-each select="innergroup">
162 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'group' and @id = current()/@refid]"/>
163 </xsl:for-each>
164 </section>
165 </xsl:template>
166
167 <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
168 <xsl:variable name="name" select="compoundname"/>
169
170 <section id="{@id}" xreflabel="{$name}">
171 <title>
172 <xsl:choose>
173 <xsl:when test="@kind = 'struct'">
174 <xsl:text>Struct </xsl:text>
175 </xsl:when>
176
177 <xsl:when test="@kind = 'union'">
178 <xsl:text>Union </xsl:text>
179 </xsl:when>
180 </xsl:choose>
181
182 <xsl:value-of select="$name"/>
183 </title>
184
185 <xsl:call-template name="generate.index.id">
186 <xsl:with-param name="name" select="$name"/>
187 </xsl:call-template>
188
189 <xsl:apply-templates select="detaileddescription"/>
190
191 <xsl:for-each select="sectiondef[@kind = 'public-attrib']">
192 <table tabstyle="striped">
193 <title>
194 <xsl:value-of select="$name"/>
195 </title>
196 <tgroup cols="3">
197 <colspec colnum="1" colname="start.col"/>
198 <colspec colnum="3" colname="stop.col"/>
199 <spanspec spanname="full" namest="start.col" nameend="stop.col"/>
200 <thead>
201 <row>
202 <entry>Type</entry>
203 <entry>Name</entry>
204 <entry>Description</entry>
205 </row>
206 </thead>
207 <tbody>
208 <xsl:for-each select="memberdef">
209 <row id="{@id}" xreflabel="{name}">
210 <entry>
211 <xsl:value-of select="type"/>
212 </entry>
213 <entry>
214 <xsl:value-of select="name"/>
215 <xsl:if test="starts-with(argsstring, '[')">
216 <xsl:text>[]</xsl:text>
217 </xsl:if>
218 <indexterm id="{$keyword.namespace}.{$name}.{name}"/>
219 </entry>
220 <entry>
221 <xsl:apply-templates select="detaileddescription"/>
222 </entry>
223 </row>
224 </xsl:for-each>
225 </tbody>
226 </tgroup>
227 </table>
228 </xsl:for-each>
229 </section>
230 </xsl:template>
231
232 <xsl:template match="memberdef[@kind = 'function']">
233 <section id="{@id}" xreflabel="{name}">
234 <title>
235 <xsl:text>Function </xsl:text>
236 <xsl:value-of select="name"/>
237 <xsl:text>()</xsl:text>
238 </title>
239
240 <xsl:call-template name="generate.index.id">
241 <xsl:with-param name="name" select="name"/>
242 </xsl:call-template>
243
244 <para>
245 <emphasis role="italic">
246 <xsl:value-of select="briefdescription"/>
247 </emphasis>
248 </para>
249
250 <programlisting language="c">
251 <emphasis role="keyword">
252 <xsl:value-of select="type"/>
253 </emphasis>
254 <xsl:text> </xsl:text>
255 <xsl:value-of select="name"/>
256 <xsl:text>(</xsl:text>
257
258 <xsl:choose>
259 <xsl:when test="not(param[1]/declname)">
260 <emphasis role="keyword">void</emphasis>
261 </xsl:when>
262
263 <xsl:otherwise>
264 <xsl:for-each select="param">
265 <xsl:if test="position() > 1">
266 <xsl:text>,</xsl:text>
267 </xsl:if>
268 <xsl:text>&#10;&#9;</xsl:text>
269 <emphasis role="keyword">
270 <xsl:value-of select="type"/>
271 </emphasis>
272 <xsl:text> </xsl:text>
273 <xsl:value-of select="declname"/>
274 </xsl:for-each>
275 </xsl:otherwise>
276 </xsl:choose>
277
278 <xsl:text>)</xsl:text>
279 </programlisting>
280
281 <xsl:apply-templates select="detaileddescription"/>
282 </section>
283 </xsl:template>
284
285 <xsl:template match="memberdef[@kind = 'enum']">
286 <section id="{@id}" xreflabel="{name}">
287 <title>
288 <xsl:text>Enum </xsl:text>
289 <xsl:value-of select="name"/>
290 </title>
291
292 <xsl:call-template name="generate.index.id">
293 <xsl:with-param name="name" select="name"/>
294 </xsl:call-template>
295
296 <xsl:apply-templates select="detaileddescription"/>
297
298 <table tabstyle="striped">
299 <title>Members</title>
300 <tgroup cols="2">
301 <thead>
302 <row>
303 <entry>Enum Value</entry>
304 <entry>Description</entry>
305 </row>
306 </thead>
307 <tbody>
308 <xsl:for-each select="enumvalue">
309 <row>
310 <entry>
311 <para id="{@id}" xreflabel="{name}">
312 <xsl:value-of select="name"/>
313 <indexterm id="{$keyword.namespace}.{name}"/>
314 </para>
315 </entry>
316 <entry>
317 <xsl:apply-templates select="detaileddescription"/>
318 </entry>
319 </row>
320 </xsl:for-each>
321 </tbody>
322 </tgroup>
323 </table>
324 </section>
325 </xsl:template>
326
327 <xsl:template match="memberdef[@kind = 'define']">
328 <section id="{@id}" xreflabel="{name}">
329 <title>
330 <xsl:text>Macro </xsl:text>
331 <xsl:value-of select="name"/>
332 </title>
333
334 <xsl:call-template name="generate.index.id">
335 <xsl:with-param name="name" select="name"/>
336 </xsl:call-template>
337
338 <programlisting language="c">
339 <emphasis role="preprocessor">
340 <xsl:text>#define </xsl:text>
341 <xsl:value-of select="name"/>
342 <xsl:if test="count(param) > 0">
343 <xsl:text>(</xsl:text>
344 <xsl:for-each select="param/defname">
345 <xsl:if test="position() > 1">
346 <xsl:text>,</xsl:text>
347 </xsl:if>
348 <xsl:value-of select="."/>
349 </xsl:for-each>
350 <xsl:text>)</xsl:text>
351 </xsl:if>
352 <xsl:text> </xsl:text>
353
354 <!-- Split long macro definitions across multiple lines -->
355 <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">
356 <xsl:text>\&#10;&#9;</xsl:text>
357 </xsl:if>
358
359 <xsl:value-of select="initializer"/>
360 </emphasis>
361 <xsl:text> </xsl:text>
362 </programlisting>
363
364 <xsl:apply-templates select="detaileddescription"/>
365 </section>
366 </xsl:template>
367
368 <xsl:template match="memberdef[@kind = 'variable' or @kind = 'typedef']">
369 <section id="{@id}" xreflabel="{name}">
370 <!-- Doxygen gets confused and thinks function pointer type definitions
371 are variables, so we need to map them to this common section and
372 check the definition to see which of the two it is. -->
373 <xsl:choose>
374 <xsl:when test="contains(definition, 'typedef')">
375 <title>
376 <xsl:text>Type </xsl:text>
377 <xsl:value-of select="name"/>
378 </title>
379
380 <xsl:call-template name="generate.index.id">
381 <xsl:with-param name="name" select="name"/>
382 </xsl:call-template>
383
384 <programlisting language="c">
385 <emphasis role="keyword">
386 <xsl:text>typedef </xsl:text>
387 <xsl:value-of select="type"/>
388 </emphasis>
389 <xsl:text> </xsl:text>
390 <xsl:value-of select="name"/>
391 <xsl:text> </xsl:text>
392 <xsl:value-of select="argsstring"/>
393 </programlisting>
394 </xsl:when>
395
396 <xsl:otherwise>
397 <title>
398 <xsl:text>Variable </xsl:text>
399 <xsl:value-of select="name"/>
400 </title>
401
402 <xsl:call-template name="generate.index.id">
403 <xsl:with-param name="name" select="name"/>
404 </xsl:call-template>
405
406 <programlisting language="c">
407 <emphasis role="keyword">
408 <xsl:value-of select="type"/>
409 </emphasis>
410 <xsl:text> </xsl:text>
411 <xsl:value-of select="name"/>
412 </programlisting>
413 </xsl:otherwise>
414 </xsl:choose>
415
416 <xsl:apply-templates select="detaileddescription"/>
417 </section>
418 </xsl:template>
419
420 <xsl:template match="linebreak | simplesectsep">
421 <literallayout>
422 </literallayout>
423 </xsl:template>
424
425 <xsl:template match="verbatim">
426 <programlisting>
427 <xsl:apply-templates/>
428 </programlisting>
429 </xsl:template>
430
431 <xsl:template match="sectiondef">
432 <para>
433 <xsl:value-of select="description"/>
434 </para>
435
436 <xsl:apply-templates select="memberdef"/>
437 </xsl:template>
438
439 <xsl:template match="simplesect" mode="struct">
440 <footnote>
441 <xsl:apply-templates/>
442 </footnote>
443 </xsl:template>
444
445 <xsl:template match="simplesect">
446 <xsl:choose>
447 <xsl:when test="@kind = 'par'">
448 <note>
449 <title>
450 <xsl:value-of select="title"/>
451 </title>
452 <xsl:apply-templates/>
453 </note>
454 </xsl:when>
455
456 <xsl:when test="@kind = 'return'">
457 <note>
458 <title>Returns</title>
459 <xsl:apply-templates/>
460 </note>
461 </xsl:when>
462
463 <xsl:when test="@kind = 'warning'">
464 <warning>
465 <title>Warning</title>
466 <xsl:apply-templates/>
467 </warning>
468 </xsl:when>
469
470 <xsl:when test="@kind = 'pre'">
471 <note>
472 <title>Precondition</title>
473 <xsl:apply-templates/>
474 </note>
475 </xsl:when>
476
477 <xsl:when test="@kind = 'see'">
478 <note>
479 <title>See also</title>
480 <xsl:apply-templates/>
481 </note>
482 </xsl:when>
483
484 <xsl:when test="@kind = 'note'">
485 <note>
486 <title>Note</title>
487 <xsl:apply-templates/>
488 </note>
489 </xsl:when>
490
491 </xsl:choose>
492 </xsl:template>
493
494 <xsl:template match="parameterlist[@kind = 'param']">
495 <table tabstyle="striped">
496 <title>Parameters</title>
497 <tgroup cols="3">
498 <thead>
499 <row>
500 <entry>Data Direction</entry>
501 <entry>Parameter Name</entry>
502 <entry>Description</entry>
503 </row>
504 </thead>
505 <tbody>
506 <xsl:for-each select="parameteritem">
507 <row>
508 <xsl:apply-templates select="."/>
509 </row>
510 </xsl:for-each>
511 </tbody>
512 </tgroup>
513 </table>
514 </xsl:template>
515
516 <xsl:template match="parameterlist[@kind = 'retval']">
517 <table tabstyle="striped">
518 <title>Return Values</title>
519 <tgroup cols="2">
520 <thead>
521 <row>
522 <entry>Return Value</entry>
523 <entry>Description</entry>
524 </row>
525 </thead>
526 <tbody>
527 <xsl:for-each select="parameteritem">
528 <row>
529 <xsl:apply-templates select="."/>
530 </row>
531 </xsl:for-each>
532 </tbody>
533 </tgroup>
534 </table>
535 </xsl:template>
536
537 <xsl:template match="parameteritem">
538 <xsl:if test="parent::parameterlist/@kind = 'param'">
539 <entry>
540 <para>
541 <xsl:choose>
542 <xsl:when test="not(descendant::parametername/@direction)">
543 <emphasis role="italic">?</emphasis>
544 </xsl:when>
545
546 <xsl:otherwise>
547 <emphasis role="bold">
548 [<xsl:value-of select="descendant::parametername/@direction"/>]
549 </emphasis>
550 </xsl:otherwise>
551 </xsl:choose>
552 </para>
553 </entry>
554 </xsl:if>
555
556 <entry>
557 <para>
558 <xsl:value-of select="parameternamelist/parametername"/>
559 </para>
560 </entry>
561
562 <entry>
563 <xsl:apply-templates select="parameterdescription"/>
564 </entry>
565 </xsl:template>
566
567 <xsl:template match="parameterdescription">
568 <para>
569 <xsl:apply-templates/>
570 </para>
571 </xsl:template>
572
573 <xsl:template match="type">
574 <xsl:apply-templates/>
575 </xsl:template>
576
577 <xsl:template match="bold">
578 <emphasis role="bold">
579 <xsl:apply-templates/>
580 </emphasis>
581 </xsl:template>
582
583 <xsl:template match="emphasis">
584 <emphasis role="italic">
585 <xsl:apply-templates/>
586 </emphasis>
587 </xsl:template>
588
589 <xsl:template match="small">
590 <xsl:apply-templates/>
591 </xsl:template>
592
593 <xsl:template match="mdash | ndash">
594 <xsl:text>--</xsl:text>
595 </xsl:template>
596
597 <xsl:template match="computeroutput | preformatted">
598 <computeroutput>
599 <xsl:apply-templates/>
600 </computeroutput>
601 </xsl:template>
602
603 <xsl:template match="codeline">
604 <xsl:apply-templates/>
605 </xsl:template>
606
607 <xsl:template match="ulink">
608 <ulink url="{@url}">
609 <xsl:value-of select="."/>
610 </ulink>
611 </xsl:template>
612
613 <xsl:template match="superscript">
614 <superscript>
615 <xsl:apply-templates/>
616 </superscript>
617 </xsl:template>
618
619 <xsl:template match="subscript">
620 <subscript>
621 <xsl:apply-templates/>
622 </subscript>
623 </xsl:template>
624
625 <xsl:template match="para">
626 <para>
627 <xsl:apply-templates/>
628 </para>
629 </xsl:template>
630
631 <xsl:template match="ref">
632 <xsl:choose>
633 <!-- Don't show links inside program listings -->
634 <xsl:when test="ancestor::programlisting">
635 <xsl:value-of select="."/>
636 </xsl:when>
637
638 <!-- Don't show links to file compound definitions, as they are discarded -->
639 <xsl:when test="ancestor::*/compounddef[@kind = 'file' and @id = current()/@refid]">
640 <xsl:value-of select="."/>
641 </xsl:when>
642
643 <!-- Show links outside program listings -->
644 <xsl:otherwise>
645 <link linkend="{@refid}">
646 <xsl:value-of select="text()"/>
647 </link>
648 </xsl:otherwise>
649 </xsl:choose>
650 </xsl:template>
651
652 <xsl:template match="entry">
653 <entry>
654 <xsl:apply-templates/>
655 </entry>
656 </xsl:template>
657
658 <xsl:template match="table">
659 <xsl:choose>
660 <xsl:when test="caption">
661 <table tabstyle="striped">
662 <title>
663 <xsl:value-of select="caption"/>
664 </title>
665
666 <xsl:call-template name="write.table.content"/>
667 </table>
668 </xsl:when>
669
670 <xsl:otherwise>
671 <informaltable tabstyle="striped">
672 <xsl:call-template name="write.table.content"/>
673 </informaltable>
674 </xsl:otherwise>
675 </xsl:choose>
676 </xsl:template>
677
678 <xsl:template name="write.table.content">
679 <tgroup cols="{@cols}">
680 <thead>
681 <xsl:for-each select="row[1]">
682 <row>
683 <xsl:apply-templates select="entry"/>
684 </row>
685 </xsl:for-each>
686 </thead>
687 <tbody>
688 <xsl:for-each select="row[position() != 1]">
689 <row>
690 <xsl:apply-templates select="entry"/>
691 </row>
692 </xsl:for-each>
693 </tbody>
694 </tgroup>
695 </xsl:template>
696
697 <xsl:template match="itemizedlist">
698 <itemizedlist>
699 <xsl:apply-templates/>
700 </itemizedlist>
701 </xsl:template>
702
703 <xsl:template match="orderedlist">
704 <orderedlist>
705 <xsl:apply-templates/>
706 </orderedlist>
707 </xsl:template>
708
709 <xsl:template match="listitem">
710 <listitem>
711 <xsl:apply-templates/>
712 </listitem>
713 </xsl:template>
714
715 <xsl:template match="programlisting">
716 <programlisting language="c">
717 <xsl:for-each select="codeline[position() > 1 or highlight]">
718 <xsl:apply-templates select="."/>
719 <xsl:text>&#10;</xsl:text>
720 </xsl:for-each>
721 </programlisting>
722 </xsl:template>
723
724 <xsl:template match="highlight">
725 <emphasis role="{@class}">
726 <xsl:apply-templates/>
727 </emphasis>
728 </xsl:template>
729
730 <xsl:template match="sp[ancestor::codeline]">
731 <xsl:text> </xsl:text>
732 </xsl:template>
733
734 <xsl:template match="image">
735 <mediaobject>
736 <imageobject>
737 <imagedata align="center">
738 <xsl:attribute name="fileref">
739 <xsl:text>images/</xsl:text>
740 <xsl:value-of select="@name"/>
741 </xsl:attribute>
742 </imagedata>
743 </imageobject>
744 </mediaobject>
745 </xsl:template>
746
747 <xsl:template match="detaileddescription">
748 <xsl:apply-templates/>
749 </xsl:template>
750
751 <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
752 <section>
753 <xsl:if test="@id">
754 <xsl:attribute name="id">
755 <xsl:value-of select="@id"/>
756 </xsl:attribute>
757 </xsl:if>
758
759 <title>
760 <xsl:value-of select="title"/>
761 </title>
762
763 <xsl:apply-templates/>
764 </section>
765 </xsl:template>
766
767 <xsl:template match="anchor">
768 <xsl:if test="@id">
769 <indexterm id="{@id}"/>
770 </xsl:if>
771 </xsl:template>
772
773 <xsl:template match="title"/>
774
775 <xsl:template match="htmlonly"/>
776
777 <xsl:template match="*">
778 <xsl:message>NO XSL TEMPLATE MATCH: <xsl:value-of select="name()"/></xsl:message>
779 </xsl:template>
780
781 </xsl:stylesheet>