2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"
4 exclude-result-prefixes="doc">
6 Convert D-Bus GLib XML into DocBook refentries
7 Copyright (C) 2007 William Jon McCann
10 <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
12 <xsl:template match="/">
14 <xsl:variable name="interface" select="//interface/@name"/>
15 <xsl:variable name="basename">
16 <xsl:call-template name="interface-basename">
17 <xsl:with-param name="str" select="$interface"/>
21 <refentry><xsl:attribute name="id"><xsl:value-of select="$basename"/></xsl:attribute>
23 <refentrytitle role="top_of_page"><xsl:value-of select="//interface/@name"/></refentrytitle>
27 <refname><xsl:value-of select="//interface/@name"/></refname>
28 <refpurpose><xsl:value-of select="$basename"/> interface</refpurpose>
31 <refsynopsisdiv role="synopsis">
32 <title role="synopsis.title">Methods</title>
34 <xsl:call-template name="methods-synopsis">
35 <xsl:with-param name="basename" select="$basename"/>
40 <refsect1 role="signal_proto">
41 <title role="signal_proto.title">Signals</title>
43 <xsl:call-template name="signals-synopsis">
44 <xsl:with-param name="basename" select="$basename"/>
49 <refsect1 role="impl_interfaces">
50 <title role="impl_interfaces.title">Implemented Interfaces</title>
52 <xsl:value-of select="$interface"/> implements
53 org.freedesktop.DBus.Introspectable,
54 org.freedesktop.DBus.Properties
58 <refsect1 role="properties">
59 <title role="properties.title">Properties</title>
61 <xsl:call-template name="properties-synopsis">
62 <xsl:with-param name="basename" select="$basename"/>
67 <refsect1 role="desc">
68 <title role="desc.title">Description</title>
70 <xsl:apply-templates select="//interface/doc:doc"/>
74 <refsect1 role="details">
75 <title role="details.title">Details</title>
76 <xsl:call-template name="method-details">
77 <xsl:with-param name="basename" select="$basename"/>
81 <refsect1 role="signals">
82 <title role="signals.title">Signal Details</title>
83 <xsl:call-template name="signal-details">
84 <xsl:with-param name="basename" select="$basename"/>
88 <refsect1 role="property_details">
89 <title role="property_details.title">Property Details</title>
90 <xsl:call-template name="property-details">
91 <xsl:with-param name="basename" select="$basename"/>
99 <xsl:template name="property-doc">
100 <xsl:apply-templates select="doc:doc/doc:description"/>
102 <variablelist role="params">
103 <xsl:for-each select="arg">
104 <varlistentry><term><parameter><xsl:value-of select="@name"/></parameter>:</term>
105 <listitem><simpara><xsl:value-of select="doc:doc/doc:summary"/></simpara></listitem>
110 <xsl:apply-templates select="doc:doc/doc:since"/>
111 <xsl:apply-templates select="doc:doc/doc:deprecated"/>
112 <xsl:apply-templates select="doc:doc/doc:permission"/>
113 <xsl:apply-templates select="doc:doc/doc:seealso"/>
117 <xsl:template name="property-details">
118 <xsl:param name="basename"/>
119 <xsl:variable name="longest">
120 <xsl:call-template name="find-longest">
121 <xsl:with-param name="set" select="@name"/>
124 <xsl:for-each select="///property">
126 <title><anchor role="function"><xsl:attribute name="id"><xsl:value-of select="$basename"/>:<xsl:value-of select="@name"/></xsl:attribute></anchor>The "<xsl:value-of select="@name"/>" property</title>
127 <indexterm><primary><xsl:value-of select="@name"/></primary><secondary><xsl:value-of select="$basename"/></secondary></indexterm>
128 <programlisting>'<xsl:value-of select="@name"/>'<xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="2"/></xsl:call-template>
129 <xsl:call-template name="property-args"><xsl:with-param name="indent" select="string-length(@name) + 2"/></xsl:call-template></programlisting>
132 <xsl:call-template name="property-doc"/>
137 <xsl:template name="signal-doc">
138 <xsl:apply-templates select="doc:doc/doc:description"/>
140 <variablelist role="params">
141 <xsl:for-each select="arg">
142 <varlistentry><term><parameter><xsl:value-of select="@name"/></parameter>:</term>
143 <listitem><simpara><xsl:value-of select="doc:doc/doc:summary"/></simpara></listitem>
148 <xsl:apply-templates select="doc:doc/doc:since"/>
149 <xsl:apply-templates select="doc:doc/doc:deprecated"/>
150 <xsl:apply-templates select="doc:doc/doc:permission"/>
151 <xsl:apply-templates select="doc:doc/doc:seealso"/>
154 <xsl:template name="signal-details">
155 <xsl:param name="basename"/>
156 <xsl:variable name="longest">
157 <xsl:call-template name="find-longest">
158 <xsl:with-param name="set" select="@name"/>
161 <xsl:for-each select="///signal">
163 <title><anchor role="function"><xsl:attribute name="id"><xsl:value-of select="$basename"/>::<xsl:value-of select="@name"/></xsl:attribute></anchor>The <xsl:value-of select="@name"/> signal</title>
164 <indexterm><primary><xsl:value-of select="@name"/></primary><secondary><xsl:value-of select="$basename"/></secondary></indexterm>
165 <programlisting><xsl:value-of select="@name"/> (<xsl:call-template name="signal-args"><xsl:with-param name="indent" select="string-length(@name) + 2"/><xsl:with-param name="prefix" select="."/></xsl:call-template>)</programlisting>
168 <xsl:call-template name="signal-doc"/>
173 <xsl:template match="doc:code">
175 <xsl:apply-templates />
179 <xsl:template match="doc:summary">
180 <!-- by default don't display -->
183 <xsl:template match="doc:example">
185 <xsl:apply-templates />
189 <xsl:template match="doc:para">
191 <xsl:apply-templates />
195 <xsl:template match="doc:description">
196 <xsl:apply-templates />
199 <xsl:template match="doc:since">
200 <para role="since">Since <xsl:value-of select="@version"/>
204 <xsl:template match="doc:deprecated">
205 <xsl:variable name="name" select="../../@name"/>
206 <xsl:variable name="parent">
207 <xsl:call-template name="interface-basename">
208 <xsl:with-param name="str" select="../../../@name"/>/>
212 <xsl:variable name="type" select="name(../..)"/>
214 <para role="deprecated">
215 <warning><para><literal><xsl:value-of select="$name"/></literal> is deprecated since version <xsl:value-of select="@version"/> and should not be used in newly-written code. Use
217 <xsl:variable name="to">
219 <xsl:when test="contains($type,'property')">
220 <xsl:value-of select="$parent"/>:<xsl:value-of select="@instead"/>
222 <xsl:when test="contains($type,'signal')">
223 <xsl:value-of select="$parent"/>::<xsl:value-of select="@instead"/>
225 <xsl:when test="contains($type,'method')">
226 <xsl:value-of select="$parent"/>.<xsl:value-of select="@instead"/>
228 <xsl:when test="contains($type,'interface')">
229 <xsl:value-of select="@instead"/>
232 <xsl:value-of select="@instead"/>
237 <xsl:call-template name="create-link">
238 <xsl:with-param name="type" select="$type"/>
239 <xsl:with-param name="to" select="$to"/>
240 <xsl:with-param name="val" select="@instead"/>
242 instead.</para></warning>
246 <xsl:template match="doc:permission">
247 <para role="permission">
248 <xsl:apply-templates />
252 <xsl:template match="doc:seealso">
255 <xsl:apply-templates />
260 <xsl:template name="create-link">
261 <xsl:param name="type"/>
262 <xsl:param name="to"/>
263 <xsl:param name="val"/>
266 <xsl:when test="contains($type,'property')">
267 <link><xsl:attribute name="linkend"><xsl:value-of select="$to"/></xsl:attribute><literal><xsl:value-of select="$val"/></literal></link>
269 <xsl:when test="contains($type,'signal')">
270 <link><xsl:attribute name="linkend"><xsl:value-of select="$to"/></xsl:attribute><literal><xsl:value-of select="$val"/></literal></link>
272 <xsl:when test="contains($type,'method')">
273 <link><xsl:attribute name="linkend"><xsl:value-of select="$to"/></xsl:attribute><function><xsl:value-of select="$val"/></function></link>
275 <xsl:when test="contains($type,'interface')">
276 <link><xsl:attribute name="linkend"><xsl:value-of select="$to"/></xsl:attribute><xsl:value-of select="$val"/></link>
281 <xsl:template match="doc:ref">
282 <xsl:call-template name="create-link">
283 <xsl:with-param name="type" select="@type"/>
284 <xsl:with-param name="to" select="@to"/>
285 <xsl:with-param name="val" select="."/>
289 <xsl:template name="method-doc">
290 <xsl:apply-templates select="doc:doc/doc:description"/>
292 <variablelist role="params">
293 <xsl:for-each select="arg">
294 <varlistentry><term><parameter><xsl:value-of select="@name"/></parameter>:</term>
295 <listitem><simpara><xsl:value-of select="doc:doc/doc:summary"/></simpara></listitem>
300 <xsl:apply-templates select="doc:doc/doc:since"/>
301 <xsl:apply-templates select="doc:doc/doc:deprecated"/>
302 <xsl:apply-templates select="doc:doc/doc:permission"/>
303 <xsl:apply-templates select="doc:doc/doc:seealso"/>
306 <xsl:template name="method-details">
307 <xsl:param name="basename"/>
308 <xsl:variable name="longest">
309 <xsl:call-template name="find-longest">
310 <xsl:with-param name="set" select="@name"/>
313 <xsl:for-each select="///method">
315 <title><anchor role="function"><xsl:attribute name="id"><xsl:value-of select="$basename"/>.<xsl:value-of select="@name"/></xsl:attribute></anchor><xsl:value-of select="@name"/> ()</title>
316 <indexterm><primary><xsl:value-of select="@name"/></primary><secondary><xsl:value-of select="$basename"/></secondary></indexterm>
317 <programlisting><xsl:value-of select="@name"/> (<xsl:call-template name="method-args"><xsl:with-param name="indent" select="string-length(@name) + 2"/><xsl:with-param name="prefix" select="."/></xsl:call-template>)</programlisting>
320 <xsl:call-template name="method-doc"/>
326 <xsl:template name="properties-synopsis">
327 <xsl:param name="basename"/>
328 <xsl:variable name="longest">
329 <xsl:call-template name="find-longest">
330 <xsl:with-param name="set" select="///property/@name"/>
333 <xsl:for-each select="///property">
334 <link><xsl:attribute name="linkend"><xsl:value-of select="$basename"/>:<xsl:value-of select="@name"/></xsl:attribute>'<xsl:value-of select="@name"/>'</link><xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="$longest - string-length(@name) + 1"/></xsl:call-template> <xsl:call-template name="property-args"><xsl:with-param name="indent" select="$longest + 2"/></xsl:call-template>
339 <xsl:template name="signals-synopsis">
340 <xsl:param name="basename"/>
341 <xsl:variable name="longest">
342 <xsl:call-template name="find-longest">
343 <xsl:with-param name="set" select="///signal/@name"/>
346 <xsl:for-each select="///signal">
347 <link><xsl:attribute name="linkend"><xsl:value-of select="$basename"/>::<xsl:value-of select="@name"/></xsl:attribute><xsl:value-of select="@name"/></link><xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="$longest - string-length(@name) + 1"/></xsl:call-template>(<xsl:call-template name="signal-args"><xsl:with-param name="indent" select="$longest + 2"/><xsl:with-param name="prefix" select="///signal"/></xsl:call-template>)
352 <xsl:template name="methods-synopsis">
353 <xsl:param name="basename"/>
354 <xsl:variable name="longest">
355 <xsl:call-template name="find-longest">
356 <xsl:with-param name="set" select="///method/@name"/>
359 <xsl:for-each select="///method">
360 <link><xsl:attribute name="linkend"><xsl:value-of select="$basename"/>.<xsl:value-of select="@name"/></xsl:attribute><xsl:value-of select="@name"/></link><xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="$longest - string-length(@name) + 1"/></xsl:call-template>(<xsl:call-template name="method-args"><xsl:with-param name="indent" select="$longest + 2"/><xsl:with-param name="prefix" select="///method"/></xsl:call-template>)
365 <xsl:template name="method-args"><xsl:param name="indent"/><xsl:param name="prefix"/><xsl:variable name="longest"><xsl:call-template name="find-longest"><xsl:with-param name="set" select="$prefix/arg/@type"/></xsl:call-template></xsl:variable><xsl:for-each select="arg"><xsl:value-of select="@direction"/>
366 <xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="4 - string-length(@direction)"/></xsl:call-template>'<xsl:value-of select="@type"/>'<xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="$longest - string-length(@type) + 1"/></xsl:call-template>
367 <xsl:value-of select="@name"/><xsl:if test="not(position() = last())">,
368 <xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="$indent"/></xsl:call-template></xsl:if>
373 <xsl:template name="signal-args"><xsl:param name="indent"/><xsl:param name="prefix"/><xsl:variable name="longest"><xsl:call-template name="find-longest"><xsl:with-param name="set" select="$prefix/arg/@type"/></xsl:call-template></xsl:variable><xsl:for-each select="arg">'<xsl:value-of select="@type"/>'<xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="$longest - string-length(@type) + 1"/></xsl:call-template>
374 <xsl:value-of select="@name"/><xsl:if test="not(position() = last())">,
375 <xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="$indent"/></xsl:call-template></xsl:if>
380 <xsl:template name="property-args"><xsl:param name="indent"/>
381 <xsl:value-of select="@access"/><xsl:call-template name="pad-spaces"><xsl:with-param name="width" select="9 - string-length(@access) + 1"/></xsl:call-template>'<xsl:value-of select="@type"/>'
385 <xsl:template name="pad-spaces">
386 <xsl:param name="width"/>
387 <xsl:variable name="spaces" xml:space="preserve"> </xsl:variable>
388 <xsl:value-of select="substring($spaces,1,$width)"/>
392 <xsl:template name="find-longest">
393 <xsl:param name="set"/>
394 <xsl:param name="index" select="1"/>
395 <xsl:param name="longest" select="0"/>
398 <xsl:when test="$index > count($set)">
399 <!--finished looking-->
400 <xsl:value-of select="$longest"/>
402 <xsl:when test="string-length($set[$index])>$longest">
403 <!--found new longest-->
404 <xsl:call-template name="find-longest">
405 <xsl:with-param name="set" select="$set"/>
406 <xsl:with-param name="index" select="$index + 1"/>
407 <xsl:with-param name="longest" select="string-length($set[$index])"/>
411 <!--this isn't any longer-->
412 <xsl:call-template name="find-longest">
413 <xsl:with-param name="set" select="$set"/>
414 <xsl:with-param name="index" select="$index + 1"/>
415 <xsl:with-param name="longest" select="$longest"/>
422 <xsl:template name="interface-basename">
423 <xsl:param name="str"/>
425 <xsl:when test="contains($str,'.')">
426 <xsl:call-template name="interface-basename">
427 <xsl:with-param name="str" select="substring-after($str,'.')"/>
431 <xsl:value-of select="$str"/>