53dd82f9a882a3c0b1086fcad116e9f44b4943e8
[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="yes"/>
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 match="doxygen">
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 <book name="{$book.id}">
37 <title>
38 <xsl:value-of select="$book.title"/>
39 </title>
40
41 <!-- Add index chapter -->
42 <xsl:call-template name="generate.top.level.page">
43 <xsl:with-param name="top.level.page" select="compounddef[@kind = 'page' and contains(@id, 'index')]"/>
44 </xsl:call-template>
45
46 <!-- Add free-floating chapters -->
47 <xsl:for-each select="compounddef[@kind = 'page' and not(contains(@id, 'index'))]">
48 <xsl:if test="not(//innerpage[@refid = current()/@id])">
49 <xsl:call-template name="generate.top.level.page">
50 <xsl:with-param name="top.level.page" select="current()"/>
51 </xsl:call-template>
52 </xsl:if>
53 </xsl:for-each>
54
55 <!-- Add Module chapter -->
56 <chapter>
57 <title>Modules</title>
58 <xsl:for-each select="compounddef[@kind = 'group']">
59 <xsl:if test="not(//innergroup[@refid = current()/@id])">
60 <xsl:apply-templates select="current()"/>
61 </xsl:if>
62 </xsl:for-each>
63 </chapter>
64 </book>
65 </xsl:template>
66
67 <xsl:template name="generate.top.level.page">
68 <xsl:param name="top.level.page"/>
69
70 <chapter id="{$top.level.page/@id}">
71 <title>
72 <xsl:value-of select="$top.level.page/title"/>
73 </title>
74 <xsl:apply-templates select="$top.level.page/detaileddescription"/>
75
76 <xsl:for-each select="$top.level.page/innerpage">
77 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
78 </xsl:for-each>
79 </chapter>
80 </xsl:template>
81
82 <xsl:template match="compounddef[@kind = 'page']">
83 <section id="{@id}">
84 <title>
85 <xsl:value-of select="title"/>
86 </title>
87 <xsl:apply-templates select="detaileddescription"/>
88
89 <xsl:for-each select="innerpage">
90 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
91 </xsl:for-each>
92 </section>
93 </xsl:template>
94
95 <xsl:template match="compounddef[@kind = 'group']">
96 <section id="{@id}">
97 <title>
98 <xsl:value-of select="title"/>
99 </title>
100
101 <xsl:variable name="book.title">
102 <xsl:call-template name="generate.book.title"/>
103 </xsl:variable>
104
105 <xsl:variable name="name">
106 <xsl:choose>
107 <xsl:when test="contains(compoundname, '_')">
108 <xsl:value-of select="translate(compoundname, '_', '/')"/>
109 <xsl:text>.h</xsl:text>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:value-of select="compoundname"/>
113 <xsl:text>.h</xsl:text>
114 </xsl:otherwise>
115 </xsl:choose>
116 </xsl:variable>
117
118 <xsl:variable name="name.escaped">
119 <xsl:choose>
120 <xsl:when test="contains(compoundname, '_')">
121 <xsl:value-of select="translate(compoundname, '_', '.')"/>
122 <xsl:text>.h</xsl:text>
123 </xsl:when>
124 <xsl:otherwise>
125 <xsl:value-of select="compoundname"/>
126 <xsl:text>.h</xsl:text>
127 </xsl:otherwise>
128 </xsl:choose>
129 </xsl:variable>
130
131 <indexterm id="{$keyword.namespace}.{$name.escaped}">
132 <primary>Header</primary>
133 <secondary>
134 <xsl:value-of select="$name"/>
135 </secondary>
136 </indexterm>
137 <indexterm>
138 <primary>
139 <xsl:value-of select="$book.title"/>
140 </primary>
141 <secondary>
142 <xsl:value-of select="$name"/>
143 </secondary>
144 </indexterm>
145 <indexterm>
146 <primary>
147 <xsl:value-of select="$name"/>
148 </primary>
149 </indexterm>
150
151 <xsl:apply-templates/>
152 <xsl:for-each select="innerclass">
153 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
154 </xsl:for-each>
155
156 <xsl:for-each select="innergroup">
157 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'group' and @id = current()/@refid]"/>
158 </xsl:for-each>
159 </section>
160 </xsl:template>
161
162 <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
163 <xsl:variable name="name" select="compoundname"/>
164 <xsl:variable name="book.title">
165 <xsl:call-template name="generate.book.title"/>
166 </xsl:variable>
167 <xsl:variable name="book.id">
168 <xsl:call-template name="generate.book.id">
169 <xsl:with-param name="book.title" select="$book.title"/>
170 </xsl:call-template>
171 </xsl:variable>
172
173 <section id="{@id}" xreflabel="{$name}">
174 <title>
175 <xsl:value-of select="@kind"/>
176 <xsl:text> </xsl:text>
177 <xsl:value-of select="$name"/>
178 </title>
179
180 <indexterm id="{$keyword.namespace}.{$name}">
181 <primary>
182 <xsl:value-of select="$book.title"/>
183 </primary>
184 <secondary>
185 <xsl:value-of select="$name"/>
186 </secondary>
187 </indexterm>
188
189 <xsl:apply-templates select="detaileddescription"/>
190 <xsl:for-each select="sectiondef[@kind='public-attrib']">
191 <table abstyle="striped">
192 <title>
193 <xsl:value-of select="$name"/>
194 </title>
195 <tgroup cols="3">
196 <colspec colnum="1" colname="start.col"/>
197 <colspec colnum="3" colname="stop.col"/>
198 <spanspec spanname="full" namest="start.col" nameend="stop.col"/>
199 <thead>
200 <row>
201 <entry>Data type</entry>
202 <entry>Field name</entry>
203 <entry>Description</entry>
204 </row>
205 </thead>
206 <tbody>
207 <xsl:for-each select="memberdef">
208 <row id="{@id}" xreflabel="{name}">
209 <entry>
210 <xsl:apply-templates select="type"/>
211 </entry>
212 <entry>
213 <xsl:value-of select="name"/>
214 <indexterm id="{$keyword.namespace}.{$name}.{name}"/>
215 </entry>
216 <entry>
217 <xsl:apply-templates select="detaileddescription"/>
218 </entry>
219 </row>
220 </xsl:for-each>
221 </tbody>
222 </tgroup>
223 </table>
224 </xsl:for-each>
225 </section>
226 </xsl:template>
227
228 <xsl:template match="linebreak">
229 <xsl:text>&#10;</xsl:text>
230 </xsl:template>
231
232 <xsl:template match="image">
233 <figure>
234 <title>
235 <xsl:value-of select="."/>
236 </title>
237
238 <mediaobject>
239 <imageobject>
240 <imagedata>
241 <xsl:attribute name="fileref">images/<xsl:value-of select="@name"/></xsl:attribute>
242 </imagedata>
243 </imageobject>
244 </mediaobject>
245 </figure>
246 </xsl:template>
247
248 <xsl:template match="detaileddescription">
249 <xsl:apply-templates/>
250 </xsl:template>
251
252 <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
253 <section>
254 <xsl:if test="@id">
255 <xsl:attribute name="id">
256 <xsl:value-of select="@id"/>
257 </xsl:attribute>
258 </xsl:if>
259
260 <title>
261 <xsl:value-of select="title"/>
262 </title>
263
264 <xsl:apply-templates/>
265 </section>
266 </xsl:template>
267
268 <xsl:template match="anchor">
269 <xsl:if test="@id">
270 <indexterm id="{@id}"/>
271 </xsl:if>
272 </xsl:template>
273
274 <xsl:template match="compoundname"/>
275
276 <xsl:template match="title"/>
277
278 <xsl:template match="indexterm"/>
279
280 <xsl:template match="indexentry">
281 <xsl:variable name="prim">
282 <xsl:choose>
283 <xsl:when test="contains(primaryie, ',')">
284 <xsl:value-of select="normalize-space(substring-before(primaryie, ','))"/>
285 </xsl:when>
286 <xsl:otherwise>
287 <xsl:value-of select="primaryie"/>
288 </xsl:otherwise>
289 </xsl:choose>
290 </xsl:variable>
291
292 <xsl:variable name="sec">
293 <xsl:choose>
294 <xsl:when test="contains(primaryie, ',')">
295 <xsl:value-of select="normalize-space(substring-after(primaryie, ','))"/>
296 </xsl:when>
297 <xsl:when test="seondariye">
298 <xsl:value-of select="secondaryie"/>
299 </xsl:when>
300 <xsl:otherwise/>
301 </xsl:choose>
302 </xsl:variable>
303
304 <xsl:variable name="tert">
305 <xsl:choose>
306 <xsl:when test="contains(primaryie, ',')">
307 <xsl:choose>
308 <xsl:when test="secondaryie">
309 <xsl:value-of select="secondaryie"/>
310 </xsl:when>
311 </xsl:choose>
312 </xsl:when>
313 <xsl:when test="tertiaryie">
314 <xsl:value-of select="tertiaryie"/>
315 </xsl:when>
316 <xsl:otherwise/>
317 </xsl:choose>
318 </xsl:variable>
319
320 <indexterm>
321 <xsl:if test="@id">
322 <xsl:attribute name="id">
323 <xsl:value-of select="@id"/>
324 </xsl:attribute>
325 </xsl:if>
326 <xsl:if test="$prim">
327 <primary>
328 <xsl:value-of select="$prim"/>
329 </primary>
330 </xsl:if>
331 <xsl:if test="$sec">
332 <secondary>
333 <xsl:value-of select="$sec"/>
334 </secondary>
335 </xsl:if>
336 <xsl:if test="$tert">
337 <tertiary>
338 <xsl:value-of select="$tert"/>
339 </tertiary>
340 </xsl:if>
341 </indexterm>
342 </xsl:template>
343 </xsl:stylesheet>