|
51 | 51 | </xsl:attribute> |
52 | 52 |
|
53 | 53 | <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"/> |
55 | 56 |
|
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 > 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> |
81 | 62 |
|
82 | | - <header> |
83 | | - <h2 class="underline">Example<xsl:if test="$number-examples > 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> |
85 | 73 |
|
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 > 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 > 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> |
92 | 94 | </article> |
93 | 95 | </xsl:for-each> |
94 | 96 | </xsl:template> |
|
164 | 166 | </xsl:call-template> |
165 | 167 | </xsl:for-each> |
166 | 168 | </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"/> |
176 | 170 | </xsl:when> |
177 | 171 | <xsl:when test="$entry-type='selector'"> |
178 | 172 | <span> |
|
184 | 178 | <span> |
185 | 179 | <xsl:value-of select="@name"/> |
186 | 180 | </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"/> |
202 | 182 | </xsl:when> |
| 183 | + <xsl:otherwise> |
| 184 | + <span><xsl:value-of select="title"/></span> |
| 185 | + </xsl:otherwise> |
203 | 186 | </xsl:choose> |
204 | 187 | </h2> |
205 | 188 | </xsl:template> |
|
310 | 293 | <h2 class="underline">Options</h2> |
311 | 294 | </header> |
312 | 295 | <xsl:for-each select="options/option"> |
| 296 | + <xsl:sort select="@name"/> |
313 | 297 | <div id="option-{@name}"> |
314 | 298 | <h3> |
315 | 299 | <xsl:value-of select="@name"/> |
316 | 300 | </h3> |
317 | 301 | <div> |
318 | | - <strong>Type: </strong><xsl:call-template name="render-types"/> |
| 302 | + <strong>Type: </strong> |
| 303 | + <xsl:call-template name="render-types"/> |
319 | 304 | </div> |
320 | 305 | <div> |
321 | | - <strong>Default: </strong><xsl:value-of select="@default"/> |
| 306 | + <strong>Default: </strong> |
| 307 | + <code><xsl:value-of select="@default"/></code> |
322 | 308 | </div> |
323 | 309 | <div> |
324 | 310 | <xsl:apply-templates select="desc"> |
|
333 | 319 | <li> |
334 | 320 | <strong><xsl:value-of select="../@name"/></strong> |
335 | 321 | <xsl:text>: </xsl:text> |
336 | | - <xsl:copy-of select="node()"/> |
| 322 | + <xsl:apply-templates select="."/> |
337 | 323 | </li> |
338 | 324 | </xsl:for-each> |
339 | 325 | </ul> |
|
351 | 337 | <h2 class="underline">Methods</h2> |
352 | 338 | </header> |
353 | 339 | <xsl:for-each select="methods/method"> |
| 340 | + <xsl:sort select="@name"/> |
354 | 341 | <xsl:variable name="method-name" select="@name"/> |
355 | 342 | <div id="method-{$method-name}"> |
356 | 343 | <xsl:for-each select="signature | self::node()[count(signature) = 0]"> |
|
369 | 356 | <h2 class="underline">Events</h2> |
370 | 357 | </header> |
371 | 358 | <xsl:for-each select="events/event"> |
| 359 | + <xsl:sort select="@name"/> |
372 | 360 | <div id="event-{@name}"> |
373 | 361 | <xsl:call-template name="widget-method-event"> |
374 | 362 | <xsl:with-param name="entry-name" select="$entry-name"/> |
|
458 | 446 | </xsl:if> |
459 | 447 | </xsl:template> |
460 | 448 |
|
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() > 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 | | - |
484 | 449 | <!-- Render a single type --> |
485 | 450 | <xsl:template name="render-type"> |
486 | 451 | <xsl:param name="typename"/> |
|
492 | 457 | - the return element is optional |
493 | 458 | --> |
494 | 459 | <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> |
496 | 462 | <xsl:if test="argument"> |
497 | 463 | <xsl:text> </xsl:text> |
498 | 464 | <xsl:for-each select="argument"> |
|
502 | 468 | <xsl:call-template name="render-types"/> |
503 | 469 | </xsl:for-each> |
504 | 470 | <xsl:text> </xsl:text> |
505 | | - </xsl:if>) |
| 471 | + </xsl:if> |
| 472 | + <xsl:text>)</xsl:text> |
506 | 473 |
|
507 | 474 | <!-- display return type if present --> |
508 | 475 | <xsl:if test="return or @return"> |
|
517 | 484 | </xsl:choose> |
518 | 485 | </xsl:template> |
519 | 486 |
|
| 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() > 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 | + |
520 | 522 | <xsl:template name="method-signature"> |
521 | 523 | <xsl:param name="method-name"/> |
522 | 524 | <xsl:param name="dot" select="false()"/> |
523 | 525 |
|
524 | 526 | <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> |
526 | 529 | <xsl:if test="argument"> |
527 | 530 | <xsl:text> </xsl:text> |
528 | 531 | <xsl:for-each select="argument"> |
|
532 | 535 | <xsl:if test="@optional"><xsl:text> ]</xsl:text></xsl:if> |
533 | 536 | </xsl:for-each> |
534 | 537 | <xsl:text> </xsl:text> |
535 | | - </xsl:if>) |
| 538 | + </xsl:if> |
| 539 | + <xsl:text>)</xsl:text> |
536 | 540 | </xsl:template> |
537 | 541 |
|
538 | 542 | <xsl:template name="arguments"> |
|
612 | 616 | <xsl:call-template name="method-signature"> |
613 | 617 | <xsl:with-param name="method-name" select="$method-name"/> |
614 | 618 | </xsl:call-template> |
| 619 | + <xsl:call-template name="return-value"/> |
615 | 620 | </h3> |
616 | 621 | <div> |
617 | 622 | <xsl:apply-templates select="desc"> |
|
622 | 627 | <xsl:call-template name="arguments"/> |
623 | 628 | </xsl:template> |
624 | 629 |
|
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"> |
626 | 633 | <xsl:param name="entry-name"/> |
627 | 634 | <xsl:apply-templates select="./node()"> |
628 | 635 | <xsl:with-param name="entry-name" select="$entry-name"/> |
629 | 636 | </xsl:apply-templates> |
630 | 637 | </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> |
634 | 643 | </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]"/> |
638 | 650 | </xsl:template> |
639 | 651 |
|
640 | 652 | <!-- escape-string, from xml2json.xsl --> |
|
0 commit comments