Add basic CSS styling to the Atmel Studio integrated help.
[pub/USBasp.git] / LUFA / StudioIntegration / HV1 / lufa_docbook_transform.xsl
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 <xsl:import href="transform_base.xsl"/>
5
6 <xsl:output method="xml" indent="no"/>
7
8 <xsl:param name="keyword.namespace" select="'Atmel.Language.C'"/>
9
10 <xsl:template name="generate.book.title">
11 <xsl:text>LUFA Library</xsl:text>
12 </xsl:template>
13
14 <xsl:template name="generate.book.id">
15 <xsl:param name="book.title"/>
16 <xsl:choose>
17 <xsl:when test="@id">
18 <xsl:value-of select="@id"/>
19 </xsl:when>
20 <xsl:otherwise>
21 <xsl:value-of select="translate($book.title, ' ','')"/>
22 </xsl:otherwise>
23 </xsl:choose>
24 </xsl:template>
25
26 <xsl:template name="generate.index.id">
27 <xsl:param name="name"/>
28 <xsl:variable name="book.title">
29 <xsl:call-template name="generate.book.title"/>
30 </xsl:variable>
31 <xsl:variable name="book.id">
32 <xsl:call-template name="generate.book.id">
33 <xsl:with-param name="book.title" select="$book.title"/>
34 </xsl:call-template>
35 </xsl:variable>
36
37 <indexterm id="{$keyword.namespace}.{$name}">
38 <primary>
39 <xsl:value-of select="$book.title"/>
40 </primary>
41 <secondary>
42 <xsl:value-of select="$name"/>
43 </secondary>
44 </indexterm>
45 </xsl:template>
46
47 <xsl:template match="doxygen">
48 <xsl:variable name="book.title">
49 <xsl:call-template name="generate.book.title"/>
50 </xsl:variable>
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 name="{$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 contains(@id, 'index')]"/>
65 </xsl:call-template>
66
67 <!-- Add free-floating chapters -->
68 <xsl:for-each select="compounddef[@kind = 'page' and not(contains(@id, 'index'))]">
69 <xsl:if test="not(//innerpage[@refid = current()/@id])">
70 <xsl:call-template name="generate.top.level.page">
71 <xsl:with-param name="top.level.page" select="current()"/>
72 </xsl:call-template>
73 </xsl:if>
74 </xsl:for-each>
75
76 <!-- Add Module chapter -->
77 <chapter>
78 <title>Modules</title>
79 <xsl:for-each select="compounddef[@kind = 'group']">
80 <xsl:if test="not(//innergroup[@refid = current()/@id])">
81 <xsl:apply-templates select="current()"/>
82 </xsl:if>
83 </xsl:for-each>
84 </chapter>
85 </book>
86 </xsl:template>
87
88 <xsl:template name="generate.top.level.page">
89 <xsl:param name="top.level.page"/>
90 <chapter id="{$top.level.page/@id}">
91 <title>
92 <xsl:value-of select="$top.level.page/title"/>
93 </title>
94 <xsl:apply-templates select="$top.level.page/detaileddescription"/>
95 <xsl:for-each select="$top.level.page/innerpage">
96 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
97 </xsl:for-each>
98 </chapter>
99 </xsl:template>
100
101 <xsl:template match="compounddef[@kind = 'page']">
102 <section id="{@id}">
103 <title>
104 <xsl:value-of select="title"/>
105 </title>
106 <xsl:apply-templates select="detaileddescription"/>
107 <xsl:for-each select="innerpage">
108 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
109 </xsl:for-each>
110 </section>
111 </xsl:template>
112
113 <xsl:template match="compounddef[@kind = 'group']">
114 <section id="{@id}">
115 <title>
116 <xsl:value-of select="title"/>
117 </title>
118
119 <xsl:variable name="book.title">
120 <xsl:call-template name="generate.book.title"/>
121 </xsl:variable>
122
123 <xsl:variable name="name">
124 <xsl:choose>
125 <xsl:when test="contains(compoundname, '_')">
126 <xsl:value-of select="translate(compoundname, '_', '/')"/>
127 <xsl:text>.h</xsl:text>
128 </xsl:when>
129 <xsl:otherwise>
130 <xsl:value-of select="compoundname"/>
131 <xsl:text>.h</xsl:text>
132 </xsl:otherwise>
133 </xsl:choose>
134 </xsl:variable>
135
136 <xsl:variable name="name.escaped">
137 <xsl:choose>
138 <xsl:when test="contains(compoundname, '_')">
139 <xsl:value-of select="translate(compoundname, '_', '.')"/>
140 <xsl:text>.h</xsl:text>
141 </xsl:when>
142 <xsl:otherwise>
143 <xsl:value-of select="compoundname"/>
144 <xsl:text>.h</xsl:text>
145 </xsl:otherwise>
146 </xsl:choose>
147 </xsl:variable>
148
149 <indexterm id="{$keyword.namespace}.{$name.escaped}">
150 <primary>Header</primary>
151 <secondary>
152 <xsl:value-of select="$name"/>
153 </secondary>
154 </indexterm>
155
156 <xsl:call-template name="generate.index.id">
157 <xsl:with-param name="name" select="$name"/>
158 </xsl:call-template>
159
160 <indexterm>
161 <primary>
162 <xsl:value-of select="$name"/>
163 </primary>
164 </indexterm>
165
166 <xsl:apply-templates select="detaileddescription" />
167
168 <xsl:apply-templates select="sectiondef" />
169
170 <xsl:for-each select="innerclass">
171 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
172 </xsl:for-each>
173
174 <xsl:for-each select="innergroup">
175 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'group' and @id = current()/@refid]"/>
176 </xsl:for-each>
177 </section>
178 </xsl:template>
179
180 <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
181 <xsl:variable name="name" select="compoundname"/>
182
183 <section id="{@id}" xreflabel="{$name}">
184 <title>
185 <xsl:value-of select="@kind"/>
186 <xsl:text> </xsl:text>
187 <xsl:value-of select="$name"/>
188 </title>
189
190 <xsl:call-template name="generate.index.id">
191 <xsl:with-param name="name" select="$name"/>
192 </xsl:call-template>
193
194 <xsl:apply-templates select="detaileddescription"/>
195
196 <xsl:for-each select="sectiondef[@kind='public-attrib']">
197 <table abstyle="striped">
198 <title>
199 <xsl:value-of select="$name"/>
200 </title>
201 <tgroup cols="3">
202 <colspec colnum="1" colname="start.col"/>
203 <colspec colnum="3" colname="stop.col"/>
204 <spanspec spanname="full" namest="start.col" nameend="stop.col"/>
205 <thead>
206 <row>
207 <entry>Data type</entry>
208 <entry>Field name</entry>
209 <entry>Description</entry>
210 </row>
211 </thead>
212 <tbody>
213 <xsl:for-each select="memberdef">
214 <row id="{@id}" xreflabel="{name}">
215 <entry>
216 <xsl:apply-templates select="type"/>
217 </entry>
218 <entry>
219 <xsl:value-of select="name"/>
220 <indexterm id="{$keyword.namespace}.{$name}.{name}"/>
221 </entry>
222 <entry>
223 <xsl:apply-templates select="detaileddescription"/>
224 </entry>
225 </row>
226 </xsl:for-each>
227 </tbody>
228 </tgroup>
229 </table>
230 </xsl:for-each>
231 </section>
232 </xsl:template>
233
234 <xsl:template match="memberdef[@kind = 'function']">
235 <xsl:variable name="name" select="name"/>
236
237 <section id="{@id}" xreflabel="{name}">
238 <title>
239 <xsl:text>Function </xsl:text>
240 <xsl:value-of select="name"/>
241 <xsl:text>()</xsl:text>
242 </title>
243
244 <xsl:call-template name="generate.index.id">
245 <xsl:with-param name="name" select="$name"/>
246 </xsl:call-template>
247
248 <para>
249 <emphasis role="italic">
250 <xsl:value-of select="briefdescription"/>
251 </emphasis>
252 </para>
253
254 <programlisting language="c">
255 <xsl:value-of select="definition"/>
256 <xsl:text> </xsl:text>
257 <xsl:apply-templates select="argsstring"/>
258 </programlisting>
259
260 <xsl:apply-templates select="detaileddescription"/>
261 </section>
262 </xsl:template>
263
264 <xsl:template match="memberdef[@kind = 'enum']">
265 <xsl:variable name="name" select="name"/>
266
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 <informaltable tabstyle="striped">
280 <tgroup cols="2">
281 <thead>
282 <row>
283 <entry>Enum Value</entry>
284 <entry>Description</entry>
285 </row>
286 </thead>
287 <tbody>
288 <xsl:for-each select="enumvalue">
289 <row>
290 <entry>
291 <para id="{@id}" xreflabel="{name}">
292 <xsl:value-of select="name"/>
293 </para>
294 </entry>
295 <entry>
296 <xsl:apply-templates select="detaileddescription"/>
297 </entry>
298 </row>
299 </xsl:for-each>
300 </tbody>
301 </tgroup>
302 </informaltable>
303 </section>
304 </xsl:template>
305
306 <xsl:template match="memberdef[@kind = 'define']">
307 <xsl:variable name="name" select="name"/>
308
309 <section id="{@id}" xreflabel="{name}">
310 <title>
311 <xsl:text>Macro </xsl:text>
312 <xsl:value-of select="name"/>
313 </title>
314
315 <xsl:call-template name="generate.index.id">
316 <xsl:with-param name="name" select="$name"/>
317 </xsl:call-template>
318
319 <programlisting language="c">
320 <xsl:text>#define </xsl:text>
321 <xsl:value-of select="name"/>
322 <xsl:if test="count(param) &gt; 0">
323 <xsl:text>(</xsl:text>
324 <xsl:for-each select="param/defname">
325 <xsl:if test="position() &gt; 1">
326 <xsl:text>,</xsl:text>
327 </xsl:if>
328 <xsl:value-of select="."/>
329 </xsl:for-each>
330 <xsl:text>)</xsl:text>
331 </xsl:if>
332
333 <xsl:text> </xsl:text>
334
335 <!-- Split long macro definitions across multiple lines -->
336 <xsl:if test="(string-length(initializer) &gt; 50) or (count(param) &gt; 0)">
337 <xsl:text>\</xsl:text>
338 </xsl:if>
339
340 <xsl:value-of select="initializer"/>
341 </programlisting>
342
343 <xsl:apply-templates select="detaileddescription"/>
344 </section>
345 </xsl:template>
346
347 <xsl:template match="memberdef[@kind = 'variable' or @kind = 'typedef']">
348 <xsl:variable name="name" select="name"/>
349
350 <section id="{@id}" xreflabel="{name}">
351 <title>
352 <!-- Doxygen gets confused and thinks function pointer type definitions
353 are variables, so we need to map them to this common section and
354 check the definition to see which of the two it is. -->
355 <xsl:choose>
356 <xsl:when test="contains(definition,'typedef')">
357 <xsl:text>Type </xsl:text>
358 </xsl:when>
359 <xsl:otherwise>
360 <xsl:text>Variable </xsl:text>
361 </xsl:otherwise>
362 </xsl:choose>
363
364 <xsl:value-of select="name"/>
365 </title>
366
367 <xsl:call-template name="generate.index.id">
368 <xsl:with-param name="name" select="$name"/>
369 </xsl:call-template>
370
371 <programlisting language="c">
372 <xsl:value-of select="definition"/>
373 </programlisting>
374
375 <xsl:apply-templates select="detaileddescription"/>
376 </section>
377 </xsl:template>
378
379 <xsl:template match="linebreak">
380 <xsl:text>&#10;</xsl:text>
381 </xsl:template>
382
383 <xsl:template match="image">
384 <figure>
385 <title>
386 <xsl:value-of select="."/>
387 </title>
388
389 <mediaobject>
390 <imageobject>
391 <imagedata>
392 <xsl:attribute name="fileref">images/<xsl:value-of select="@name"/></xsl:attribute>
393 </imagedata>
394 </imageobject>
395 </mediaobject>
396 </figure>
397 </xsl:template>
398
399 <xsl:template match="detaileddescription">
400 <xsl:apply-templates/>
401 </xsl:template>
402
403 <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
404 <section>
405 <xsl:if test="@id">
406 <xsl:attribute name="id">
407 <xsl:value-of select="@id"/>
408 </xsl:attribute>
409 </xsl:if>
410
411 <title>
412 <xsl:value-of select="title"/>
413 </title>
414
415 <xsl:apply-templates/>
416 </section>
417 </xsl:template>
418
419 <xsl:template match="anchor">
420 <xsl:if test="@id">
421 <indexterm id="{@id}"/>
422 </xsl:if>
423 </xsl:template>
424
425 <xsl:template match="title"/>
426
427 <xsl:template match="indexentry">
428 <xsl:variable name="prim">
429 <xsl:choose>
430 <xsl:when test="contains(primaryie, ',')">
431 <xsl:value-of select="normalize-space(substring-before(primaryie, ','))"/>
432 </xsl:when>
433 <xsl:otherwise>
434 <xsl:value-of select="primaryie"/>
435 </xsl:otherwise>
436 </xsl:choose>
437 </xsl:variable>
438
439 <xsl:variable name="sec">
440 <xsl:choose>
441 <xsl:when test="contains(primaryie, ',')">
442 <xsl:value-of select="normalize-space(substring-after(primaryie, ','))"/>
443 </xsl:when>
444 <xsl:when test="seondariye">
445 <xsl:value-of select="secondaryie"/>
446 </xsl:when>
447 <xsl:otherwise/>
448 </xsl:choose>
449 </xsl:variable>
450
451 <xsl:variable name="tert">
452 <xsl:choose>
453 <xsl:when test="contains(primaryie, ',')">
454 <xsl:choose>
455 <xsl:when test="secondaryie">
456 <xsl:value-of select="secondaryie"/>
457 </xsl:when>
458 </xsl:choose>
459 </xsl:when>
460 <xsl:when test="tertiaryie">
461 <xsl:value-of select="tertiaryie"/>
462 </xsl:when>
463 <xsl:otherwise/>
464 </xsl:choose>
465 </xsl:variable>
466
467 <indexterm>
468 <xsl:if test="@id">
469 <xsl:attribute name="id">
470 <xsl:value-of select="@id"/>
471 </xsl:attribute>
472 </xsl:if>
473 <xsl:if test="$prim">
474 <primary>
475 <xsl:value-of select="$prim"/>
476 </primary>
477 </xsl:if>
478 <xsl:if test="$sec">
479 <secondary>
480 <xsl:value-of select="$sec"/>
481 </secondary>
482 </xsl:if>
483 <xsl:if test="$tert">
484 <tertiary>
485 <xsl:value-of select="$tert"/>
486 </tertiary>
487 </xsl:if>
488 </indexterm>
489 </xsl:template>
490 </xsl:stylesheet>