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