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