Add missing indexterm entries to the Atmel Studio help transform.
[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 <indexterm>
156 <primary>
157 <xsl:value-of select="$book.title"/>
158 </primary>
159 <secondary>
160 <xsl:value-of select="$name"/>
161 </secondary>
162 </indexterm>
163 <indexterm>
164 <primary>
165 <xsl:value-of select="$name"/>
166 </primary>
167 </indexterm>
168 <xsl:apply-templates/>
169 <xsl:for-each select="innerclass">
170 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
171 </xsl:for-each>
172
173 <xsl:for-each select="innergroup">
174 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'group' and @id = current()/@refid]"/>
175 </xsl:for-each>
176 </section>
177 </xsl:template>
178
179 <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
180 <xsl:variable name="name" select="compoundname"/>
181
182 <section id="{@id}" xreflabel="{$name}">
183 <title>
184 <xsl:value-of select="@kind"/>
185 <xsl:text> </xsl:text>
186 <xsl:value-of select="$name"/>
187 </title>
188
189 <xsl:call-template name="generate.index.id">
190 <xsl:with-param name="name" select="$name"/>
191 </xsl:call-template>
192
193 <xsl:apply-templates select="detaileddescription"/>
194
195 <xsl:for-each select="sectiondef[@kind='public-attrib']">
196 <table abstyle="striped">
197 <title>
198 <xsl:value-of select="$name"/>
199 </title>
200 <tgroup cols="3">
201 <colspec colnum="1" colname="start.col"/>
202 <colspec colnum="3" colname="stop.col"/>
203 <spanspec spanname="full" namest="start.col" nameend="stop.col"/>
204 <thead>
205 <row>
206 <entry>Data type</entry>
207 <entry>Field name</entry>
208 <entry>Description</entry>
209 </row>
210 </thead>
211 <tbody>
212 <xsl:for-each select="memberdef">
213 <row id="{@id}" xreflabel="{name}">
214 <entry>
215 <xsl:apply-templates select="type"/>
216 </entry>
217 <entry>
218 <xsl:value-of select="name"/>
219 <indexterm id="{$keyword.namespace}.{$name}.{name}"/>
220 </entry>
221 <entry>
222 <xsl:apply-templates select="detaileddescription"/>
223 </entry>
224 </row>
225 </xsl:for-each>
226 </tbody>
227 </tgroup>
228 </table>
229 </xsl:for-each>
230 </section>
231 </xsl:template>
232
233 <xsl:template match="memberdef[@kind = 'function']">
234 <xsl:variable name="name" select="name"/>
235
236 <section id="{@id}" xreflabel="{name}">
237 <title>
238 <xsl:text>Function </xsl:text>
239 <xsl:value-of select="name"/>
240 <xsl:text>()</xsl:text>
241 </title>
242
243 <xsl:call-template name="generate.index.id">
244 <xsl:with-param name="name" select="$name"/>
245 </xsl:call-template>
246
247 <para>
248 <emphasis role="italic">
249 <xsl:value-of select="briefdescription"/>
250 </emphasis>
251 </para>
252
253 <programlisting language="c">
254 <xsl:value-of select="definition"/>
255 <xsl:text> </xsl:text>
256 <xsl:apply-templates select="argsstring"/>
257 </programlisting>
258
259 <xsl:apply-templates select="detaileddescription"/>
260 </section>
261 </xsl:template>
262
263 <xsl:template match="memberdef[@kind = 'enum']">
264 <xsl:variable name="name" select="name"/>
265
266 <section id="{@id}" xreflabel="{name}">
267 <title>
268 <xsl:text>Enum </xsl:text>
269 <xsl:value-of select="name"/>
270 </title>
271
272 <xsl:call-template name="generate.index.id">
273 <xsl:with-param name="name" select="$name"/>
274 </xsl:call-template>
275
276 <xsl:apply-templates select="detaileddescription"/>
277
278 <informaltable tabstyle="striped">
279 <tgroup cols="2">
280 <thead>
281 <row>
282 <entry>Enum Value</entry>
283 <entry>Description</entry>
284 </row>
285 </thead>
286 <tbody>
287 <xsl:for-each select="enumvalue">
288 <row>
289 <entry>
290 <para id="{@id}" xreflabel="{name}">
291 <xsl:value-of select="name"/>
292 </para>
293 </entry>
294 <entry>
295 <xsl:apply-templates select="detaileddescription"/>
296 </entry>
297 </row>
298 </xsl:for-each>
299 </tbody>
300 </tgroup>
301 </informaltable>
302 </section>
303 </xsl:template>
304
305 <xsl:template match="memberdef[@kind = 'define']">
306 <xsl:variable name="name" select="name"/>
307
308 <section id="{@id}" xreflabel="{name}">
309 <title>
310 <xsl:text>Macro </xsl:text>
311 <xsl:value-of select="name"/>
312 </title>
313
314 <xsl:call-template name="generate.index.id">
315 <xsl:with-param name="name" select="$name"/>
316 </xsl:call-template>
317
318 <programlisting language="c">
319 <xsl:text>#define </xsl:text>
320 <xsl:value-of select="name"/>
321 <xsl:if test="count(param) &gt; 0">
322 <xsl:text>(</xsl:text>
323 <xsl:for-each select="param/defname">
324 <xsl:if test="position() &gt; 1">
325 <xsl:text>,</xsl:text>
326 </xsl:if>
327 <xsl:value-of select="."/>
328 </xsl:for-each>
329 <xsl:text>)</xsl:text>
330 </xsl:if>
331
332 <xsl:text> </xsl:text>
333
334 <!-- Split long macro definitions across multiple lines -->
335 <xsl:if test="(string-length(initializer) &gt; 50) or (count(param) &gt; 0)">
336 <xsl:text>\</xsl:text>
337 </xsl:if>
338
339 <xsl:value-of select="initializer"/>
340 </programlisting>
341
342 <xsl:apply-templates select="detaileddescription"/>
343 </section>
344 </xsl:template>
345
346 <xsl:template match="memberdef[@kind = 'variable' or @kind = 'typedef']">
347 <xsl:variable name="name" select="name"/>
348
349 <section id="{@id}" xreflabel="{name}">
350 <title>
351 <!-- Doxygen gets confused and thinks function pointer type definitions
352 are variables, so we need to map them to this common section and
353 check the definition to see which of the two it is. -->
354 <xsl:choose>
355 <xsl:when test="contains(definition,'typedef')">
356 <xsl:text>Type </xsl:text>
357 </xsl:when>
358 <xsl:otherwise>
359 <xsl:text>Variable </xsl:text>
360 </xsl:otherwise>
361 </xsl:choose>
362
363 <xsl:value-of select="name"/>
364 </title>
365
366 <xsl:call-template name="generate.index.id">
367 <xsl:with-param name="name" select="$name"/>
368 </xsl:call-template>
369
370 <programlisting language="c">
371 <xsl:value-of select="definition"/>
372 </programlisting>
373
374 <xsl:apply-templates select="detaileddescription"/>
375 </section>
376 </xsl:template>
377
378 <xsl:template match="linebreak">
379 <xsl:text>&#10;</xsl:text>
380 </xsl:template>
381
382 <xsl:template match="image">
383 <figure>
384 <title>
385 <xsl:value-of select="."/>
386 </title>
387
388 <mediaobject>
389 <imageobject>
390 <imagedata>
391 <xsl:attribute name="fileref">images/<xsl:value-of select="@name"/></xsl:attribute>
392 </imagedata>
393 </imageobject>
394 </mediaobject>
395 </figure>
396 </xsl:template>
397
398 <xsl:template match="detaileddescription">
399 <xsl:apply-templates/>
400 </xsl:template>
401
402 <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
403 <section>
404 <xsl:if test="@id">
405 <xsl:attribute name="id">
406 <xsl:value-of select="@id"/>
407 </xsl:attribute>
408 </xsl:if>
409
410 <title>
411 <xsl:value-of select="title"/>
412 </title>
413 <xsl:apply-templates/>
414 </section>
415 </xsl:template>
416
417 <xsl:template match="anchor">
418 <xsl:if test="@id">
419 <indexterm id="{@id}"/>
420 </xsl:if>
421 </xsl:template>
422
423 <xsl:template match="compoundname"/>
424
425 <xsl:template match="title"/>
426
427 <xsl:template match="indexterm"/>
428
429 <xsl:template match="indexentry">
430 <xsl:variable name="prim">
431 <xsl:choose>
432 <xsl:when test="contains(primaryie, ',')">
433 <xsl:value-of select="normalize-space(substring-before(primaryie, ','))"/>
434 </xsl:when>
435 <xsl:otherwise>
436 <xsl:value-of select="primaryie"/>
437 </xsl:otherwise>
438 </xsl:choose>
439 </xsl:variable>
440
441 <xsl:variable name="sec">
442 <xsl:choose>
443 <xsl:when test="contains(primaryie, ',')">
444 <xsl:value-of select="normalize-space(substring-after(primaryie, ','))"/>
445 </xsl:when>
446 <xsl:when test="seondariye">
447 <xsl:value-of select="secondaryie"/>
448 </xsl:when>
449 <xsl:otherwise/>
450 </xsl:choose>
451 </xsl:variable>
452
453 <xsl:variable name="tert">
454 <xsl:choose>
455 <xsl:when test="contains(primaryie, ',')">
456 <xsl:choose>
457 <xsl:when test="secondaryie">
458 <xsl:value-of select="secondaryie"/>
459 </xsl:when>
460 </xsl:choose>
461 </xsl:when>
462 <xsl:when test="tertiaryie">
463 <xsl:value-of select="tertiaryie"/>
464 </xsl:when>
465 <xsl:otherwise/>
466 </xsl:choose>
467 </xsl:variable>
468
469 <indexterm>
470 <xsl:if test="@id">
471 <xsl:attribute name="id">
472 <xsl:value-of select="@id"/>
473 </xsl:attribute>
474 </xsl:if>
475 <xsl:if test="$prim">
476 <primary>
477 <xsl:value-of select="$prim"/>
478 </primary>
479 </xsl:if>
480 <xsl:if test="$sec">
481 <secondary>
482 <xsl:value-of select="$sec"/>
483 </secondary>
484 </xsl:if>
485 <xsl:if test="$tert">
486 <tertiary>
487 <xsl:value-of select="$tert"/>
488 </tertiary>
489 </xsl:if>
490 </indexterm>
491 </xsl:template>
492 </xsl:stylesheet>