Thanks.  I've attached what I've come up with:

simple.xsl: transforms the standard index.xml (comes with jQuery source)
into a simple one page doc with anchored methods
simple.css: the stylesheet used by simple.xsl
gotapi.xsl: generates the gotapi.com specific xml format (
http://gotapi.com/contribute/index.html)

Let me know if it's worthy of checking in.

Rich



On 12/8/06, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:

Rich Manalang schrieb:
> Here's an early sample of what I was thinking of:
>
> http://manalang.com/jquery/docs/gotapi.xml
>
> I need to figure out how to add the method signatures into the anchor.
I'm using these XSLT snippets to generate ids and hrefs

    <xsl:template name="href">
        <xsl:attribute name="href">
            <xsl:text>#</xsl:text>
            <xsl:value-of select="@name"/>
            <xsl:for-each select="params">
                <xsl:value-of select="translate(@type, '&lt;&gt;', '')"/>
            </xsl:for-each>
        </xsl:attribute>
    </xsl:template>

    <xsl:template name="id">
        <xsl:attribute name="id">
            <xsl:value-of select="@name"/>
            <xsl:for-each select="params">
                <xsl:value-of select="translate(@type, '&lt;&gt;', '')"/>
            </xsl:for-each>
        </xsl:attribute>
    </xsl:template>:

And the simply called with this inside a anchor:
<xsl:call-template name="href" />

Or with this inside the target element (li in my case):
<xsl:call-template name="id" />

You could extract the common part of both into another template...

--
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

html, body {
	font-family: Arial;
	font-size:1em;
	margin: 5px 10px;
}
h1 {
	text-align: left;
	color: #000;
	margin:0;
	padding:0;
}
h1 a {
	color:#000080;
	text-decoration:none;
}
h2 {
	font-size:1.2em;
}
h3 {
	font-size:1em;
	margin:0;
	padding:0;
}
h4 {
	font-size:.9em;
	margin:0;
	padding:0;
}
.tooltip {
	cursor:pointer;
}
.tooltipdemo {
	color:#000;
	font-size:.7em;
	font-weight:normal;
	background:#ffff99;
}
a.name {
	color:#000080;
	margin:0 5px 0 0;
	text-decoration:underline;
}
.arg-type {
	color:#666;
}
.arg-type,
.arg-name {
	font-weight:normal;
	border-bottom:1px dotted #666;
}
.type {
	font-weight:normal;
	color:#666;
	margin:0 0 0 10px;
}
.type .tooltip {
	font-weight:normal;
	border-bottom:1px dotted #666;
}
.desc, .example p {
	font-size:1.4ex;
}
.example {
	border-top:2px solid #ccc;
	background:#eee;
	margin:15px 0px;
	padding:5px 10px;
}
.example h3 {
	margin:0;
	padding:0;
}
pre {
	background:#ffffcc;
	padding: 10px;
	font-size:.9em;
	border-left:5px solid #ccc;
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:template name="generate-anchors">
		<xsl:for-each select="params">-<xsl:value-of select="@name"/></xsl:for-each>
	</xsl:template>
	<xsl:template match="/*">
		<html>
			<head>
				<title>jQuery API Documentation: Version <xsl:value-of select="/docs/@version"/></title>
				<link rel="stylesheet" href="style/gotapi.css"/>
				<script src="../dist/jquery.js"></script>
				<script src="js/tooltip.js"></script>
				<script src="js/gotapi.js"></script>
			</head>
			<body>
				<h1><span><a href="http://jquery.com"; title="jQuery Home">jQuery</a> API Documentation</span></h1>
				<h4>Version: <xsl:value-of select="/docs/@version"/></h4>
				<dl>
					<xsl:for-each select="method[not(@private)]">
						<xsl:sort select="translate(@name,'$.','')"/>
						<xsl:sort select="count(params)"/>
						
						<dt>
							<h2>
								<span class='fn'>
									<a class='name'>
										<xsl:attribute name="name"><xsl:value-of select="@name"/><xsl:call-template name="generate-anchors"/></xsl:attribute>
										<xsl:attribute name="href">#<xsl:value-of select="@name"/><xsl:call-template name="generate-anchors"/></xsl:attribute>
										<xsl:value-of select="@name"/>
									</a>
									<xsl:if test="not(@property)">(
										<xsl:for-each select="params">
											<span class='arg-type tooltip'><xsl:value-of select="@type"/></span><xsl:text> </xsl:text>
											<span class='arg-name tooltip' title='{desc}'><xsl:value-of select="@name"/></span>
											<xsl:if test="position() != last()">
												<xsl:if test="@any"> or </xsl:if>
												<xsl:if test="not(@any)">, </xsl:if>
											</xsl:if>
										</xsl:for-each>
									)</xsl:if>
								</span>
								<span class='type'>returns <span class='tooltip'><xsl:value-of select="@type"/></span></span>
							</h2>
						</dt>
						<dd>
							<div class='desc'>
								<xsl:value-of select="desc"/>
							</div>
							<xsl:for-each select="examples">
								<div class='example'>
									<h3>Example:</h3>
									<xsl:if test="desc">
										<p><xsl:value-of select="desc"/></p>
									</xsl:if>
									<pre><xsl:value-of select="code"/></pre>
									<xsl:if test="before">
										<h4>HTML:</h4>
										<pre><xsl:value-of select="before"/></pre>
									</xsl:if>
									<xsl:if test="result">
										<h4>Result:</h4>
										<pre><xsl:value-of select="result"/></pre>
									</xsl:if>
								</div>
							</xsl:for-each>
						</dd>
					</xsl:for-each>
				</dl>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" omit-xml-declaration="no"/>
	<xsl:variable name="docurl">http://jquery.com/api/</xsl:variable>
	<xsl:template name="generate-anchors">
		<xsl:for-each select="params">-<xsl:value-of select="@name"/></xsl:for-each>
	</xsl:template>
	<xsl:template name="method-signatures">
		<xsl:for-each select="params">
			<xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
			<xsl:if test="position() != last()">
				<xsl:if test="@any"> or </xsl:if>
				<xsl:if test="not(@any)">, </xsl:if>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	<xsl:key name="methods-by-cat" match="method" use="@cat"/>
	<xsl:template match="/*">
		<pages>
			<xsl:for-each select="method[count(. | key('methods-by-cat', @cat)[1]) = 1 and not(@private)]">
				<xsl:sort select="@cat"/>
				<page title="[EMAIL PROTECTED]" type="package" url="">
					<xsl:for-each select="key('methods-by-cat', @cat)">
						<xsl:sort select="translate(@name,'$.','')"/>
						<xsl:sort select="count(params)"/>
							<xsl:if test="not(@private)">
							<page type="method">
								<xsl:attribute name="title"><xsl:value-of select="@name"/>(<xsl:call-template name="method-signatures"/>)</xsl:attribute>
								<xsl:attribute name="url"><xsl:copy-of select="$docurl"/>#<xsl:value-of select="@name"/><xsl:call-template name="generate-anchors"/></xsl:attribute>
							</page>
							</xsl:if>
					</xsl:for-each>
				</page>
			</xsl:for-each>
	    </pages>
	</xsl:template>
</xsl:stylesheet>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to