Update Indonesian translation
[empathy-mirror.git] / tools / doc-generator.xsl
blob76fc96964a63d101d81846e5c9e6bd3500b199d3
1 <!-- Generate HTML documentation from the Telepathy specification.
2 The master copy of this stylesheet is in the Telepathy spec repository -
3 please make any changes there.
5 Copyright (C) 2006-2008 Collabora Limited
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 -->
22 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
23 xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
24 xmlns:html="http://www.w3.org/1999/xhtml"
25 exclude-result-prefixes="tp html">
26 <!--Don't move the declaration of the HTML namespace up here — XMLNSs
27 don't work ideally in the presence of two things that want to use the
28 absence of a prefix, sadly. -->
30 <xsl:param name="allow-undefined-interfaces" select="false()"/>
32 <xsl:template match="html:* | @*" mode="html">
33 <xsl:copy>
34 <xsl:apply-templates mode="html"/>
35 </xsl:copy>
36 </xsl:template>
38 <xsl:template match="tp:type" mode="html">
39 <xsl:call-template name="tp-type">
40 <xsl:with-param name="tp-type" select="string(.)"/>
41 </xsl:call-template>
42 </xsl:template>
44 <!-- tp:dbus-ref: reference a D-Bus interface, signal, method or property -->
45 <xsl:template match="tp:dbus-ref" mode="html">
46 <xsl:variable name="name">
47 <xsl:choose>
48 <xsl:when test="@namespace">
49 <xsl:value-of select="@namespace"/>
50 <xsl:text>.</xsl:text>
51 </xsl:when>
52 </xsl:choose>
53 <xsl:value-of select="string(.)"/>
54 </xsl:variable>
56 <xsl:choose>
57 <xsl:when test="//interface[@name=$name]
58 or //interface/method[concat(../@name, '.', @name)=$name]
59 or //interface/signal[concat(../@name, '.', @name)=$name]
60 or //interface/property[concat(../@name, '.', @name)=$name]
61 or //interface[@name=concat($name, '.DRAFT')]
62 or //interface/method[
63 concat(../@name, '.', @name)=concat($name, '.DRAFT')]
64 or //interface/signal[
65 concat(../@name, '.', @name)=concat($name, '.DRAFT')]
66 or //interface/property[
67 concat(../@name, '.', @name)=concat($name, '.DRAFT')]
69 <a xmlns="http://www.w3.org/1999/xhtml" href="#{$name}">
70 <xsl:value-of select="string(.)"/>
71 </a>
72 </xsl:when>
74 <xsl:when test="$allow-undefined-interfaces">
75 <span xmlns="http://www.w3.org/1999/xhtml" title="defined elsewhere">
76 <xsl:value-of select="string(.)"/>
77 </span>
78 </xsl:when>
80 <xsl:otherwise>
81 <xsl:message terminate="yes">
82 <xsl:text>ERR: cannot find D-Bus interface, method, </xsl:text>
83 <xsl:text>signal or property called '</xsl:text>
84 <xsl:value-of select="$name"/>
85 <xsl:text>'&#10;</xsl:text>
86 </xsl:message>
87 </xsl:otherwise>
88 </xsl:choose>
89 </xsl:template>
91 <!-- tp:member-ref: reference a property of the current interface -->
92 <xsl:template match="tp:member-ref" mode="html">
93 <xsl:variable name="prefix" select="concat(ancestor::interface/@name,
94 '.')"/>
95 <xsl:variable name="name" select="string(.)"/>
97 <xsl:if test="not(ancestor::interface)">
98 <xsl:message terminate="yes">
99 <xsl:text>ERR: Cannot use tp:member-ref when not in an</xsl:text>
100 <xsl:text> &lt;interface&gt;&#10;</xsl:text>
101 </xsl:message>
102 </xsl:if>
104 <xsl:choose>
105 <xsl:when test="ancestor::interface/signal[@name=$name]"/>
106 <xsl:when test="ancestor::interface/method[@name=$name]"/>
107 <xsl:when test="ancestor::interface/property[@name=$name]"/>
108 <xsl:otherwise>
109 <xsl:message terminate="yes">
110 <xsl:text>ERR: interface </xsl:text>
111 <xsl:value-of select="ancestor::interface/@name"/>
112 <xsl:text> has no signal/method/property called </xsl:text>
113 <xsl:value-of select="$name"/>
114 <xsl:text>&#10;</xsl:text>
115 </xsl:message>
116 </xsl:otherwise>
117 </xsl:choose>
119 <a xmlns="http://www.w3.org/1999/xhtml" href="#{$prefix}{$name}">
120 <xsl:value-of select="$name"/>
121 </a>
122 </xsl:template>
124 <xsl:template match="*" mode="identity">
125 <xsl:copy>
126 <xsl:apply-templates mode="identity"/>
127 </xsl:copy>
128 </xsl:template>
130 <xsl:template match="tp:docstring">
131 <xsl:apply-templates mode="html"/>
132 </xsl:template>
134 <xsl:template match="tp:added">
135 <p class="added" xmlns="http://www.w3.org/1999/xhtml">Added in
136 version <xsl:value-of select="@version"/>.
137 <xsl:apply-templates select="node()" mode="html"/></p>
138 </xsl:template>
140 <xsl:template match="tp:changed">
141 <xsl:choose>
142 <xsl:when test="node()">
143 <p class="changed" xmlns="http://www.w3.org/1999/xhtml">Changed in
144 version <xsl:value-of select="@version"/>:
145 <xsl:apply-templates select="node()" mode="html"/></p>
146 </xsl:when>
147 <xsl:otherwise>
148 <p class="changed">Changed in version
149 <xsl:value-of select="@version"/></p>
150 </xsl:otherwise>
151 </xsl:choose>
152 </xsl:template>
154 <xsl:template match="tp:deprecated">
155 <p class="deprecated" xmlns="http://www.w3.org/1999/xhtml">Deprecated
156 since version <xsl:value-of select="@version"/>.
157 <xsl:apply-templates select="node()" mode="html"/></p>
158 </xsl:template>
160 <xsl:template match="tp:rationale" mode="html">
161 <div xmlns="http://www.w3.org/1999/xhtml" class="rationale">
162 <xsl:apply-templates select="node()" mode="html"/>
163 </div>
164 </xsl:template>
166 <xsl:template match="tp:errors">
167 <h1 xmlns="http://www.w3.org/1999/xhtml">Errors</h1>
168 <xsl:apply-templates/>
169 </xsl:template>
171 <xsl:template match="tp:generic-types">
172 <h1 xmlns="http://www.w3.org/1999/xhtml">Generic types</h1>
173 <xsl:call-template name="do-types"/>
174 </xsl:template>
176 <xsl:template name="do-types">
177 <xsl:if test="tp:simple-type">
178 <h2 xmlns="http://www.w3.org/1999/xhtml">Simple types</h2>
179 <xsl:apply-templates select="tp:simple-type"/>
180 </xsl:if>
182 <xsl:if test="tp:enum">
183 <h2 xmlns="http://www.w3.org/1999/xhtml">Enumerated types:</h2>
184 <xsl:apply-templates select="tp:enum"/>
185 </xsl:if>
187 <xsl:if test="tp:flags">
188 <h2 xmlns="http://www.w3.org/1999/xhtml">Sets of flags:</h2>
189 <xsl:apply-templates select="tp:flags"/>
190 </xsl:if>
192 <xsl:if test="tp:struct">
193 <h2 xmlns="http://www.w3.org/1999/xhtml">Structure types</h2>
194 <xsl:apply-templates select="tp:struct"/>
195 </xsl:if>
197 <xsl:if test="tp:mapping">
198 <h2 xmlns="http://www.w3.org/1999/xhtml">Mapping types</h2>
199 <xsl:apply-templates select="tp:mapping"/>
200 </xsl:if>
202 <xsl:if test="tp:external-type">
203 <h2 xmlns="http://www.w3.org/1999/xhtml">Types defined elsewhere</h2>
204 <dl><xsl:apply-templates select="tp:external-type"/></dl>
205 </xsl:if>
206 </xsl:template>
208 <xsl:template match="tp:error">
209 <h2 xmlns="http://www.w3.org/1999/xhtml"><a name="{concat(../@namespace, '.', translate(@name, ' ', ''))}"></a><xsl:value-of select="concat(../@namespace, '.', translate(@name, ' ', ''))"/></h2>
210 <xsl:apply-templates select="tp:docstring"/>
211 <xsl:apply-templates select="tp:added"/>
212 <xsl:apply-templates select="tp:changed"/>
213 <xsl:apply-templates select="tp:deprecated"/>
214 </xsl:template>
216 <xsl:template match="/tp:spec/tp:copyright">
217 <div xmlns="http://www.w3.org/1999/xhtml">
218 <xsl:apply-templates mode="text"/>
219 </div>
220 </xsl:template>
221 <xsl:template match="/tp:spec/tp:license">
222 <div xmlns="http://www.w3.org/1999/xhtml" class="license">
223 <xsl:apply-templates mode="html"/>
224 </div>
225 </xsl:template>
227 <xsl:template match="tp:copyright"/>
228 <xsl:template match="tp:license"/>
230 <xsl:template match="interface">
231 <h1 xmlns="http://www.w3.org/1999/xhtml"><a name="{@name}"></a><xsl:value-of select="@name"/></h1>
233 <xsl:if test="@tp:causes-havoc">
234 <p xmlns="http://www.w3.org/1999/xhtml" class="causes-havoc">
235 This interface is <xsl:value-of select="@tp:causes-havoc"/>
236 and is likely to cause havoc to your API/ABI if bindings are generated.
237 Don't include it in libraries that care about compatibility.
238 </p>
239 </xsl:if>
241 <xsl:if test="tp:requires">
242 <p>Implementations of this interface must also implement:</p>
243 <ul xmlns="http://www.w3.org/1999/xhtml">
244 <xsl:for-each select="tp:requires">
245 <li><code><a href="#{@interface}"><xsl:value-of select="@interface"/></a></code></li>
246 </xsl:for-each>
247 </ul>
248 </xsl:if>
250 <xsl:apply-templates select="tp:docstring" />
251 <xsl:apply-templates select="tp:added"/>
252 <xsl:apply-templates select="tp:changed"/>
253 <xsl:apply-templates select="tp:deprecated"/>
255 <xsl:choose>
256 <xsl:when test="method">
257 <h2 xmlns="http://www.w3.org/1999/xhtml">Methods:</h2>
258 <xsl:apply-templates select="method"/>
259 </xsl:when>
260 <xsl:otherwise>
261 <p xmlns="http://www.w3.org/1999/xhtml">Interface has no methods.</p>
262 </xsl:otherwise>
263 </xsl:choose>
265 <xsl:choose>
266 <xsl:when test="signal">
267 <h2 xmlns="http://www.w3.org/1999/xhtml">Signals:</h2>
268 <xsl:apply-templates select="signal"/>
269 </xsl:when>
270 <xsl:otherwise>
271 <p xmlns="http://www.w3.org/1999/xhtml">Interface has no signals.</p>
272 </xsl:otherwise>
273 </xsl:choose>
275 <xsl:choose>
276 <xsl:when test="tp:property">
277 <h2 xmlns="http://www.w3.org/1999/xhtml">Telepathy Properties:</h2>
278 <p xmlns="http://www.w3.org/1999/xhtml">Accessed using the
279 <a href="#org.freedesktop.Telepathy.Properties">Telepathy
280 Properties</a> interface.</p>
281 <dl xmlns="http://www.w3.org/1999/xhtml">
282 <xsl:apply-templates select="tp:property"/>
283 </dl>
284 </xsl:when>
285 <xsl:otherwise>
286 <p xmlns="http://www.w3.org/1999/xhtml">Interface has no Telepathy
287 properties.</p>
288 </xsl:otherwise>
289 </xsl:choose>
291 <xsl:choose>
292 <xsl:when test="property">
293 <h2 xmlns="http://www.w3.org/1999/xhtml">D-Bus core Properties:</h2>
294 <p xmlns="http://www.w3.org/1999/xhtml">Accessed using the
295 org.freedesktop.DBus.Properties interface.</p>
296 <dl xmlns="http://www.w3.org/1999/xhtml">
297 <xsl:apply-templates select="property"/>
298 </dl>
299 </xsl:when>
300 <xsl:otherwise>
301 <p xmlns="http://www.w3.org/1999/xhtml">Interface has no D-Bus core
302 properties.</p>
303 </xsl:otherwise>
304 </xsl:choose>
306 <xsl:call-template name="do-types"/>
308 </xsl:template>
310 <xsl:template match="tp:flags">
312 <xsl:if test="not(@name) or @name = ''">
313 <xsl:message terminate="yes">
314 <xsl:text>ERR: missing @name on a tp:flags type&#10;</xsl:text>
315 </xsl:message>
316 </xsl:if>
318 <xsl:if test="not(@type) or @type = ''">
319 <xsl:message terminate="yes">
320 <xsl:text>ERR: missing @type on tp:flags type</xsl:text>
321 <xsl:value-of select="@name"/>
322 <xsl:text>&#10;</xsl:text>
323 </xsl:message>
324 </xsl:if>
326 <h3>
327 <a name="type-{@name}">
328 <xsl:value-of select="@name"/>
329 </a>
330 </h3>
331 <xsl:apply-templates select="tp:docstring" />
332 <xsl:apply-templates select="tp:added"/>
333 <xsl:apply-templates select="tp:changed"/>
334 <xsl:apply-templates select="tp:deprecated"/>
335 <dl xmlns="http://www.w3.org/1999/xhtml">
336 <xsl:variable name="value-prefix">
337 <xsl:choose>
338 <xsl:when test="@value-prefix">
339 <xsl:value-of select="@value-prefix"/>
340 </xsl:when>
341 <xsl:otherwise>
342 <xsl:value-of select="@name"/>
343 </xsl:otherwise>
344 </xsl:choose>
345 </xsl:variable>
346 <xsl:for-each select="tp:flag">
347 <dt xmlns="http://www.w3.org/1999/xhtml"><code><xsl:value-of select="concat($value-prefix, '_', @suffix)"/> = <xsl:value-of select="@value"/></code></dt>
348 <xsl:choose>
349 <xsl:when test="tp:docstring">
350 <dd xmlns="http://www.w3.org/1999/xhtml">
351 <xsl:apply-templates select="tp:docstring" />
352 <xsl:apply-templates select="tp:added"/>
353 <xsl:apply-templates select="tp:changed"/>
354 <xsl:apply-templates select="tp:deprecated"/>
355 </dd>
356 </xsl:when>
357 <xsl:otherwise>
358 <dd xmlns="http://www.w3.org/1999/xhtml">(Undocumented)</dd>
359 </xsl:otherwise>
360 </xsl:choose>
361 </xsl:for-each>
362 </dl>
363 </xsl:template>
365 <xsl:template match="tp:enum">
367 <xsl:if test="not(@name) or @name = ''">
368 <xsl:message terminate="yes">
369 <xsl:text>ERR: missing @name on a tp:enum type&#10;</xsl:text>
370 </xsl:message>
371 </xsl:if>
373 <xsl:if test="not(@type) or @type = ''">
374 <xsl:message terminate="yes">
375 <xsl:text>ERR: missing @type on tp:enum type</xsl:text>
376 <xsl:value-of select="@name"/>
377 <xsl:text>&#10;</xsl:text>
378 </xsl:message>
379 </xsl:if>
381 <h3 xmlns="http://www.w3.org/1999/xhtml">
382 <a name="type-{@name}">
383 <xsl:value-of select="@name"/>
384 </a>
385 </h3>
386 <xsl:apply-templates select="tp:docstring" />
387 <xsl:apply-templates select="tp:added"/>
388 <xsl:apply-templates select="tp:changed"/>
389 <xsl:apply-templates select="tp:deprecated"/>
390 <dl xmlns="http://www.w3.org/1999/xhtml">
391 <xsl:variable name="value-prefix">
392 <xsl:choose>
393 <xsl:when test="@value-prefix">
394 <xsl:value-of select="@value-prefix"/>
395 </xsl:when>
396 <xsl:otherwise>
397 <xsl:value-of select="@name"/>
398 </xsl:otherwise>
399 </xsl:choose>
400 </xsl:variable>
401 <xsl:for-each select="tp:enumvalue">
402 <dt xmlns="http://www.w3.org/1999/xhtml"><code><xsl:value-of select="concat($value-prefix, '_', @suffix)"/> = <xsl:value-of select="@value"/></code></dt>
403 <xsl:choose>
404 <xsl:when test="tp:docstring">
405 <dd xmlns="http://www.w3.org/1999/xhtml">
406 <xsl:apply-templates select="tp:docstring" />
407 <xsl:apply-templates select="tp:added"/>
408 <xsl:apply-templates select="tp:changed"/>
409 <xsl:apply-templates select="tp:deprecated"/>
410 </dd>
411 </xsl:when>
412 <xsl:otherwise>
413 <dd xmlns="http://www.w3.org/1999/xhtml">(Undocumented)</dd>
414 </xsl:otherwise>
415 </xsl:choose>
416 </xsl:for-each>
417 </dl>
418 </xsl:template>
420 <xsl:template match="property">
422 <xsl:if test="not(parent::interface)">
423 <xsl:message terminate="yes">
424 <xsl:text>ERR: property </xsl:text>
425 <xsl:value-of select="@name"/>
426 <xsl:text> does not have an interface as parent&#10;</xsl:text>
427 </xsl:message>
428 </xsl:if>
430 <xsl:if test="not(@name) or @name = ''">
431 <xsl:message terminate="yes">
432 <xsl:text>ERR: missing @name on a property of </xsl:text>
433 <xsl:value-of select="../@name"/>
434 <xsl:text>&#10;</xsl:text>
435 </xsl:message>
436 </xsl:if>
438 <xsl:if test="not(@type) or @type = ''">
439 <xsl:message terminate="yes">
440 <xsl:text>ERR: missing @type on property </xsl:text>
441 <xsl:value-of select="concat(../@name, '.', @name)"/>
442 <xsl:text>: '</xsl:text>
443 <xsl:value-of select="@access"/>
444 <xsl:text>'&#10;</xsl:text>
445 </xsl:message>
446 </xsl:if>
448 <dt xmlns="http://www.w3.org/1999/xhtml">
449 <a name="{concat(../@name, '.', @name)}">
450 <code><xsl:value-of select="@name"/></code>
451 </a>
452 <xsl:text></xsl:text>
453 <code><xsl:value-of select="@type"/></code>
454 <xsl:call-template name="parenthesized-tp-type"/>
455 <xsl:text>, </xsl:text>
456 <xsl:choose>
457 <xsl:when test="@access = 'read'">
458 <xsl:text>read-only</xsl:text>
459 </xsl:when>
460 <xsl:when test="@access = 'write'">
461 <xsl:text>write-only</xsl:text>
462 </xsl:when>
463 <xsl:when test="@access = 'readwrite'">
464 <xsl:text>read/write</xsl:text>
465 </xsl:when>
466 <xsl:otherwise>
467 <xsl:message terminate="yes">
468 <xsl:text>ERR: unknown or missing value for </xsl:text>
469 <xsl:text>@access on property </xsl:text>
470 <xsl:value-of select="concat(../@name, '.', @name)"/>
471 <xsl:text>: '</xsl:text>
472 <xsl:value-of select="@access"/>
473 <xsl:text>'&#10;</xsl:text>
474 </xsl:message>
475 </xsl:otherwise>
476 </xsl:choose>
477 </dt>
478 <dd xmlns="http://www.w3.org/1999/xhtml">
479 <xsl:apply-templates select="tp:docstring"/>
480 <xsl:apply-templates select="tp:added"/>
481 <xsl:apply-templates select="tp:changed"/>
482 <xsl:apply-templates select="tp:deprecated"/>
483 </dd>
484 </xsl:template>
486 <xsl:template match="tp:property">
487 <dt xmlns="http://www.w3.org/1999/xhtml">
488 <xsl:if test="@name">
489 <code><xsl:value-of select="@name"/></code>
490 </xsl:if>
491 <code><xsl:value-of select="@type"/></code>
492 </dt>
493 <dd xmlns="http://www.w3.org/1999/xhtml">
494 <xsl:apply-templates select="tp:docstring"/>
495 <xsl:apply-templates select="tp:added"/>
496 <xsl:apply-templates select="tp:changed"/>
497 <xsl:apply-templates select="tp:deprecated"/>
498 </dd>
499 </xsl:template>
501 <xsl:template match="tp:mapping">
502 <div xmlns="http://www.w3.org/1999/xhtml" class="struct">
503 <h3>
504 <a name="type-{@name}">
505 <xsl:value-of select="@name"/>
506 </a> − a{
507 <xsl:for-each select="tp:member">
508 <xsl:value-of select="@type"/>
509 <xsl:text>: </xsl:text>
510 <xsl:value-of select="@name"/>
511 <xsl:if test="position() != last()"> &#x2192; </xsl:if>
512 </xsl:for-each>
514 </h3>
515 <div class="docstring">
516 <xsl:apply-templates select="tp:docstring"/>
517 <xsl:if test="string(@array-name) != ''">
518 <p>In bindings that need a separate name, arrays of
519 <xsl:value-of select="@name"/> should be called
520 <xsl:value-of select="@array-name"/>.</p>
521 </xsl:if>
522 </div>
523 <div>
524 <h4>Members</h4>
525 <dl>
526 <xsl:apply-templates select="tp:member" mode="members-in-docstring"/>
527 </dl>
528 </div>
529 </div>
530 </xsl:template>
532 <xsl:template match="tp:docstring" mode="in-index"/>
534 <xsl:template match="tp:simple-type | tp:enum | tp:flags | tp:external-type"
535 mode="in-index">
536 <xsl:value-of select="@type"/>
537 </xsl:template>
539 <xsl:template match="tp:simple-type">
541 <xsl:if test="not(@name) or @name = ''">
542 <xsl:message terminate="yes">
543 <xsl:text>ERR: missing @name on a tp:simple-type&#10;</xsl:text>
544 </xsl:message>
545 </xsl:if>
547 <xsl:if test="not(@type) or @type = ''">
548 <xsl:message terminate="yes">
549 <xsl:text>ERR: missing @type on tp:simple-type</xsl:text>
550 <xsl:value-of select="@name"/>
551 <xsl:text>&#10;</xsl:text>
552 </xsl:message>
553 </xsl:if>
555 <div xmlns="http://www.w3.org/1999/xhtml" class="simple-type">
556 <h3>
557 <a name="type-{@name}">
558 <xsl:value-of select="@name"/>
559 </a><xsl:value-of select="@type"/>
560 </h3>
561 <div class="docstring">
562 <xsl:apply-templates select="tp:docstring"/>
563 <xsl:apply-templates select="tp:added"/>
564 <xsl:apply-templates select="tp:changed"/>
565 <xsl:apply-templates select="tp:deprecated"/>
566 </div>
567 </div>
568 </xsl:template>
570 <xsl:template match="tp:external-type">
572 <xsl:if test="not(@name) or @name = ''">
573 <xsl:message terminate="yes">
574 <xsl:text>ERR: missing @name on a tp:external-type&#10;</xsl:text>
575 </xsl:message>
576 </xsl:if>
578 <xsl:if test="not(@type) or @type = ''">
579 <xsl:message terminate="yes">
580 <xsl:text>ERR: missing @type on tp:external-type</xsl:text>
581 <xsl:value-of select="@name"/>
582 <xsl:text>&#10;</xsl:text>
583 </xsl:message>
584 </xsl:if>
586 <div xmlns="http://www.w3.org/1999/xhtml" class="external-type">
587 <dt>
588 <a name="type-{@name}">
589 <xsl:value-of select="@name"/>
590 </a><xsl:value-of select="@type"/>
591 </dt>
592 <dd>Defined by: <xsl:value-of select="@from"/></dd>
593 </div>
594 </xsl:template>
596 <xsl:template match="tp:struct" mode="in-index">
597 − ( <xsl:for-each select="tp:member">
598 <xsl:value-of select="@type"/>
599 <xsl:if test="position() != last()">, </xsl:if>
600 </xsl:for-each> )
601 </xsl:template>
603 <xsl:template match="tp:mapping" mode="in-index">
604 − a{ <xsl:for-each select="tp:member">
605 <xsl:value-of select="@type"/>
606 <xsl:if test="position() != last()"> &#x2192; </xsl:if>
607 </xsl:for-each> }
608 </xsl:template>
610 <xsl:template match="tp:struct">
611 <div xmlns="http://www.w3.org/1999/xhtml" class="struct">
612 <h3>
613 <a name="type-{@name}">
614 <xsl:value-of select="@name"/>
615 </a> − (
616 <xsl:for-each select="tp:member">
617 <xsl:value-of select="@type"/>
618 <xsl:text>: </xsl:text>
619 <xsl:value-of select="@name"/>
620 <xsl:if test="position() != last()">, </xsl:if>
621 </xsl:for-each>
623 </h3>
624 <div class="docstring">
625 <xsl:apply-templates select="tp:docstring"/>
626 <xsl:apply-templates select="tp:added"/>
627 <xsl:apply-templates select="tp:changed"/>
628 <xsl:apply-templates select="tp:deprecated"/>
629 </div>
630 <xsl:choose>
631 <xsl:when test="string(@array-name) != ''">
632 <p>In bindings that need a separate name, arrays of
633 <xsl:value-of select="@name"/> should be called
634 <xsl:value-of select="@array-name"/>.</p>
635 </xsl:when>
636 <xsl:otherwise>
637 <p>Arrays of <xsl:value-of select="@name"/> don't generally
638 make sense.</p>
639 </xsl:otherwise>
640 </xsl:choose>
641 <div>
642 <h4>Members</h4>
643 <dl>
644 <xsl:apply-templates select="tp:member" mode="members-in-docstring"/>
645 </dl>
646 </div>
647 </div>
648 </xsl:template>
650 <xsl:template match="method">
652 <xsl:if test="not(parent::interface)">
653 <xsl:message terminate="yes">
654 <xsl:text>ERR: method </xsl:text>
655 <xsl:value-of select="@name"/>
656 <xsl:text> does not have an interface as parent&#10;</xsl:text>
657 </xsl:message>
658 </xsl:if>
660 <xsl:if test="not(@name) or @name = ''">
661 <xsl:message terminate="yes">
662 <xsl:text>ERR: missing @name on a method of </xsl:text>
663 <xsl:value-of select="../@name"/>
664 <xsl:text>&#10;</xsl:text>
665 </xsl:message>
666 </xsl:if>
668 <xsl:for-each select="arg">
669 <xsl:if test="not(@type) or @type = ''">
670 <xsl:message terminate="yes">
671 <xsl:text>ERR: an arg of method </xsl:text>
672 <xsl:value-of select="concat(../../@name, '.', ../@name)"/>
673 <xsl:text> has no type</xsl:text>
674 </xsl:message>
675 </xsl:if>
676 <xsl:choose>
677 <xsl:when test="@direction='in'">
678 <xsl:if test="not(@name) or @name = ''">
679 <xsl:message terminate="yes">
680 <xsl:text>ERR: an 'in' arg of method </xsl:text>
681 <xsl:value-of select="concat(../../@name, '.', ../@name)"/>
682 <xsl:text> has no name</xsl:text>
683 </xsl:message>
684 </xsl:if>
685 </xsl:when>
686 <xsl:when test="@direction='out'">
687 <!-- FIXME: This is commented out until someone with a lot of time
688 on their hands goes through the spec adding names to all the "out"
689 arguments
691 <xsl:if test="not(@name) or @name = ''">
692 <xsl:message terminate="no">
693 <xsl:text>INFO: an 'out' arg of method </xsl:text>
694 <xsl:value-of select="concat(../../@name, '.', ../@name)"/>
695 <xsl:text> has no name</xsl:text>
696 </xsl:message>
697 </xsl:if>-->
698 </xsl:when>
699 <xsl:otherwise>
700 <xsl:message terminate="yes">
701 <xsl:text>ERR: an arg of method </xsl:text>
702 <xsl:value-of select="concat(../../@name, '.', ../@name)"/>
703 <xsl:text> has direction neither 'in' nor 'out'</xsl:text>
704 </xsl:message>
705 </xsl:otherwise>
706 </xsl:choose>
707 </xsl:for-each>
709 <div xmlns="http://www.w3.org/1999/xhtml" class="method">
710 <h3 xmlns="http://www.w3.org/1999/xhtml">
711 <a name="{concat(../@name, concat('.', @name))}">
712 <xsl:value-of select="@name"/>
713 </a> (
714 <xsl:for-each xmlns="" select="arg[@direction='in']">
715 <xsl:value-of select="@type"/>: <xsl:value-of select="@name"/>
716 <xsl:if test="position() != last()">, </xsl:if>
717 </xsl:for-each>
718 ) &#x2192;
719 <xsl:choose>
720 <xsl:when test="arg[@direction='out']">
721 <xsl:for-each xmlns="" select="arg[@direction='out']">
722 <xsl:value-of select="@type"/>
723 <xsl:if test="position() != last()">, </xsl:if>
724 </xsl:for-each>
725 </xsl:when>
726 <xsl:otherwise>nothing</xsl:otherwise>
727 </xsl:choose>
728 </h3>
729 <div xmlns="http://www.w3.org/1999/xhtml" class="docstring">
730 <xsl:apply-templates select="tp:docstring" />
731 <xsl:apply-templates select="tp:added"/>
732 <xsl:apply-templates select="tp:changed"/>
733 <xsl:apply-templates select="tp:deprecated"/>
734 </div>
736 <xsl:if test="arg[@direction='in']">
737 <div xmlns="http://www.w3.org/1999/xhtml">
738 <h4>Parameters</h4>
739 <dl xmlns="http://www.w3.org/1999/xhtml">
740 <xsl:apply-templates select="arg[@direction='in']"
741 mode="parameters-in-docstring"/>
742 </dl>
743 </div>
744 </xsl:if>
746 <xsl:if test="arg[@direction='out']">
747 <div xmlns="http://www.w3.org/1999/xhtml">
748 <h4>Returns</h4>
749 <dl xmlns="http://www.w3.org/1999/xhtml">
750 <xsl:apply-templates select="arg[@direction='out']"
751 mode="returns-in-docstring"/>
752 </dl>
753 </div>
754 </xsl:if>
756 <xsl:if test="tp:possible-errors">
757 <div xmlns="http://www.w3.org/1999/xhtml">
758 <h4>Possible errors</h4>
759 <dl xmlns="http://www.w3.org/1999/xhtml">
760 <xsl:apply-templates select="tp:possible-errors/tp:error"/>
761 </dl>
762 </div>
763 </xsl:if>
765 </div>
766 </xsl:template>
768 <xsl:template name="tp-type">
769 <xsl:param name="tp-type"/>
770 <xsl:param name="type"/>
772 <xsl:variable name="single-type">
773 <xsl:choose>
774 <xsl:when test="contains($tp-type, '[]')">
775 <xsl:value-of select="substring-before($tp-type, '[]')"/>
776 </xsl:when>
777 <xsl:otherwise>
778 <xsl:value-of select="$tp-type"/>
779 </xsl:otherwise>
780 </xsl:choose>
781 </xsl:variable>
783 <xsl:variable name="type-of-tp-type">
784 <xsl:if test="contains($tp-type, '[]')">
785 <!-- one 'a', plus one for each [ after the [], and delete all ] -->
786 <xsl:value-of select="concat('a',
787 translate(substring-after($tp-type, '[]'), '[]', 'a'))"/>
788 </xsl:if>
790 <xsl:choose>
791 <xsl:when test="//tp:simple-type[@name=$single-type]">
792 <xsl:value-of select="string(//tp:simple-type[@name=$single-type]/@type)"/>
793 </xsl:when>
794 <xsl:when test="//tp:struct[@name=$single-type]">
795 <xsl:text>(</xsl:text>
796 <xsl:for-each select="//tp:struct[@name=$single-type]/tp:member">
797 <xsl:value-of select="@type"/>
798 </xsl:for-each>
799 <xsl:text>)</xsl:text>
800 </xsl:when>
801 <xsl:when test="//tp:enum[@name=$single-type]">
802 <xsl:value-of select="string(//tp:enum[@name=$single-type]/@type)"/>
803 </xsl:when>
804 <xsl:when test="//tp:flags[@name=$single-type]">
805 <xsl:value-of select="string(//tp:flags[@name=$single-type]/@type)"/>
806 </xsl:when>
807 <xsl:when test="//tp:mapping[@name=$single-type]">
808 <xsl:text>a{</xsl:text>
809 <xsl:for-each select="//tp:mapping[@name=$single-type]/tp:member">
810 <xsl:value-of select="@type"/>
811 </xsl:for-each>
812 <xsl:text>}</xsl:text>
813 </xsl:when>
814 <xsl:when test="//tp:external-type[@name=$single-type]">
815 <xsl:value-of select="string(//tp:external-type[@name=$single-type]/@type)"/>
816 </xsl:when>
817 <xsl:otherwise>
818 <xsl:message terminate="yes">
819 <xsl:text>ERR: Unable to find type '</xsl:text>
820 <xsl:value-of select="$tp-type"/>
821 <xsl:text>'&#10;</xsl:text>
822 </xsl:message>
823 </xsl:otherwise>
824 </xsl:choose>
825 </xsl:variable>
827 <xsl:if test="string($type) != '' and
828 string($type-of-tp-type) != string($type)">
829 <xsl:message terminate="yes">
830 <xsl:text>ERR: tp:type '</xsl:text>
831 <xsl:value-of select="$tp-type"/>
832 <xsl:text>' has D-Bus type '</xsl:text>
833 <xsl:value-of select="$type-of-tp-type"/>
834 <xsl:text>' but has been used with type='</xsl:text>
835 <xsl:value-of select="$type"/>
836 <xsl:text>'&#10;</xsl:text>
837 </xsl:message>
838 </xsl:if>
840 <a href="#type-{$single-type}"><xsl:value-of select="$tp-type"/></a>
842 </xsl:template>
844 <xsl:template name="parenthesized-tp-type">
845 <xsl:if test="@tp:type">
846 <xsl:text> (</xsl:text>
847 <xsl:call-template name="tp-type">
848 <xsl:with-param name="tp-type" select="@tp:type"/>
849 <xsl:with-param name="type" select="@type"/>
850 </xsl:call-template>
851 <xsl:text>)</xsl:text>
852 </xsl:if>
853 </xsl:template>
855 <xsl:template match="tp:member" mode="members-in-docstring">
856 <dt xmlns="http://www.w3.org/1999/xhtml">
857 <code><xsl:value-of select="@name"/></code>
858 <code><xsl:value-of select="@type"/></code>
859 <xsl:call-template name="parenthesized-tp-type"/>
860 </dt>
861 <dd xmlns="http://www.w3.org/1999/xhtml">
862 <xsl:choose>
863 <xsl:when test="tp:docstring">
864 <xsl:apply-templates select="tp:docstring" />
865 </xsl:when>
866 <xsl:otherwise>
867 <em>(undocumented)</em>
868 </xsl:otherwise>
869 </xsl:choose>
870 </dd>
871 </xsl:template>
873 <xsl:template match="arg" mode="parameters-in-docstring">
874 <dt xmlns="http://www.w3.org/1999/xhtml">
875 <code><xsl:value-of select="@name"/></code>
876 <code><xsl:value-of select="@type"/></code>
877 <xsl:call-template name="parenthesized-tp-type"/>
878 </dt>
879 <dd xmlns="http://www.w3.org/1999/xhtml">
880 <xsl:apply-templates select="tp:docstring" />
881 </dd>
882 </xsl:template>
884 <xsl:template match="arg" mode="returns-in-docstring">
885 <dt xmlns="http://www.w3.org/1999/xhtml">
886 <xsl:if test="@name">
887 <code><xsl:value-of select="@name"/></code>
888 </xsl:if>
889 <code><xsl:value-of select="@type"/></code>
890 <xsl:call-template name="parenthesized-tp-type"/>
891 </dt>
892 <dd xmlns="http://www.w3.org/1999/xhtml">
893 <xsl:apply-templates select="tp:docstring"/>
894 </dd>
895 </xsl:template>
897 <xsl:template match="tp:possible-errors/tp:error">
898 <dt xmlns="http://www.w3.org/1999/xhtml">
899 <code><xsl:value-of select="@name"/></code>
900 </dt>
901 <dd xmlns="http://www.w3.org/1999/xhtml">
902 <xsl:variable name="name" select="@name"/>
903 <xsl:choose>
904 <xsl:when test="tp:docstring">
905 <xsl:apply-templates select="tp:docstring"/>
906 </xsl:when>
907 <xsl:when test="//tp:errors/tp:error[concat(../@namespace, '.', translate(@name, ' ', ''))=$name]/tp:docstring">
908 <xsl:apply-templates select="//tp:errors/tp:error[concat(../@namespace, '.', translate(@name, ' ', ''))=$name]/tp:docstring"/> <em xmlns="http://www.w3.org/1999/xhtml">(generic description)</em>
909 </xsl:when>
910 <xsl:otherwise>
911 (Undocumented.)
912 </xsl:otherwise>
913 </xsl:choose>
914 </dd>
915 </xsl:template>
917 <xsl:template match="signal">
919 <xsl:if test="not(parent::interface)">
920 <xsl:message terminate="yes">
921 <xsl:text>ERR: signal </xsl:text>
922 <xsl:value-of select="@name"/>
923 <xsl:text> does not have an interface as parent&#10;</xsl:text>
924 </xsl:message>
925 </xsl:if>
927 <xsl:if test="not(@name) or @name = ''">
928 <xsl:message terminate="yes">
929 <xsl:text>ERR: missing @name on a signal of </xsl:text>
930 <xsl:value-of select="../@name"/>
931 <xsl:text>&#10;</xsl:text>
932 </xsl:message>
933 </xsl:if>
935 <xsl:for-each select="arg">
936 <xsl:if test="not(@type) or @type = ''">
937 <xsl:message terminate="yes">
938 <xsl:text>ERR: an arg of signal </xsl:text>
939 <xsl:value-of select="concat(../../@name, '.', ../@name)"/>
940 <xsl:text> has no type</xsl:text>
941 </xsl:message>
942 </xsl:if>
943 <xsl:if test="not(@name) or @name = ''">
944 <xsl:message terminate="yes">
945 <xsl:text>ERR: an arg of signal </xsl:text>
946 <xsl:value-of select="concat(../../@name, '.', ../@name)"/>
947 <xsl:text> has no name</xsl:text>
948 </xsl:message>
949 </xsl:if>
950 <xsl:choose>
951 <xsl:when test="not(@direction)"/>
952 <xsl:when test="@direction='in'">
953 <xsl:message terminate="no">
954 <xsl:text>INFO: an arg of signal </xsl:text>
955 <xsl:value-of select="concat(../../@name, '.', ../@name)"/>
956 <xsl:text> has unnecessary direction 'in'</xsl:text>
957 </xsl:message>
958 </xsl:when>
959 <xsl:otherwise>
960 <xsl:message terminate="yes">
961 <xsl:text>ERR: an arg of signal </xsl:text>
962 <xsl:value-of select="concat(../../@name, '.', ../@name)"/>
963 <xsl:text> has direction other than 'in'</xsl:text>
964 </xsl:message>
965 </xsl:otherwise>
966 </xsl:choose>
967 </xsl:for-each>
969 <div xmlns="http://www.w3.org/1999/xhtml" class="signal">
970 <h3 xmlns="http://www.w3.org/1999/xhtml">
971 <a name="{concat(../@name, concat('.', @name))}">
972 <xsl:value-of select="@name"/>
973 </a> (
974 <xsl:for-each xmlns="" select="arg">
975 <xsl:value-of select="@type"/>: <xsl:value-of select="@name"/>
976 <xsl:if test="position() != last()">, </xsl:if>
977 </xsl:for-each>
978 )</h3>
980 <div xmlns="http://www.w3.org/1999/xhtml" class="docstring">
981 <xsl:apply-templates select="tp:docstring"/>
982 <xsl:apply-templates select="tp:added"/>
983 <xsl:apply-templates select="tp:changed"/>
984 <xsl:apply-templates select="tp:deprecated"/>
985 </div>
987 <xsl:if test="arg">
988 <div xmlns="http://www.w3.org/1999/xhtml">
989 <h4>Parameters</h4>
990 <dl xmlns="http://www.w3.org/1999/xhtml">
991 <xsl:apply-templates select="arg" mode="parameters-in-docstring"/>
992 </dl>
993 </div>
994 </xsl:if>
995 </div>
996 </xsl:template>
998 <xsl:output method="xml" indent="no" encoding="ascii"
999 omit-xml-declaration="yes"
1000 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
1001 doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />
1003 <xsl:template match="/tp:spec">
1004 <html xmlns="http://www.w3.org/1999/xhtml">
1005 <head>
1006 <title>
1007 <xsl:value-of select="tp:title"/>
1008 <xsl:if test="tp:version">
1009 <xsl:text> version </xsl:text>
1010 <xsl:value-of select="tp:version"/>
1011 </xsl:if>
1012 </title>
1013 <style type="text/css">
1015 body {
1016 font-family: sans-serif;
1017 margin: 2em;
1018 height: 100%;
1019 font-size: 1.2em;
1021 h1 {
1022 padding-top: 5px;
1023 padding-bottom: 5px;
1024 font-size: 1.6em;
1025 background: #dadae2;
1027 h2 {
1028 font-size: 1.3em;
1030 h3 {
1031 font-size: 1.2em;
1033 a:link, a:visited, a:link:hover, a:visited:hover {
1034 font-weight: bold;
1036 .topbox {
1037 padding-top: 10px;
1038 padding-left: 10px;
1039 border-bottom: black solid 1px;
1040 padding-bottom: 10px;
1041 background: #dadae2;
1042 font-size: 2em;
1043 font-weight: bold;
1044 color: #5c5c5c;
1046 .topnavbox {
1047 padding-left: 10px;
1048 padding-top: 5px;
1049 padding-bottom: 5px;
1050 background: #abacba;
1051 border-bottom: black solid 1px;
1052 font-size: 1.2em;
1054 .topnavbox a{
1055 color: black;
1056 font-weight: normal;
1058 .sidebar {
1059 float: left;
1060 /* width:9em;
1061 border-right:#abacba solid 1px;
1062 border-left: #abacba solid 1px;
1063 height:100%; */
1064 border: #abacba solid 1px;
1065 padding-left: 10px;
1066 margin-left: 10px;
1067 padding-right: 10px;
1068 margin-right: 10px;
1069 color: #5d5d5d;
1070 background: #dadae2;
1072 .sidebar a {
1073 text-decoration: none;
1074 border-bottom: #e29625 dotted 1px;
1075 color: #e29625;
1076 font-weight: normal;
1078 .sidebar h1 {
1079 font-size: 1.2em;
1080 color: black;
1082 .sidebar ul {
1083 padding-left: 25px;
1084 padding-bottom: 10px;
1085 border-bottom: #abacba solid 1px;
1087 .sidebar li {
1088 padding-top: 2px;
1089 padding-bottom: 2px;
1091 .sidebar h2 {
1092 font-style:italic;
1093 font-size: 0.81em;
1094 padding-left: 5px;
1095 padding-right: 5px;
1096 font-weight: normal;
1098 .date {
1099 font-size: 0.6em;
1100 float: right;
1101 font-style: italic;
1103 .method, .signal, .property {
1104 margin-left: 1em;
1105 margin-right: 4em;
1107 .rationale {
1108 font-style: italic;
1109 border-left: 0.25em solid #808080;
1110 padding-left: 0.5em;
1113 .added {
1114 color: #006600;
1115 background: #ffffff;
1117 .deprecated {
1118 color: #ff0000;
1119 background: #ffffff;
1121 table, tr, td, th {
1122 border: 1px solid #666;
1125 </style>
1126 </head>
1127 <body>
1128 <h1 class="topbox">
1129 <xsl:value-of select="tp:title" />
1130 </h1>
1131 <xsl:if test="tp:version">
1132 <h2>Version <xsl:value-of select="string(tp:version)"/></h2>
1133 </xsl:if>
1134 <xsl:apply-templates select="tp:copyright"/>
1135 <xsl:apply-templates select="tp:license"/>
1136 <xsl:apply-templates select="tp:docstring"/>
1138 <h2>Interfaces</h2>
1139 <ul>
1140 <xsl:for-each select="//node/interface">
1141 <li><code><a href="#{@name}"><xsl:value-of select="@name"/></a></code></li>
1142 </xsl:for-each>
1143 </ul>
1145 <xsl:apply-templates select="//node"/>
1146 <xsl:apply-templates select="tp:generic-types"/>
1147 <xsl:apply-templates select="tp:errors"/>
1149 <h1>Index</h1>
1150 <h2>Index of interfaces</h2>
1151 <ul>
1152 <xsl:for-each select="//node/interface">
1153 <li><code><a href="#{@name}"><xsl:value-of select="@name"/></a></code></li>
1154 </xsl:for-each>
1155 </ul>
1156 <h2>Index of types</h2>
1157 <ul>
1158 <xsl:for-each select="//tp:simple-type | //tp:enum | //tp:flags | //tp:mapping | //tp:struct | //tp:external-type">
1159 <xsl:sort select="@name"/>
1160 <li>
1161 <code>
1162 <a href="#type-{@name}">
1163 <xsl:value-of select="@name"/>
1164 </a>
1165 </code>
1166 <xsl:apply-templates mode="in-index" select="."/>
1167 </li>
1168 </xsl:for-each>
1169 </ul>
1170 </body>
1171 </html>
1172 </xsl:template>
1174 <xsl:template match="node">
1175 <xsl:apply-templates />
1176 </xsl:template>
1178 <xsl:template match="text()">
1179 <xsl:if test="normalize-space(.) != ''">
1180 <xsl:message terminate="yes">
1181 <xsl:text>Stray text: {{{</xsl:text>
1182 <xsl:value-of select="." />
1183 <xsl:text>}}}&#10;</xsl:text>
1184 </xsl:message>
1185 </xsl:if>
1186 </xsl:template>
1188 <xsl:template match="*">
1189 <xsl:message terminate="yes">
1190 <xsl:text>Unrecognised element: {</xsl:text>
1191 <xsl:value-of select="namespace-uri(.)" />
1192 <xsl:text>}</xsl:text>
1193 <xsl:value-of select="local-name(.)" />
1194 <xsl:text>&#10;</xsl:text>
1195 </xsl:message>
1196 </xsl:template>
1197 </xsl:stylesheet>
1199 <!-- vim:set sw=2 sts=2 et: -->