macro:maybe-columns
[cxml-rng.git] / doc / html.xslx
blob56734e703860f544a5513ea5f628a26a8ed8df65
1 <!--
2     This is the main stylesheet.
3     Input must have been cleaned up using cleanup.xsl already.
5     This stylesheet does nearly all of the formatting work, but still keeps
6     all data together in one big XML document.
8     A <page> element is produced for each package and symbol.
10     The contents of each <page> will be mostly HTML, with the exception
11     of a few formatting elements like <columns> that are replaced later.
13   -->
14 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15                 xmlns:macro="http://lichteblau.com/macro"
16                 version="1.0">
17   <xsl:output method="xml" indent="yes"/>
19   <xsl:template match="/">
20     <pages>
21       <xsl:apply-templates select="documentation"/>
22       <xsl:apply-templates select="documentation/package"/>
23       <xsl:apply-templates select="documentation/package/symbols/*"/>
24     </pages>
25   </xsl:template>
28   <!--
29       page generation templates
30     -->
32   <xsl:template match="documentation">
33     <main-page title="@title">
34       Index of packages:
36       <columns>
37         <column width="60%">
38           <xsl:for-each select="package">
39             <h2>
40               <a href="pages/{@id}.html">
41                 Package
42                 <xsl:value-of select="@name"/>
43               </a>
44             </h2>
45             <div style="left: 100px">
46               <xsl:apply-templates select="documentation-string"/>
47             </div>
48           </xsl:for-each>
49         </column>
50         <column>
51           <h3><a name="index"></a>Symbol Index</h3>
52           <xsl:apply-templates select="package/symbols/*" mode="symbol-index">
53             <xsl:sort select="@name" data-type="text" order="ascending"/>
54             <xsl:with-param name="packagep" select="'pages/'"/>
55           </xsl:apply-templates>
56         </column>
57       </columns>
58     </main-page>
59   </xsl:template>
61   <xsl:template match="package">
62     <page base="../"
63           pathname="pages/{@id}.html"
64           title="Package {@name}">
65       <p class="noindent">
66         Up:
67         <a href="../index.html">
68           <xsl:value-of select="/documentation/@title"/>
69         </a>
70       </p>
71       <h1>
72         Package
73         <xsl:value-of select="@name"/>
74       </h1>
75       <xsl:apply-templates select="documentation-string"/>
76       <columns>
77         <column width="60%">
78           <xsl:if test="sections">
79             <div style="margin-left: -30px">
80               <h3>About This Package</h3>
81             </div>
82             <xsl:apply-templates select="sections/section" mode="toc"/>
83             <br/>
84             <xsl:apply-templates select="sections"/>
85           </xsl:if>
86         </column>
87         <column>
88           <h3><a name="index"></a>Symbol Index</h3>
89           <xsl:apply-templates select="symbols" mode="symbol-index"/>
90         </column>
91       </columns>
92     </page>
93   </xsl:template>
95   <xsl:template match="class-definition">
96     <page base="../"
97           pathname="pages/{@id}.html"
98           title="Class {@name}">
99       <p class="noindent">
100         Package:
101         <a href="{../../@id}.html">
102           <xsl:value-of select="../../@name"/>
103         </a>
104       </p>
105       <h2>
106         Class <xsl:value-of select="@name"/>
107       </h2>
108       <macro:maybe-columns test="see-also">
109         <h3>Superclasses</h3>
110         <div class="indent">
111           <xsl:for-each select="cpl/superclass">
112             <xsl:call-template name="class-list"/>
113           </xsl:for-each>
114         </div>
115         <h3>Documented Subclasses</h3>
116         <div class="indent">
117           <xsl:choose>
118             <xsl:when test="subclasses/subclass">
119               <xsl:for-each select="subclasses/subclass">
120                 <xsl:sort select="@id" data-type="text" order="ascending"/>
121                 <xsl:call-template name="class-list"/>
122               </xsl:for-each>
123             </xsl:when>
124             <xsl:otherwise>
125               None
126             </xsl:otherwise>
127           </xsl:choose>
128         </div>
129         <xsl:call-template name="main-left"/>
130       </macro:maybe-columns>
131     </page>
132   </xsl:template>
134   <xsl:template match="function-definition">
135     <page base="../"
136           pathname="pages/{@id}.html"
137           title="Function {@name}">
138       <p class="noindent">
139         Package:
140         <a href="{../../@id}.html">
141           <xsl:value-of select="../../@name"/>
142         </a>
143       </p>
144       <h2>
145         Function
146         <xsl:value-of select="@name"/>
147       </h2>
148       <macro:maybe-columns test="see-also">
149         <h3>Lambda List</h3>
150         <div class="indent">
151           <xsl:apply-templates select="lambda-list"/>
152         </div>
153         <xsl:apply-templates select="arguments"/>
154         <xsl:apply-templates select="return"/>
155         <xsl:call-template name="main-left"/>
156       </macro:maybe-columns>
157     </page>
158   </xsl:template>
160   <xsl:template match="macro-definition">
161     <page base="../"
162           pathname="pages/{@id}.html"
163           title="Macro {@name}">
164       <p class="noindent">
165         Package:
166         <a href="{../../@id}.html">
167           <xsl:value-of select="../../@name"/>
168         </a>
169       </p>
170       <h2>
171         Macro
172         <xsl:value-of select="@name"/>
173       </h2>
174       <xsl:apply-templates select="lambda-list"/>
175       <xsl:call-template name="main"/>
176     </page>
177   </xsl:template>
179   <xsl:template match="variable-definition">
180     <page base="../"
181           pathname="pages/{@id}.html"
182           title="Variable {@name}">
183       <p class="noindent">
184         Package:
185         <a href="{../../@id}.html">
186           <xsl:value-of select="../../@name"/>
187         </a>
188       </p>
189       <h2>
190         Variable
191         <xsl:value-of select="@name"/>
192       </h2>
193       <xsl:call-template name="main"/>
194     </page>
195   </xsl:template>
198   <!--
199       Symbol index
200     -->
201   <xsl:template match="*" mode="symbol-index"/>
203   <xsl:template match="symbols" mode="symbol-index">
204     <xsl:param name="packagep"/>
205     <xsl:apply-templates mode="symbol-index">
206       <xsl:sort select="@id" data-type="text" order="ascending"/>
207       <xsl:with-param name="packagep" select="$packagep"/>
208     </xsl:apply-templates>
209   </xsl:template>
211   <xsl:template name="undocumented">
212     <xsl:if test="not(documentation-string)">
213       <xsl:text>&#160;</xsl:text>
214       <span style="color: red">
215         (undocumented)
216       </span>
217     </xsl:if>
218   </xsl:template>
220   <xsl:template match="class-definition" mode="symbol-index">
221     <xsl:param name="packagep"/>
222     <a href="{$packagep}{@id}.html">
223       <tt>
224         <macro:maybe-package-prefix/>
225         <xsl:value-of select="@name"/>
226       </tt>
227     </a>
228     <xsl:text>, class</xsl:text>
229     <xsl:call-template name="undocumented"/>
230     <br/>
231   </xsl:template>
233   <xsl:template match="function-definition" mode="symbol-index">
234     <xsl:param name="packagep"/>
235     <a href="{$packagep}{@id}.html">
236       <tt>
237         <macro:maybe-package-prefix/>
238         <xsl:value-of select="@name"/>
239       </tt>
240     </a>
241     <xsl:text>, function</xsl:text>
242     <xsl:call-template name="undocumented"/>
243     <br/>
244   </xsl:template>
246   <xsl:template match="macro-definition" mode="symbol-index">
247     <xsl:param name="packagep"/>
248     <a href="{$packagep}{@id}.html">
249       <tt>
250         <macro:maybe-package-prefix/>
251         <xsl:value-of select="@name"/>
252       </tt>
253     </a>
254     <xsl:text>, macro</xsl:text>
255     <xsl:call-template name="undocumented"/>
256     <br/>
257   </xsl:template>
259   <xsl:template match="variable-definition" mode="symbol-index">
260     <xsl:param name="packagep"/>
261     <a href="{$packagep}{@id}.html">
262       <tt>
263         <macro:maybe-package-prefix/>
264         <xsl:value-of select="@name"/>
265       </tt>
266     </a>
267     <xsl:text>, variable</xsl:text>
268     <xsl:call-template name="undocumented"/>
269     <br/>
270   </xsl:template>
273   <!--
274       Other templates
275     -->
277   <xsl:template match="arguments">
278     <h3>Arguments</h3>
279     <div class="indent">
280       <ul>
281         <xsl:for-each select="arg">
282           <li>
283             <tt>
284               <xsl:value-of select="@arg"/>
285             </tt>
286             <xsl:text> -- </xsl:text>
287             <xsl:apply-templates/>
288           </li>
289         </xsl:for-each>
290       </ul>
291     </div>
292   </xsl:template>
294   <xsl:template name="main-left">
295     <xsl:choose>
296       <xsl:when test="documentation-string">
297         <h3>Details<a name="details"/></h3>
298         <xsl:apply-templates select="documentation-string"/>
299       </xsl:when>
300       <xsl:otherwise>
301         <p style="color: red; font-weight: bold">
302           No documentation string.  Possibly unimplemented or incomplete.
303         </p>
304       </xsl:otherwise>
305     </xsl:choose>
306     <xsl:apply-templates select="implementation-note"/>
307   </xsl:template>
309   <xsl:template name="main-right">
310     <xsl:if test="see-also/constructor">
311       <h3>Returned by</h3>
312       <div class="indent">
313         <simple-table>
314           <xsl:apply-templates select="see-also/constructor/see"/>
315         </simple-table>
316       </div>
317     </xsl:if>
318     <xsl:if test="see-also/slot">
319       <h3>Slot Access Functions</h3>
320       <div class="indent">
321         <simple-table>
322           <xsl:apply-templates select="see-also/slot/see"/>
323         </simple-table>
324       </div>
325     </xsl:if>
326     <xsl:if test="see-also/other">
327       <h3>See also</h3>
328       <div class="indent">
329         <simple-table>
330           <xsl:apply-templates select="see-also/other/see"/>
331         </simple-table>
332       </div>
333     </xsl:if>
334   </xsl:template>
336   <xsl:template name="main">
337     <macro:maybe-columns test="see-also">
338       <xsl:call-template name="main-left"/>
339     </macro:maybe-columns>
340   </xsl:template>
342   <xsl:template name="class-list">
343     <xsl:if test="position() != 1">
344       <xsl:text>, </xsl:text>
345     </xsl:if>
346     <xsl:choose>
347       <xsl:when test="@id">
348         <a href="{@id}.html">
349           <tt>
350             <xsl:if test="@status = 'INTERNAL'">
351               <xsl:value-of select="@package"/>
352               <xsl:text>::</xsl:text>
353             </xsl:if>
354             <xsl:value-of select="@name"/>
355           </tt>
356         </a>
357       </xsl:when>
358       <xsl:when test="@status = 'INTERNAL'">
359         <tt style="color: #777777">
360           <xsl:value-of select="@package"/>
361           <xsl:text>::</xsl:text>
362           <xsl:value-of select="@name"/>
363         </tt>
364       </xsl:when>         
365       <xsl:otherwise>
366         <tt style="color: #777777">
367           <xsl:value-of select="@package"/>
368           <xsl:text>:</xsl:text>
369           <xsl:value-of select="@name"/>
370         </tt>
371       </xsl:otherwise>
372     </xsl:choose>
373   </xsl:template>
375   <xsl:template match="lambda-list">
376     <tt><xsl:value-of select="../@name"/></tt>
377     <xsl:text> (</xsl:text>
378     <xsl:for-each select="elt">
379       <xsl:if test="position() != 1">
380         <xsl:text>&#160;</xsl:text>
381       </xsl:if>
382       <b><xsl:value-of select="text()"/></b>
383     </xsl:for-each>
384     <xsl:text>)</xsl:text>
385   </xsl:template>
387   <xsl:template mode="about-arguments" match="lambda-list">
388     <div class="def">
389       <a href="{../@id}.html">
390         Function
391         <xsl:value-of select="../@name"/>
392         <xsl:text> (</xsl:text>
393         <xsl:for-each select="elt">
394           <xsl:if test="position() != 1">
395             <xsl:text>&#160;</xsl:text>
396           </xsl:if>
397           <xsl:value-of select="text()"/>
398         </xsl:for-each>
399         <xsl:text>)</xsl:text>
400       </a>
401     </div>
402   </xsl:template>
404   <xsl:template match="documentation-string">
405     <div class="indent">
406       <xsl:apply-templates/>
407     </div>
408   </xsl:template>
410   <xsl:template match="short">
411     <xsl:apply-templates/>
412   </xsl:template>
414   <xsl:template match="em">
415     <i>
416       <xsl:apply-templates/>
417     </i>
418   </xsl:template>
420   <xsl:template match="var">
421     <tt>
422       <xsl:apply-templates/>
423     </tt>
424   </xsl:template>
426   <xsl:template match="code">
427     <tt>
428       <xsl:apply-templates/>
429     </tt>
430   </xsl:template>
432   <xsl:template match="a">
433     <a href="{@a}">
434       <xsl:apply-templates/>
435     </a>
436   </xsl:template>
438   <xsl:template match="fun">
439     <a href="{@id}.html">
440       <tt>
441         <xsl:apply-templates/>
442       </tt>
443     </a>
444   </xsl:template>
446   <xsl:template match="class">
447     <a href="{@id}.html">
448       <tt>
449         <xsl:apply-templates/>
450       </tt>
451     </a>
452   </xsl:template>
454   <xsl:template match="variable">
455     <a href="{@id}.html">
456       <tt>
457         <xsl:apply-templates/>
458       </tt>
459     </a>
460   </xsl:template>
462   <xsl:template match="itemize">
463     <ul>
464       <xsl:apply-templates/>
465     </ul>
466   </xsl:template>
468   <xsl:template match="item">
469     <li>
470       <xsl:apply-templates/>
471     </li>
472   </xsl:template>
474   <xsl:template match="see">
475     <tr>
476       <td>
477         <a href="{@id}.html">
478           <tt>
479             <xsl:apply-templates/>
480           </tt>
481         </a>
482       </td>
483       <xsl:if test="@see">
484         <td>
485           &#160;&#160;&#160;&#160;
486           <i>
487             <xsl:value-of select="@see"/>
488           </i>
489         </td>
490       </xsl:if>
491     </tr>
492   </xsl:template>
494   <xsl:template match="return">
495     <h3>Return Value</h3>
496     <div class="indent">
497       <xsl:apply-templates/>
498     </div>
499   </xsl:template>
501   <xsl:template match="implementation-note">
502     <h3>Implementation notes</h3>
503     <xsl:apply-templates/>
504   </xsl:template>
506   <xsl:template match="break">
507     <br/><br/>
508   </xsl:template>
510   <xsl:template match="sections">
511     <xsl:for-each select="section">
512       <h2>
513         <a name="{generate-id()}"/>
514         <xsl:value-of select="@section"/>
515       </h2>
516       <xsl:apply-templates/>
517     </xsl:for-each>
518   </xsl:template>
520   <xsl:template match="section" mode="toc">
521     <a href="#{generate-id()}" style="font-weight: bold">
522       <xsl:value-of select="@section"/>
523     </a>
524     <br/>
525   </xsl:template>
527   <xsl:template match="aboutfun">
528     <xsl:variable name="fun" select="text()"/>
529     <xsl:apply-templates
530        mode="about-arguments"
531        select="//function-definition[@name=$fun]/lambda-list"/>
532     <div style="margin-left: 3em">
533       <xsl:choose>
534         <xsl:when
535            test="//function-definition[@name=$fun]/documentation-string//short">
536           <xsl:for-each select="//function-definition[@name=$fun]">
537             <xsl:apply-templates select="documentation-string//short"/>
538             <xsl:text> </xsl:text>
539             <a href="{@id}.html#details">...</a>
540           </xsl:for-each>
541         </xsl:when>
542         <xsl:otherwise>
543           <xsl:apply-templates
544              select="//function-definition[@name=$fun]/documentation-string"/>
545         </xsl:otherwise>
546       </xsl:choose>
547     </div>
548     <br/>
549   </xsl:template>
551   <xsl:template match="aboutclass">
552     <xsl:variable name="name" select="text()"/>
553     <xsl:for-each select="//class-definition[@name=$name]">
554       <div class="def">
555         <a href="{@id}.html">
556           Class
557           <xsl:value-of select="@name"/>
558         </a>
559       </div>
560     </xsl:for-each>
561     <div style="margin-left: 3em">
562       <xsl:choose>
563         <xsl:when
564            test="//class-definition[@name=$name]/documentation-string//short">
565           <xsl:for-each select="//class-definition[@name=$name]">
566             <xsl:apply-templates select="documentation-string//short"/>
567             <xsl:text> </xsl:text>
568             <a href="{@id}.html#details">...</a>
569           </xsl:for-each>
570         </xsl:when>
571         <xsl:otherwise>
572           <xsl:apply-templates
573              select="//class-definition[@name=$name]/documentation-string"/>
574         </xsl:otherwise>
575       </xsl:choose>
576     </div>
577     <br/>
578   </xsl:template>
579 </xsl:stylesheet>