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