Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of api-docs-stylesheet, an example doc and little ant …
…script for transforming.
- Loading branch information
0 parents
commit e446595
Showing
3 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<project name="jQuery API" default="transform" basedir="."> | ||
|
||
<target name="transform" description="Transform XML via XSL to HTML"> | ||
<delete file="*.html" /> | ||
<xslt includes="*.xml" excludes="build.xml" destdir="." style="entries2html.xsl" /> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> | ||
|
||
<xsl:template match="/"> | ||
|
||
<html> | ||
<fieldset class="toc"> | ||
<legend>Contents</legend> | ||
<ul class="toc-list"> | ||
<xsl:for-each select="//entry"> | ||
<xsl:variable name="entry-name" select="@name" /> | ||
<li> | ||
<a href="#{concat(@name,position())}"> | ||
<xsl:value-of select="@name" /><xsl:if test="@type='method'">(<xsl:if test="signature/argument"><xsl:text> </xsl:text> | ||
<xsl:for-each select="signature[1]/argument"> | ||
<xsl:if test="position() > 1"> | ||
<xsl:text>, </xsl:text> | ||
</xsl:if> | ||
<xsl:if test="@optional">[ </xsl:if> | ||
<xsl:value-of select="@name" /> | ||
<xsl:if test="@optional"> ]</xsl:if> | ||
</xsl:for-each> | ||
<xsl:text> </xsl:text></xsl:if>)</xsl:if> | ||
<xsl:text> </xsl:text> | ||
<span class="desc"> | ||
<xsl:value-of select="desc" /> | ||
</span> | ||
</a> | ||
<xsl:if test="@type='method'"> | ||
<ul> | ||
<xsl:for-each select="signature"> | ||
<li> | ||
<a> | ||
<xsl:attribute name="href"> | ||
#<xsl:value-of select="$entry-name" /> | ||
<xsl:for-each select="argument"> | ||
<xsl:variable name="argument-name" select="@name" /> | ||
<xsl:text>-</xsl:text><xsl:value-of select="translate($argument-name, ')(', '')"/> | ||
</xsl:for-each> | ||
</xsl:attribute> | ||
<xsl:if test="not(contains($entry-name, '.'))">.</xsl:if><xsl:value-of select="$entry-name" />(<xsl:if test="argument"><xsl:text> </xsl:text> | ||
<xsl:for-each select="argument"> | ||
<xsl:if test="position() > 1"> | ||
<xsl:text>, </xsl:text> | ||
</xsl:if> | ||
<xsl:if test="@optional">[ </xsl:if> | ||
<xsl:value-of select="@name" /> | ||
<xsl:if test="@optional"> ]</xsl:if> | ||
</xsl:for-each><xsl:text> </xsl:text></xsl:if>) | ||
</a> | ||
</li> | ||
</xsl:for-each> | ||
</ul> | ||
</xsl:if> | ||
</li> | ||
</xsl:for-each> | ||
</ul> | ||
</fieldset> | ||
|
||
<xsl:for-each select="//entry"> | ||
<xsl:variable name="entry-name" select="@name" /> | ||
<xsl:variable name="entry-type" select="@type" /> | ||
<xsl:variable name="entry-index" select="position()" /> | ||
<xsl:variable name="number-examples" select="count(example)" /> | ||
<div class="entry {@type}" id="{concat(@name,position())}"> | ||
<h2> | ||
<span class="name"><xsl:value-of select="@name" /><xsl:if test="@type='method'">(<xsl:if test="signature/argument"><xsl:text> </xsl:text> | ||
<xsl:for-each select="signature[1]/argument"> | ||
<xsl:if test="position() > 1"> | ||
<xsl:text>, </xsl:text> | ||
</xsl:if> | ||
<xsl:if test="@optional">[ </xsl:if> | ||
<xsl:value-of select="@name" /> | ||
<xsl:if test="@optional"> ]</xsl:if> | ||
</xsl:for-each> | ||
<xsl:text> </xsl:text></xsl:if>)</xsl:if></span> | ||
<xsl:text> </xsl:text> | ||
<span class="desc"><xsl:value-of select="desc" /></span> | ||
</h2> | ||
<div class="entry-details"> | ||
<xsl:choose> | ||
<xsl:when test="$entry-type='selector'"> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<p class="returns"> | ||
Returns: <a class="return" href="/Types#{@return}"><xsl:value-of select="@return" /></a> | ||
</p> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
<h3>Signatures:</h3> | ||
<ul class="signatures"> | ||
<xsl:for-each select="signature"> | ||
<xsl:variable name="argument-name" select="@name" /> | ||
<li class="signature"> | ||
<xsl:attribute name="id"> | ||
<xsl:value-of select="$entry-name" /> | ||
<xsl:for-each select="argument"> | ||
<xsl:text>-</xsl:text><xsl:value-of select="translate($argument-name, ')(', '')"/> | ||
</xsl:for-each> | ||
</xsl:attribute> | ||
<h4 class="name"> | ||
<span class="versionAdded">version added: <xsl:value-of select="added" /></span> | ||
<xsl:if test="$entry-type='method'"><xsl:if test="not(contains($entry-name, '.'))">.</xsl:if></xsl:if><xsl:value-of select="$entry-name" /><xsl:if test="$entry-type='method'">(<xsl:if test="argument"><xsl:text> </xsl:text> | ||
<xsl:for-each select="argument"> | ||
<xsl:if test="position() > 1"> | ||
<xsl:text>, </xsl:text> | ||
</xsl:if> | ||
<xsl:if test="@optional">[ </xsl:if> | ||
<xsl:value-of select="@name" /> | ||
<xsl:if test="@optional"> ]</xsl:if> | ||
</xsl:for-each> | ||
<xsl:text> </xsl:text></xsl:if>)</xsl:if> | ||
</h4> | ||
<xsl:if test="argument"> | ||
<dl class="arguments"> | ||
<xsl:for-each select="argument"> | ||
<dt><xsl:value-of select="@name" /></dt> | ||
<dd><xsl:copy-of select="desc/text()" /></dd> | ||
</xsl:for-each> | ||
</dl> | ||
</xsl:if> | ||
</li> | ||
</xsl:for-each> | ||
</ul> | ||
<xsl:if test="longdesc/*"> | ||
<h3>Description:</h3> | ||
<div class="longdesc"> | ||
<xsl:copy-of select="longdesc/*" /> | ||
</div> | ||
</xsl:if> | ||
<xsl:if test="$number-examples > 0"> | ||
<h3>Example<xsl:if test="$number-examples > 1">s</xsl:if>:</h3> | ||
<div class="entry-examples"> | ||
<xsl:for-each select="example"> | ||
<h4><xsl:if test="$number-examples > 1">Example: </xsl:if><span class="desc"><xsl:value-of select="desc" /></span></h4> | ||
<pre><code> | ||
<xsl:choose> | ||
<xsl:when test="html"> | ||
<xsl:attribute name="class">example demo-code</xsl:attribute> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:attribute name="class">example</xsl:attribute> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style type="text/css"><xsl:copy-of select="css/text()" /></style> | ||
<script type="text/javascript" src="/scripts/jquery-1.4.js"></script> | ||
</head> | ||
<body> | ||
<xsl:copy-of select="html/text()" /> | ||
<script><xsl:copy-of select="code/text()" /></script> | ||
|
||
</body> | ||
</html> | ||
</code></pre> | ||
<xsl:if test="html"> | ||
<h4>Demo:</h4> | ||
<div><xsl:choose> | ||
<xsl:when test="html"> | ||
<xsl:attribute name="class">demo code-demo</xsl:attribute> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:attribute name="class">demo</xsl:attribute> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</div> | ||
</xsl:if> | ||
</xsl:for-each> | ||
</div> | ||
</xsl:if> | ||
</div> | ||
</div> | ||
|
||
</xsl:for-each> | ||
|
||
</html> | ||
|
||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<entries> | ||
<entry type='method' name="rules" return="jQuery" plugin="Validation"> | ||
<signature> | ||
<added>1.3</added> | ||
</signature> | ||
<desc>Compile the contents of the matched element as a reusable compiled template.</desc> | ||
|
||
<longdesc> | ||
<p>Note: For information about how to render templates, see <a href="http://api.jquery.com/tmpl">.tmpl()</a> and <a href="http://api.jquery.com/jquery.tmpl">jQuery.tmpl()</a>.</p> | ||
|
||
<pre><![CDATA[ | ||
]]></pre> | ||
|
||
</longdesc> | ||
|
||
<example height="250"> | ||
<desc></desc> | ||
|
||
<code><![CDATA[ | ||
]]></code> | ||
<css><![CDATA[ | ||
]]></css> | ||
<html><![CDATA[ | ||
]]></html> | ||
</example> | ||
</entry> | ||
<entry type='method' name="rules" return="jQuery" plugin="Validation"> | ||
<signature> | ||
<added>1.3</added> | ||
<argument name="add" type="String"> | ||
<desc>A string indicating to add a set of rules.</desc> | ||
</argument> | ||
<argument name="rules" type="Object"> | ||
<desc>The rules to add. Accepts the same format as the rules-option of the validate-method</desc> | ||
</argument> | ||
</signature> | ||
<signature> | ||
<added>1.3</added> | ||
<argument name="remove" type="String"> | ||
<desc>A string indicating to remove rules.</desc> | ||
</argument> | ||
<argument name="rules" type="String" optional="true"> | ||
<desc>The space-separated names of rules to remove and return. If left unspecified, removes and returns all rules. Manipulates only rules specified by the <code>rules</code> option of the <code>.validate()</code> or <code>.rules("add")</code> method.</desc> | ||
</argument> | ||
</signature> | ||
<desc><p>something else</p></desc> | ||
<longdesc><p>a very long description</p></longdesc> | ||
</entry> | ||
</entries> |