Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / asio / doc / tutorial.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
4 <!--
5   Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6
7   Distributed under the Boost Software License, Version 1.0. (See accompanying
8   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 -->
10
11 <xsl:output method="text"/>
12 <xsl:strip-space elements="*"/>
13
14
15 <xsl:variable name="newline">
16 <xsl:text>
17 </xsl:text>
18 </xsl:variable>
19
20
21 <xsl:template match="/doxygen">
22 <xsl:text>[/
23  / Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
24  /
25  / Distributed under the Boost Software License, Version 1.0. (See accompanying
26  / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
27  /]
28
29 [section:tutorial Tutorial]
30
31 </xsl:text>
32
33   <xsl:for-each select="compounddef[@kind = 'page' and @id = 'indexpage']">
34     <xsl:apply-templates select="detaileddescription"/>
35   </xsl:for-each>
36
37   <xsl:for-each select="
38       compounddef[
39         @kind = 'page' and
40         @id != 'indexpage' and
41         not(contains(@id, 'src'))]">
42     <xsl:text>[section:</xsl:text>
43     <xsl:value-of select="concat(@id, ' ', title)"/>
44     <xsl:text>]</xsl:text>
45     <xsl:value-of select="$newline"/>
46     <xsl:value-of select="$newline"/>
47     <xsl:apply-templates select="detaileddescription"/>
48     <xsl:variable name="srcid" select="concat(@id, 'src')"/>
49     <xsl:if test="count(/doxygen/compounddef[@id = $srcid]) &gt; 0">
50       <xsl:value-of select="$newline"/>
51       <xsl:value-of select="$newline"/>
52       <xsl:text>[section:src </xsl:text>
53       <xsl:value-of select="/doxygen/compounddef[@id = $srcid]/title"/>
54       <xsl:text>]</xsl:text>
55       <xsl:value-of select="$newline"/>
56       <xsl:value-of select="$newline"/>
57       <xsl:apply-templates select="/doxygen/compounddef[@id = $srcid]/detaileddescription"/>
58       <xsl:text>[endsect]</xsl:text>
59       <xsl:value-of select="$newline"/>
60       <xsl:value-of select="$newline"/>
61     </xsl:if>
62     <xsl:text>[endsect]</xsl:text>
63     <xsl:value-of select="$newline"/>
64     <xsl:value-of select="$newline"/>
65   </xsl:for-each>
66
67   <xsl:value-of select="$newline"/>
68   <xsl:text>[endsect]</xsl:text>
69
70 </xsl:template>
71
72
73 <!--========== Utilities ==========-->
74
75 <xsl:template name="strip-asio-ns">
76   <xsl:param name="name"/>
77   <xsl:choose>
78     <xsl:when test="contains($name, 'boost::system::is_error_code_enum')">
79       <xsl:value-of select="$name"/>
80     </xsl:when>
81     <xsl:when test="contains($name, 'asio::')">
82       <xsl:value-of select="substring-after($name, 'asio::')"/>
83     </xsl:when>
84     <xsl:otherwise>
85       <xsl:value-of select="$name"/>
86     </xsl:otherwise>
87   </xsl:choose>
88 </xsl:template>
89
90
91 <xsl:template name="make-id">
92   <xsl:param name="name"/>
93   <xsl:choose>
94     <xsl:when test="contains($name, '::')">
95       <xsl:call-template name="make-id">
96         <xsl:with-param name="name"
97          select="concat(substring-before($name, '::'), '__', substring-after($name, '::'))"/>
98       </xsl:call-template>
99     </xsl:when>
100     <xsl:when test="contains($name, '=')">
101       <xsl:call-template name="make-id">
102         <xsl:with-param name="name"
103          select="concat(substring-before($name, '='), '_eq_', substring-after($name, '='))"/>
104       </xsl:call-template>
105     </xsl:when>
106     <xsl:when test="contains($name, '!')">
107       <xsl:call-template name="make-id">
108         <xsl:with-param name="name"
109          select="concat(substring-before($name, '!'), '_not_', substring-after($name, '!'))"/>
110       </xsl:call-template>
111     </xsl:when>
112     <xsl:when test="contains($name, '&lt;')">
113       <xsl:call-template name="make-id">
114         <xsl:with-param name="name"
115          select="concat(substring-before($name, '&lt;'), '_lt_', substring-after($name, '&lt;'))"/>
116       </xsl:call-template>
117     </xsl:when>
118     <xsl:when test="contains($name, '&gt;')">
119       <xsl:call-template name="make-id">
120         <xsl:with-param name="name"
121          select="concat(substring-before($name, '&gt;'), '_gt_', substring-after($name, '&gt;'))"/>
122       </xsl:call-template>
123     </xsl:when>
124     <xsl:when test="contains($name, '+')">
125       <xsl:call-template name="make-id">
126         <xsl:with-param name="name"
127          select="concat(substring-before($name, '+'), '_plus_', substring-after($name, '+'))"/>
128       </xsl:call-template>
129     </xsl:when>
130     <xsl:when test="contains($name, '~')">
131       <xsl:call-template name="make-id">
132         <xsl:with-param name="name"
133          select="concat(substring-before($name, '~'), '_', substring-after($name, '~'))"/>
134       </xsl:call-template>
135     </xsl:when>
136     <xsl:when test="contains($name, ' ')">
137       <xsl:call-template name="make-id">
138         <xsl:with-param name="name"
139          select="concat(substring-before($name, ' '), '_', substring-after($name, ' '))"/>
140       </xsl:call-template>
141     </xsl:when>
142     <xsl:when test="contains($name, 'boost__posix_time__ptime')">
143       <xsl:call-template name="make-id">
144         <xsl:with-param name="name"
145          select="concat(substring-before($name, 'boost__posix_time__ptime'), 'ptime', substring-after($name, 'boost__posix_time__ptime'))"/>
146       </xsl:call-template>
147     </xsl:when>
148     <xsl:otherwise>
149       <xsl:value-of select="$name"/>
150     </xsl:otherwise>
151   </xsl:choose>
152 </xsl:template>
153
154
155 <xsl:template name="replace-scope-marker">
156   <xsl:param name="text"/>
157   <xsl:choose>
158     <xsl:when test="contains($text, '_1_1')">
159       <xsl:call-template name="replace-scope-marker">
160         <xsl:with-param name="text"
161          select="concat(substring-before($text, '_1_1'), '::', substring-after($text, '_1_1'))"/>
162       </xsl:call-template>
163     </xsl:when>
164     <xsl:otherwise>
165       <xsl:value-of select="$text"/>
166     </xsl:otherwise>
167   </xsl:choose>
168 </xsl:template>
169
170
171 <xsl:template name="refid-to-anchor">
172   <xsl:param name="text"/>
173   <xsl:variable name="scoped-text">
174     <xsl:call-template name="replace-scope-marker">
175       <xsl:with-param name="text" select="$text"/>
176     </xsl:call-template>
177   </xsl:variable>
178   <xsl:value-of select="substring-after($scoped-text, '_1')"/>
179 </xsl:template>
180
181
182 <!--========== Markup ==========-->
183
184 <xsl:template match="para">
185   <xsl:apply-templates/>
186   <xsl:value-of select="$newline"/>
187   <xsl:value-of select="$newline"/>
188 </xsl:template>
189
190
191 <xsl:template match="title">
192   <xsl:variable name="title">
193     <xsl:value-of select="."/>
194   </xsl:variable>
195   <xsl:if test="string-length($title) > 0">
196     <xsl:text>[heading </xsl:text>
197     <xsl:value-of select="."/>
198     <xsl:text>]</xsl:text>
199     <xsl:value-of select="$newline"/>
200     <xsl:value-of select="$newline"/>
201   </xsl:if>
202 </xsl:template>
203
204
205 <xsl:template match="programlisting">
206   <xsl:value-of select="$newline"/>
207   <xsl:apply-templates/>
208   <xsl:value-of select="$newline"/>
209 </xsl:template>
210
211
212 <xsl:template match="codeline">
213   <xsl:if test="string-length(.) &gt; 0">
214     <xsl:text>  ``''''''``</xsl:text>
215   </xsl:if>
216   <xsl:apply-templates mode="codeline"/>
217   <xsl:value-of select="$newline"/>
218 </xsl:template>
219
220
221 <xsl:template match="sp">
222   <xsl:text> </xsl:text>
223 </xsl:template>
224
225
226 <xsl:template match="sp" mode="codeline">
227   <xsl:text> </xsl:text>
228 </xsl:template>
229
230
231 <xsl:template match="linebreak">
232   <xsl:value-of select="$newline"/>
233   <xsl:value-of select="$newline"/>
234 </xsl:template>
235
236
237 <xsl:template match="listitem">
238   <xsl:text>* </xsl:text>
239   <xsl:apply-templates/>
240   <xsl:value-of select="$newline"/>
241 </xsl:template>
242
243
244 <xsl:template match="emphasis">
245   <xsl:text>[*</xsl:text>
246   <xsl:value-of select="."/>
247   <xsl:text>]</xsl:text>
248 </xsl:template>
249
250
251 <xsl:template match="computeroutput">
252   <xsl:text>`</xsl:text>
253   <xsl:value-of select="."/>
254   <xsl:text>`</xsl:text>
255 </xsl:template>
256
257
258 <xsl:template match="text()">
259   <xsl:variable name="text" select="."/>
260   <xsl:variable name="starts-with-whitespace" select="
261       starts-with($text, ' ') or starts-with($text, $newline)"/>
262   <xsl:variable name="preceding-node-name">
263     <xsl:for-each select="preceding-sibling::*">
264       <xsl:if test="position() = last()">
265         <xsl:value-of select="local-name()"/>
266       </xsl:if>
267     </xsl:for-each>
268   </xsl:variable>
269   <xsl:variable name="after-newline" select="
270       $preceding-node-name = 'programlisting' or
271       $preceding-node-name = 'linebreak'"/>
272   <xsl:choose>
273     <xsl:when test="$starts-with-whitespace and $after-newline">
274       <xsl:call-template name="escape-text">
275         <xsl:with-param name="text">
276           <xsl:call-template name="strip-leading-whitespace">
277             <xsl:with-param name="text" select="$text"/>
278           </xsl:call-template>
279         </xsl:with-param>
280       </xsl:call-template>
281     </xsl:when>
282     <xsl:otherwise>
283       <xsl:call-template name="escape-text">
284         <xsl:with-param name="text" select="$text"/>
285       </xsl:call-template>
286     </xsl:otherwise>
287   </xsl:choose>
288 </xsl:template>
289
290
291 <xsl:template name="strip-leading-whitespace">
292   <xsl:param name="text"/>
293   <xsl:choose>
294     <xsl:when test="starts-with($text, ' ')">
295       <xsl:call-template name="strip-leading-whitespace">
296         <xsl:with-param name="text" select="substring($text, 2)"/>
297       </xsl:call-template>
298     </xsl:when>
299     <xsl:when test="starts-with($text, $newline)">
300       <xsl:call-template name="strip-leading-whitespace">
301         <xsl:with-param name="text" select="substring($text, 2)"/>
302       </xsl:call-template>
303     </xsl:when>
304     <xsl:otherwise>
305       <xsl:value-of select="$text"/>
306     </xsl:otherwise>
307   </xsl:choose>
308 </xsl:template>
309
310
311 <xsl:template name="escape-text">
312   <xsl:param name="text"/>
313   <xsl:choose>
314     <xsl:when test="contains($text, '_')">
315       <xsl:value-of select="substring-before($text, '_')"/>
316       <xsl:text>\_</xsl:text>
317       <xsl:call-template name="escape-text">
318         <xsl:with-param name="text" select="substring-after($text, '_')"/>
319       </xsl:call-template>
320     </xsl:when>
321     <xsl:otherwise>
322       <xsl:value-of select="$text"/>
323     </xsl:otherwise>
324   </xsl:choose>
325 </xsl:template>
326
327
328 <xsl:template match="ref[@kindref='compound']">
329   <xsl:variable name="name">
330     <xsl:value-of select="."/>
331   </xsl:variable>
332   <xsl:variable name="refid">
333     <xsl:value-of select="@refid"/>
334   </xsl:variable>
335   <xsl:choose>
336     <xsl:when test="count(/doxygen/compounddef[@id=$refid]) &gt; 0">
337       <xsl:text>[link boost_asio.tutorial.</xsl:text>
338       <xsl:choose>
339         <xsl:when test="contains($refid, 'src')">
340           <xsl:value-of select="substring-before($refid, 'src')"/>
341           <xsl:text>.src</xsl:text>
342         </xsl:when>
343         <xsl:otherwise>
344           <xsl:value-of select="$refid"/>
345         </xsl:otherwise>
346       </xsl:choose>
347       <xsl:value-of select="concat(' ', .)"/>
348       <xsl:text>]</xsl:text>
349     </xsl:when>
350     <xsl:when test="contains($name, 'asio::')">
351       <xsl:variable name="ref-name">
352         <xsl:call-template name="strip-asio-ns">
353           <xsl:with-param name="name" select="$name"/>
354         </xsl:call-template>
355       </xsl:variable>
356       <xsl:variable name="ref-id">
357         <xsl:call-template name="make-id">
358           <xsl:with-param name="name" select="$ref-name"/>
359         </xsl:call-template>
360       </xsl:variable>
361 [link boost_asio.reference.<xsl:value-of select="$ref-id"/><xsl:text> </xsl:text><xsl:value-of
362  select="$ref-name"/>]</xsl:when>
363     <xsl:otherwise>
364       <xsl:apply-templates/>
365     </xsl:otherwise>
366   </xsl:choose>
367 </xsl:template>
368
369
370 <xsl:template match="ref[@kindref='member']">
371   <xsl:variable name="refid">
372     <xsl:value-of select="@refid"/>
373   </xsl:variable>
374   <xsl:variable name="text">
375     <xsl:call-template name="strip-asio-ns">
376       <xsl:with-param name="name" select="."/>
377     </xsl:call-template>
378   </xsl:variable>
379   <xsl:choose>
380     <xsl:when test="$refid='index_1index'">
381       <xsl:text>[link boost_asio.tutorial </xsl:text>
382       <xsl:value-of select="$text"/>
383       <xsl:text>]</xsl:text>
384     </xsl:when>
385     <xsl:when test="@external='reference.tags'">
386       <xsl:variable name="anchor">
387         <xsl:call-template name="refid-to-anchor">
388           <xsl:with-param name="text" select="$refid"/>
389         </xsl:call-template>
390       </xsl:variable>
391       <xsl:choose>
392         <xsl:when test="count(document('reference.tags')/tagfile/compound[@kind='class']/member[anchor=$anchor]) &gt; 0">
393           <xsl:for-each select="document('reference.tags')/tagfile/compound[@kind='class']/member[anchor=$anchor]">
394             <xsl:variable name="scope">
395               <xsl:call-template name="make-id">
396                 <xsl:with-param name="name">
397                   <xsl:call-template name="strip-asio-ns">
398                     <xsl:with-param name="name" select="../name"/>
399                   </xsl:call-template>
400                 </xsl:with-param>
401               </xsl:call-template>
402             </xsl:variable>
403             <xsl:variable name="name">
404               <xsl:call-template name="make-id">
405                 <xsl:with-param name="name" select="name"/>
406               </xsl:call-template>
407             </xsl:variable>
408             <xsl:text>[link boost_asio.reference.</xsl:text>
409             <xsl:if test="string-length($scope) &gt; 0">
410               <xsl:value-of select="$scope"/><xsl:text>.</xsl:text>
411             </xsl:if>
412             <xsl:value-of select="$name"/>
413             <xsl:text> </xsl:text><xsl:value-of select="$text"/><xsl:text>]</xsl:text>
414           </xsl:for-each>
415         </xsl:when>
416         <xsl:otherwise>
417           <xsl:apply-templates/>
418         </xsl:otherwise>
419       </xsl:choose>
420     </xsl:when>
421     <xsl:otherwise>
422       <xsl:apply-templates/>
423     </xsl:otherwise>
424   </xsl:choose>
425 </xsl:template>
426
427
428 <xsl:template match="ulink">
429   <xsl:text>[@</xsl:text>
430   <xsl:value-of select="@url"/>
431   <xsl:text> </xsl:text>
432   <xsl:value-of select="."/>
433   <xsl:text>]</xsl:text>
434 </xsl:template>
435
436
437 </xsl:stylesheet>