doc.css aufgeraeumt
[cxml-rng.git] / doc / html.xsl
blobcd001620f7f9bdc75fe60e3c55e96f61c948e4b0
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 <padded>
35 Index of packages:
36 </padded>
38 <columns>
39 <column width="60%">
40 <padded>
41 <xsl:for-each select="package">
42 <xsl:variable name="url"
43 select="concat('pages/', @id, '.html')"/>
44 <h2>
45 <a href="{$url}">
46 Package
47 <xsl:value-of select="@name"/>
48 </a>
49 </h2>
50 <div style="left: 100px">
51 <xsl:apply-templates select="documentation-string"/>
52 <div class="indent">
53 <xsl:if test="sections">
54 <p><i>About this package:</i></p>
55 <ul>
56 <xsl:for-each select="sections/section">
57 <li>
58 <a href="{$url}#{generate-id()}">
59 <xsl:value-of select="@section"/>
60 </a>
61 </li>
62 </xsl:for-each>
63 </ul>
64 </xsl:if>
65 </div>
66 </div>
67 </xsl:for-each>
68 </padded>
69 </column>
70 <column>
71 <h3><a name="index"></a>Symbol Index</h3>
72 <simple-table>
73 <xsl:apply-templates select="package/symbols/*"
74 mode="symbol-index">
75 <xsl:sort select="@name" data-type="text" order="ascending"/>
76 <xsl:with-param name="packagep" select="'pages/'"/>
77 </xsl:apply-templates>
78 </simple-table>
79 </column>
80 </columns>
81 </main-page>
82 </xsl:template>
84 <xsl:template match="package">
85 <page base="../"
86 pathname="pages/{@id}.html"
87 title="Package {@name}">
88 <padded>
89 <p class="noindent">
90 Up:
91 <a href="../index.html">
92 <xsl:value-of select="/documentation/@title"/>
93 </a>
94 </p>
95 <h1>
96 Package
97 <xsl:value-of select="@name"/>
98 </h1>
99 <xsl:apply-templates select="documentation-string"/>
100 </padded>
101 <columns>
102 <column width="60%">
103 <padded>
104 <xsl:if test="sections">
105 <div style="margin-left: -30px">
106 <h3>About This Package</h3>
107 </div>
108 <xsl:for-each select="sections/section">
109 <a href="#{generate-id()}" style="font-weight: bold">
110 <xsl:value-of select="@section"/>
111 </a>
112 <br/>
113 </xsl:for-each>
114 <br/>
115 <xsl:apply-templates select="sections"/>
116 </xsl:if>
117 </padded>
118 </column>
119 <column>
120 <h3><a name="index"></a>Symbol Index</h3>
121 <xsl:apply-templates select="symbols" mode="symbol-index"/>
122 </column>
123 </columns>
124 </page>
125 </xsl:template>
127 <xsl:template match="class-definition">
128 <page base="../"
129 pathname="pages/{@id}.html"
130 title="Class {@name}">
131 <padded>
132 <p class="noindent">
133 Package:
134 <a href="{../../@id}.html">
135 <xsl:value-of select="../../@name"/>
136 </a>
137 </p>
138 <h2>
139 Class <xsl:value-of select="@name"/>
140 </h2>
141 </padded>
142 <macro:maybe-columns
143 test="see-also
144 or //class-definition[@id=current()//superclass/@id]
145 //see-also/slot">
146 <padded>
147 <h3>Superclasses</h3>
148 <div class="indent">
149 <xsl:for-each select="cpl/superclass">
150 <xsl:call-template name="class-list"/>
151 </xsl:for-each>
152 </div>
153 <h3>Documented Subclasses</h3>
154 <div class="indent">
155 <xsl:choose>
156 <xsl:when test="subclasses/subclass">
157 <xsl:for-each select="subclasses/subclass">
158 <xsl:sort select="@id" data-type="text" order="ascending"/>
159 <xsl:call-template name="class-list"/>
160 </xsl:for-each>
161 </xsl:when>
162 <xsl:otherwise>
163 None
164 </xsl:otherwise>
165 </xsl:choose>
166 </div>
167 <xsl:call-template name="main-left"/>
168 </padded>
169 </macro:maybe-columns>
170 </page>
171 </xsl:template>
173 <xsl:template match="function-definition">
174 <page base="../"
175 pathname="pages/{@id}.html"
176 title="Function {@name}">
177 <padded>
178 <p class="noindent">
179 Package:
180 <a href="{../../@id}.html">
181 <xsl:value-of select="../../@name"/>
182 </a>
183 </p>
184 <h2>
185 Function
186 <xsl:value-of select="@name"/>
187 </h2>
188 </padded>
189 <macro:maybe-columns test="see-also">
190 <padded>
191 <h3>Lambda List</h3>
192 <div class="indent">
193 <xsl:apply-templates select="lambda-list"/>
194 </div>
195 <xsl:apply-templates select="arguments"/>
196 <xsl:apply-templates select="return"/>
197 <xsl:call-template name="main-left"/>
198 </padded>
199 </macro:maybe-columns>
200 </page>
201 </xsl:template>
203 <xsl:template match="macro-definition">
204 <page base="../"
205 pathname="pages/{@id}.html"
206 title="Macro {@name}">
207 <padded>
208 <p class="noindent">
209 Package:
210 <a href="{../../@id}.html">
211 <xsl:value-of select="../../@name"/>
212 </a>
213 </p>
214 <h2>
215 Macro
216 <xsl:value-of select="@name"/>
217 </h2>
218 <xsl:apply-templates select="lambda-list"/>
219 <xsl:call-template name="main"/>
220 </padded>
221 </page>
222 </xsl:template>
224 <xsl:template match="variable-definition">
225 <page base="../"
226 pathname="pages/{@id}.html"
227 title="Variable {@name}">
228 <padded>
229 <p class="noindent">
230 Package:
231 <a href="{../../@id}.html">
232 <xsl:value-of select="../../@name"/>
233 </a>
234 </p>
235 <h2>
236 Variable
237 <xsl:value-of select="@name"/>
238 </h2>
239 <xsl:call-template name="main"/>
240 </padded>
241 </page>
242 </xsl:template>
245 <!--
246 Symbol index
248 <xsl:template match="*" mode="symbol-index"/>
250 <xsl:template match="symbols" mode="symbol-index">
251 <xsl:param name="packagep"/>
252 <simple-table>
253 <xsl:apply-templates mode="symbol-index">
254 <xsl:sort select="@id" data-type="text" order="ascending"/>
255 <xsl:with-param name="packagep" select="$packagep"/>
256 </xsl:apply-templates>
257 </simple-table>
258 </xsl:template>
260 <xsl:template name="index-entry">
261 <xsl:param name="packagep"/>
262 <xsl:param name="kind"/>
264 <row>
265 <xsl:if test="$packagep">
266 <cell align="right">
267 <span class="nonlink">
268 <tt>
269 <span style="color: #777777">
270 <xsl:value-of select="../../@name"/>
271 <xsl:text>:</xsl:text>
272 </span>
273 </tt>
274 </span>
275 </cell>
276 </xsl:if>
277 <cell>
278 <a href="{$packagep}{@id}.html">
279 <tt>
280 <xsl:value-of select="@name"/>
281 </tt>
282 </a>
283 <xsl:text>, </xsl:text>
284 <xsl:value-of select="$kind"/>
285 <xsl:call-template name="undocumented"/>
286 </cell>
287 </row>
288 </xsl:template>
290 <xsl:template match="class-definition" mode="symbol-index">
291 <xsl:param name="packagep"/>
292 <xsl:call-template name="index-entry">
293 <xsl:with-param name="packagep" select="$packagep"/>
294 <xsl:with-param name="kind" select="'class'"/>
295 </xsl:call-template>
296 </xsl:template>
298 <xsl:template match="function-definition" mode="symbol-index">
299 <xsl:param name="packagep"/>
300 <xsl:call-template name="index-entry">
301 <xsl:with-param name="packagep" select="$packagep"/>
302 <xsl:with-param name="kind" select="'function'"/>
303 </xsl:call-template>
304 </xsl:template>
306 <xsl:template match="macro-definition" mode="symbol-index">
307 <xsl:param name="packagep"/>
308 <xsl:call-template name="index-entry">
309 <xsl:with-param name="packagep" select="$packagep"/>
310 <xsl:with-param name="kind" select="'macro'"/>
311 </xsl:call-template>
312 </xsl:template>
314 <xsl:template match="variable-definition" mode="symbol-index">
315 <xsl:param name="packagep"/>
316 <xsl:call-template name="index-entry">
317 <xsl:with-param name="packagep" select="$packagep"/>
318 <xsl:with-param name="kind" select="'variable'"/>
319 </xsl:call-template>
320 </xsl:template>
323 <!--
324 Other templates
327 <xsl:template match="arguments">
328 <h3>Arguments</h3>
329 <div class="indent">
330 <ul>
331 <xsl:for-each select="arg">
332 <li>
333 <tt>
334 <xsl:value-of select="@arg"/>
335 </tt>
336 <xsl:text> -- </xsl:text>
337 <xsl:apply-templates/>
338 </li>
339 </xsl:for-each>
340 </ul>
341 </div>
342 </xsl:template>
344 <xsl:template name="main-left">
345 <xsl:choose>
346 <xsl:when test="documentation-string">
347 <h3>Details<a name="details"/></h3>
348 <xsl:apply-templates select="documentation-string"/>
349 </xsl:when>
350 <xsl:otherwise>
351 <p style="color: red; font-weight: bold">
352 No documentation string. Possibly unimplemented or incomplete.
353 </p>
354 </xsl:otherwise>
355 </xsl:choose>
356 <xsl:apply-templates select="implementation-note"/>
357 </xsl:template>
359 <xsl:template name="main-right">
360 <xsl:if test="see-also/constructor">
361 <h3>Returned by</h3>
362 <div class="indent">
363 <simple-table>
364 <xsl:apply-templates select="see-also/constructor/see"/>
365 </simple-table>
366 </div>
367 </xsl:if>
368 <xsl:if test="see-also/slot">
369 <h3>Slot Access Functions</h3>
370 <div class="indent">
371 <simple-table>
372 <xsl:apply-templates select="see-also/slot/see"/>
373 </simple-table>
374 </div>
375 </xsl:if>
376 <xsl:if
377 test="//class-definition[@id=current()//superclass/@id]
378 //see-also
379 /slot">
380 <h3>Inherited Slot Access Functions</h3>
381 <div class="indent">
382 <simple-table>
383 <xsl:apply-templates
384 select="//class-definition[@id=current()//superclass/@id]
385 //see-also/slot/see"/>
386 </simple-table>
387 </div>
388 </xsl:if>
389 <xsl:if test="see-also/other|see-also/auto">
390 <h3>See also</h3>
391 <div class="indent">
392 <simple-table>
393 <xsl:for-each select="see-also/other/see|see-also/auto/see">
394 <xsl:variable name="name" select="text()"/>
395 <xsl:if test="not(preceding-sibling::see[text() = $name])">
396 <xsl:apply-templates select="."/>
397 </xsl:if>
398 </xsl:for-each>
399 </simple-table>
400 </div>
401 </xsl:if>
402 </xsl:template>
404 <xsl:template name="main">
405 <macro:maybe-columns test="see-also">
406 <xsl:call-template name="main-left"/>
407 </macro:maybe-columns>
408 </xsl:template>
410 <xsl:template name="class-list">
411 <xsl:if test="position() != 1">
412 <xsl:text>, </xsl:text>
413 </xsl:if>
414 <xsl:choose>
415 <xsl:when test="@id">
416 <a href="{@id}.html">
417 <tt>
418 <xsl:if test="@status = 'INTERNAL'">
419 <xsl:value-of select="@package"/>
420 <xsl:text>::</xsl:text>
421 </xsl:if>
422 <xsl:value-of select="@name"/>
423 </tt>
424 </a>
425 </xsl:when>
426 <xsl:when test="@status = 'INTERNAL'">
427 <tt style="color: #777777">
428 <xsl:value-of select="@package"/>
429 <xsl:text>::</xsl:text>
430 <xsl:value-of select="@name"/>
431 </tt>
432 </xsl:when>
433 <xsl:otherwise>
434 <tt style="color: #777777">
435 <xsl:value-of select="@package"/>
436 <xsl:text>:</xsl:text>
437 <xsl:value-of select="@name"/>
438 </tt>
439 </xsl:otherwise>
440 </xsl:choose>
441 </xsl:template>
443 <xsl:template match="lambda-list">
444 <tt><xsl:value-of select="../@name"/></tt>
445 <xsl:text> (</xsl:text>
446 <xsl:for-each select="elt">
447 <xsl:if test="position() != 1">
448 <xsl:text>&#160;</xsl:text>
449 </xsl:if>
450 <b><xsl:value-of select="text()"/></b>
451 </xsl:for-each>
452 <xsl:text>)</xsl:text>
453 </xsl:template>
455 <xsl:template mode="about-arguments" match="lambda-list">
456 <div class="def">
457 <a href="{../@id}.html">
458 Function
459 <xsl:value-of select="../@name"/>
460 <xsl:text> (</xsl:text>
461 <xsl:for-each select="elt">
462 <xsl:if test="position() != 1">
463 <xsl:text>&#160;</xsl:text>
464 </xsl:if>
465 <xsl:value-of select="text()"/>
466 </xsl:for-each>
467 <xsl:text>)</xsl:text>
468 </a>
469 </div>
470 </xsl:template>
472 <xsl:template match="documentation-string">
473 <div class="indent">
474 <xsl:apply-templates/>
475 </div>
476 </xsl:template>
478 <xsl:template match="short">
479 <xsl:apply-templates/>
480 </xsl:template>
482 <xsl:template match="em">
484 <xsl:apply-templates/>
485 </i>
486 </xsl:template>
488 <xsl:template match="b">
490 <xsl:apply-templates/>
491 </b>
492 </xsl:template>
494 <xsl:template match="var">
495 <tt>
496 <xsl:apply-templates/>
497 </tt>
498 </xsl:template>
500 <xsl:template match="code">
501 <tt>
502 <xsl:apply-templates/>
503 </tt>
504 </xsl:template>
506 <xsl:template match="pre">
507 <pre>
508 <xsl:apply-templates/>
509 </pre>
510 </xsl:template>
512 <xsl:template match="a">
513 <a href="{@a}">
514 <xsl:apply-templates/>
515 </a>
516 </xsl:template>
518 <xsl:template match="fun">
519 <a href="{@id}.html">
520 <tt>
521 <xsl:apply-templates/>
522 </tt>
523 </a>
524 </xsl:template>
526 <xsl:template match="class">
527 <a href="{@id}.html">
528 <tt>
529 <xsl:apply-templates/>
530 </tt>
531 </a>
532 </xsl:template>
534 <xsl:template match="variable">
535 <a href="{@id}.html">
536 <tt>
537 <xsl:apply-templates/>
538 </tt>
539 </a>
540 </xsl:template>
542 <xsl:template match="itemize">
543 <ul>
544 <xsl:apply-templates/>
545 </ul>
546 </xsl:template>
548 <xsl:template match="item">
549 <li>
550 <xsl:apply-templates/>
551 </li>
552 </xsl:template>
554 <xsl:template match="see">
555 <tr>
556 <td>
557 <a href="{@id}.html">
558 <tt>
559 <xsl:apply-templates/>
560 </tt>
561 </a>
562 </td>
563 <xsl:if test="@see">
564 <td>
565 &#160;&#160;&#160;&#160;
567 <xsl:value-of select="@see"/>
568 </i>
569 </td>
570 </xsl:if>
571 </tr>
572 </xsl:template>
574 <xsl:template match="return">
575 <h3>Return Value</h3>
576 <div class="indent">
577 <xsl:apply-templates/>
578 </div>
579 </xsl:template>
581 <xsl:template match="implementation-note">
582 <h3>Implementation notes</h3>
583 <xsl:apply-templates/>
584 </xsl:template>
586 <xsl:template match="break">
587 <br/><br/>
588 </xsl:template>
590 <xsl:template match="sections">
591 <xsl:for-each select="section">
592 <h2>
593 <a name="{generate-id()}"/>
594 <xsl:value-of select="@section"/>
595 </h2>
596 <xsl:apply-templates/>
597 </xsl:for-each>
598 </xsl:template>
600 <xsl:template match="aboutfun">
601 <xsl:variable name="fun" select="text()"/>
602 <xsl:apply-templates
603 mode="about-arguments"
604 select="//function-definition[@name=$fun]/lambda-list"/>
605 <div style="margin-left: 3em">
606 <xsl:choose>
607 <xsl:when
608 test="//function-definition[@name=$fun]/documentation-string//short">
609 <xsl:for-each select="//function-definition[@name=$fun]">
610 <xsl:apply-templates select="documentation-string//short"/>
611 <xsl:text> </xsl:text>
612 <a href="{@id}.html#details">...</a>
613 </xsl:for-each>
614 </xsl:when>
615 <xsl:otherwise>
616 <xsl:apply-templates
617 select="//function-definition[@name=$fun]/documentation-string"/>
618 </xsl:otherwise>
619 </xsl:choose>
620 </div>
621 <br/>
622 </xsl:template>
624 <xsl:template match="aboutclass">
625 <xsl:variable name="name" select="text()"/>
626 <xsl:for-each select="//class-definition[@name=$name]">
627 <div class="def">
628 <a href="{@id}.html">
629 Class
630 <xsl:value-of select="@name"/>
631 </a>
632 </div>
633 </xsl:for-each>
634 <div style="margin-left: 3em">
635 <xsl:choose>
636 <xsl:when
637 test="//class-definition[@name=$name]/documentation-string//short">
638 <xsl:for-each select="//class-definition[@name=$name]">
639 <xsl:apply-templates select="documentation-string//short"/>
640 <xsl:text> </xsl:text>
641 <a href="{@id}.html#details">...</a>
642 </xsl:for-each>
643 </xsl:when>
644 <xsl:otherwise>
645 <xsl:apply-templates
646 select="//class-definition[@name=$name]/documentation-string"/>
647 </xsl:otherwise>
648 </xsl:choose>
649 </div>
650 <br/>
651 </xsl:template>
653 <xsl:template name="undocumented">
654 <xsl:if test="not(documentation-string)">
655 <xsl:text>&#160;</xsl:text>
656 <span style="color: red">
657 (undocumented)
658 </span>
659 </xsl:if>
660 </xsl:template>
661 </xsl:stylesheet>