Skip to content

Commit db38e56

Browse files
committed
Merge branch 'master' of github.com:jquery/api.jquery.com
* 'master' of github.com:jquery/api.jquery.com: Copy over XSL updates from UI.
2 parents ea8d285 + 82992ed commit db38e56

File tree

1 file changed

+108
-96
lines changed

1 file changed

+108
-96
lines changed

entries2html-base.xsl

+108-96
Original file line numberDiff line numberDiff line change
@@ -51,44 +51,46 @@
5151
</xsl:attribute>
5252

5353
<xsl:call-template name="entry-title"/>
54-
<xsl:call-template name="entry-body"/>
54+
<div class="entry-wrapper">
55+
<xsl:call-template name="entry-body"/>
5556

56-
<xsl:if test="normalize-space(longdesc/*)">
57-
<div class="longdesc">
58-
<xsl:copy-of select="longdesc/*" />
59-
</div>
60-
</xsl:if>
61-
62-
<xsl:if test="note">
63-
<h3>Additional Notes:</h3>
64-
<div class="longdesc">
65-
<ul>
66-
<xsl:for-each select="note">
67-
<li><xsl:call-template name="note"/></li>
68-
</xsl:for-each>
69-
</ul>
70-
</div>
71-
</xsl:if>
72-
73-
<xsl:if test="example">
74-
<section class="entry-examples">
75-
<xsl:attribute name="id">
76-
<xsl:text>entry-examples</xsl:text>
77-
<xsl:if test="$entry-index &gt; 1">
78-
<xsl:text>-</xsl:text><xsl:value-of select="$entry-index - 1"/>
79-
</xsl:if>
80-
</xsl:attribute>
57+
<xsl:if test="normalize-space(longdesc/*)">
58+
<div class="longdesc">
59+
<xsl:apply-templates select="longdesc"/>
60+
</div>
61+
</xsl:if>
8162

82-
<header>
83-
<h2 class="underline">Example<xsl:if test="$number-examples &gt; 1">s</xsl:if>:</h2>
84-
</header>
63+
<xsl:if test="note">
64+
<h3>Additional Notes:</h3>
65+
<div class="longdesc">
66+
<ul>
67+
<xsl:for-each select="note">
68+
<li><xsl:call-template name="note"/></li>
69+
</xsl:for-each>
70+
</ul>
71+
</div>
72+
</xsl:if>
8573

86-
<xsl:apply-templates select="example">
87-
<xsl:with-param name="entry-index" select="$entry-index"/>
88-
<xsl:with-param name="number-examples" select="$number-examples"/>
89-
</xsl:apply-templates>
90-
</section>
91-
</xsl:if>
74+
<xsl:if test="example">
75+
<section class="entry-examples">
76+
<xsl:attribute name="id">
77+
<xsl:text>entry-examples</xsl:text>
78+
<xsl:if test="$entry-index &gt; 1">
79+
<xsl:text>-</xsl:text><xsl:value-of select="$entry-index - 1"/>
80+
</xsl:if>
81+
</xsl:attribute>
82+
83+
<header>
84+
<h2 class="underline">Example<xsl:if test="$number-examples &gt; 1">s</xsl:if>:</h2>
85+
</header>
86+
87+
<xsl:apply-templates select="example">
88+
<xsl:with-param name="entry-index" select="$entry-index"/>
89+
<xsl:with-param name="number-examples" select="$number-examples"/>
90+
</xsl:apply-templates>
91+
</section>
92+
</xsl:if>
93+
</div>
9294
</article>
9395
</xsl:for-each>
9496
</xsl:template>
@@ -164,15 +166,7 @@
164166
</xsl:call-template>
165167
</xsl:for-each>
166168
</span>
167-
<xsl:text> </xsl:text>
168-
<span class="returns">
169-
<xsl:if test="@return != ''">
170-
<xsl:text>Returns: </xsl:text>
171-
<a class="return" href="http://api.jquery.com/Types/#{@return}">
172-
<xsl:value-of select="@return"/>
173-
</a>
174-
</xsl:if>
175-
</span>
169+
<xsl:call-template name="return-value"/>
176170
</xsl:when>
177171
<xsl:when test="$entry-type='selector'">
178172
<span>
@@ -184,22 +178,11 @@
184178
<span>
185179
<xsl:value-of select="@name"/>
186180
</span>
187-
<xsl:text> </xsl:text>
188-
<span class="returns">
189-
<xsl:if test="@return != ''">
190-
<xsl:text>Returns: </xsl:text>
191-
<a class="return" href="http://api.jquery.com/Types/#{@return}">
192-
<xsl:value-of select="@return"/>
193-
</a>
194-
</xsl:if>
195-
</span>
196-
</xsl:when>
197-
<xsl:when test="$entry-type='widget'">
198-
<span>
199-
<xsl:value-of select="@name"/>
200-
<xsl:text> widget</xsl:text>
201-
</span>
181+
<xsl:call-template name="return-value"/>
202182
</xsl:when>
183+
<xsl:otherwise>
184+
<span><xsl:value-of select="title"/></span>
185+
</xsl:otherwise>
203186
</xsl:choose>
204187
</h2>
205188
</xsl:template>
@@ -310,15 +293,18 @@
310293
<h2 class="underline">Options</h2>
311294
</header>
312295
<xsl:for-each select="options/option">
296+
<xsl:sort select="@name"/>
313297
<div id="option-{@name}">
314298
<h3>
315299
<xsl:value-of select="@name"/>
316300
</h3>
317301
<div>
318-
<strong>Type: </strong><xsl:call-template name="render-types"/>
302+
<strong>Type: </strong>
303+
<xsl:call-template name="render-types"/>
319304
</div>
320305
<div>
321-
<strong>Default: </strong><xsl:value-of select="@default"/>
306+
<strong>Default: </strong>
307+
<code><xsl:value-of select="@default"/></code>
322308
</div>
323309
<div>
324310
<xsl:apply-templates select="desc">
@@ -333,7 +319,7 @@
333319
<li>
334320
<strong><xsl:value-of select="../@name"/></strong>
335321
<xsl:text>: </xsl:text>
336-
<xsl:copy-of select="node()"/>
322+
<xsl:apply-templates select="."/>
337323
</li>
338324
</xsl:for-each>
339325
</ul>
@@ -351,6 +337,7 @@
351337
<h2 class="underline">Methods</h2>
352338
</header>
353339
<xsl:for-each select="methods/method">
340+
<xsl:sort select="@name"/>
354341
<xsl:variable name="method-name" select="@name"/>
355342
<div id="method-{$method-name}">
356343
<xsl:for-each select="signature | self::node()[count(signature) = 0]">
@@ -369,6 +356,7 @@
369356
<h2 class="underline">Events</h2>
370357
</header>
371358
<xsl:for-each select="events/event">
359+
<xsl:sort select="@name"/>
372360
<div id="event-{@name}">
373361
<xsl:call-template name="widget-method-event">
374362
<xsl:with-param name="entry-name" select="$entry-name"/>
@@ -458,29 +446,6 @@
458446
</xsl:if>
459447
</xsl:template>
460448

461-
<xsl:template name="render-return-types">
462-
<xsl:if test="@return and return">
463-
<strong>ERROR: Use <i>either</i> @return or return element</strong>
464-
</xsl:if>
465-
466-
<!-- return attribute -->
467-
<xsl:if test="@return">
468-
<xsl:call-template name="render-type">
469-
<xsl:with-param name="typename" select="@return" />
470-
</xsl:call-template>
471-
</xsl:if>
472-
473-
<!-- a return element -->
474-
<xsl:if test="return">
475-
<xsl:for-each select="return">
476-
<xsl:if test="position() &gt; 1">
477-
<strong>ERROR: A single return element is expected</strong>
478-
</xsl:if>
479-
<xsl:call-template name="render-types" />
480-
</xsl:for-each>
481-
</xsl:if>
482-
</xsl:template>
483-
484449
<!-- Render a single type -->
485450
<xsl:template name="render-type">
486451
<xsl:param name="typename"/>
@@ -492,7 +457,8 @@
492457
- the return element is optional
493458
-->
494459
<xsl:when test="$typename = 'Function'">
495-
<a href="http://api.jquery.com/Types/#Function">Function</a>(
460+
<a href="http://api.jquery.com/Types/#Function">Function</a>
461+
<xsl:text>(</xsl:text>
496462
<xsl:if test="argument">
497463
<xsl:text> </xsl:text>
498464
<xsl:for-each select="argument">
@@ -502,7 +468,8 @@
502468
<xsl:call-template name="render-types"/>
503469
</xsl:for-each>
504470
<xsl:text> </xsl:text>
505-
</xsl:if>)
471+
</xsl:if>
472+
<xsl:text>)</xsl:text>
506473

507474
<!-- display return type if present -->
508475
<xsl:if test="return or @return">
@@ -517,12 +484,48 @@
517484
</xsl:choose>
518485
</xsl:template>
519486

487+
<xsl:template name="render-return-types">
488+
<xsl:if test="@return and return">
489+
<strong>ERROR: Use <i>either</i> @return or return element</strong>
490+
</xsl:if>
491+
492+
<!-- return attribute -->
493+
<xsl:if test="@return">
494+
<xsl:call-template name="render-type">
495+
<xsl:with-param name="typename" select="@return" />
496+
</xsl:call-template>
497+
</xsl:if>
498+
499+
<!-- a return element -->
500+
<xsl:if test="return">
501+
<xsl:for-each select="return">
502+
<xsl:if test="position() &gt; 1">
503+
<strong>ERROR: A single return element is expected</strong>
504+
</xsl:if>
505+
<xsl:call-template name="render-types" />
506+
</xsl:for-each>
507+
</xsl:if>
508+
</xsl:template>
509+
510+
<xsl:template name="return-value">
511+
<xsl:if test="@return != ''">
512+
<xsl:text> </xsl:text>
513+
<span class="returns">
514+
<xsl:text>Returns: </xsl:text>
515+
<a class="return" href="http://api.jquery.com/Types/#{@return}">
516+
<xsl:value-of select="@return"/>
517+
</a>
518+
</span>
519+
</xsl:if>
520+
</xsl:template>
521+
520522
<xsl:template name="method-signature">
521523
<xsl:param name="method-name"/>
522524
<xsl:param name="dot" select="false()"/>
523525

524526
<xsl:if test="$dot and not(contains($method-name, '.')) and $method-name != 'jQuery'">.</xsl:if>
525-
<xsl:value-of select="$method-name"/>(
527+
<xsl:value-of select="$method-name"/>
528+
<xsl:text>(</xsl:text>
526529
<xsl:if test="argument">
527530
<xsl:text> </xsl:text>
528531
<xsl:for-each select="argument">
@@ -532,7 +535,8 @@
532535
<xsl:if test="@optional"><xsl:text> ]</xsl:text></xsl:if>
533536
</xsl:for-each>
534537
<xsl:text> </xsl:text>
535-
</xsl:if>)
538+
</xsl:if>
539+
<xsl:text>)</xsl:text>
536540
</xsl:template>
537541

538542
<xsl:template name="arguments">
@@ -612,6 +616,7 @@
612616
<xsl:call-template name="method-signature">
613617
<xsl:with-param name="method-name" select="$method-name"/>
614618
</xsl:call-template>
619+
<xsl:call-template name="return-value"/>
615620
</h3>
616621
<div>
617622
<xsl:apply-templates select="desc">
@@ -622,19 +627,26 @@
622627
<xsl:call-template name="arguments"/>
623628
</xsl:template>
624629

625-
<xsl:template match="desc">
630+
<!-- <desc> and <longdesc> support <placeholder name="foo"> to replace the
631+
placeholder with @foo from the <entry> -->
632+
<xsl:template match="desc|longdesc">
626633
<xsl:param name="entry-name"/>
627634
<xsl:apply-templates select="./node()">
628635
<xsl:with-param name="entry-name" select="$entry-name"/>
629636
</xsl:apply-templates>
630637
</xsl:template>
631-
<!-- This makes elements inside <desc> get copied over properly -->
632-
<xsl:template match="desc/*">
633-
<xsl:copy-of select="."/>
638+
<!-- This makes elements and attributes get copied over properly -->
639+
<xsl:template match="desc//*|desc//@*|longdesc//*|longdesc//@*">
640+
<xsl:copy>
641+
<xsl:apply-templates select="@* | node()"/>
642+
</xsl:copy>
634643
</xsl:template>
635-
<xsl:template match="desc/placeholder">
636-
<xsl:param name="entry-name"/>
637-
<xsl:value-of select="$entry-name"/>
644+
<!-- <xi:include> will add an xml:base attribute, so we strip it out -->
645+
<xsl:template match="//@xml:base"/>
646+
<!-- replace the <placeholder> with the associated attribute from the entry -->
647+
<xsl:template match="//placeholder">
648+
<xsl:variable name="name" select="@name"/>
649+
<xsl:value-of select="ancestor::entry/@*[name()=$name]"/>
638650
</xsl:template>
639651

640652
<!-- escape-string, from xml2json.xsl -->

0 commit comments

Comments
 (0)