core: Ant target to generate openAjaxMetadata; uses http://www.exfer.net/jquery/createjQueryXMLDocs.py to get the data from the wiki, and transforms it using xslt (see build/style.xsl)
This commit is contained in:
parent
82958c79ff
commit
f649acd8ab
|
@ -19,6 +19,7 @@
|
|||
<property description="Files for parsing etc." name="BUILD_DIR" value="build" />
|
||||
<property description="Rhino JS Engine" name="JAR" value="${BUILD_DIR}/js.jar" />
|
||||
<property description="YUICompressor" name="YUICompressor" value="${BUILD_DIR}/yuicompressor-2.4.2.jar" />
|
||||
<loadfile description="Version to build" property="version" srcfile="version.txt" />
|
||||
|
||||
<property description="Folder for jquery, min, lite and packed target" name="DIST_DIR" value="./dist" />
|
||||
|
||||
|
@ -95,5 +96,13 @@
|
|||
<target name="all" depends="clean,jquery,min,pack">
|
||||
<echo message="Build complete." />
|
||||
</target>
|
||||
|
||||
<target name="openAjaxMetadata">
|
||||
<property name="target" value="openAjaxMetadata-jquery-${version}.xml" />
|
||||
<delete file="dist/jquery-*.xml" />
|
||||
<get src="http://www.exfer.net/jquery/createjQueryXMLDocs.py?version=1.3" dest="${target}" />
|
||||
<xslt includes="${target}" excludes="build.xml" destdir="./dist" style="build/style.xsl" extension=".xml" />
|
||||
<delete file="${target}" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
99
build/style.xsl
Normal file
99
build/style.xsl
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?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" indent="yes" />
|
||||
|
||||
<!-- TODO convert @type array notation to bracket notation, eg. Array<DOMElement> to [DOMElement] -->
|
||||
<xsl:template match="/*">
|
||||
<api xmlns="http://openajax.org/metadata">
|
||||
<class name="jQuery">
|
||||
<constructors>
|
||||
<xsl:for-each select="//function[@name='jQuery']">
|
||||
<constructor>
|
||||
<shortDescription><xsl:value-of select="desc" /></shortDescription>
|
||||
<description><xsl:value-of select="longdesc" /></description>
|
||||
<xsl:call-template name="parameters" />
|
||||
<returnType datatype="{@return}" />
|
||||
<xsl:call-template name="examples" />
|
||||
</constructor>
|
||||
</xsl:for-each>
|
||||
</constructors>
|
||||
<properties>
|
||||
<xsl:for-each select="//property">
|
||||
<xsl:sort select="translate(@name,'$.','')"/>
|
||||
<xsl:sort select="count(params)"/>
|
||||
<property name="{@name}" readonly="true" datatype="{@return}" default="">
|
||||
<xsl:call-template name="scope" />
|
||||
<shortDescription><xsl:value-of select="desc" /></shortDescription>
|
||||
<description><xsl:value-of select="longdesc" /></description>
|
||||
<xsl:call-template name="examples" />
|
||||
</property>
|
||||
</xsl:for-each>
|
||||
</properties>
|
||||
<methods>
|
||||
<xsl:for-each select="//function[@name!='jQuery']">
|
||||
<xsl:sort select="translate(@name,'$.','')"/>
|
||||
<xsl:sort select="count(params)"/>
|
||||
<method name="{@name}">
|
||||
<xsl:call-template name="scope" />
|
||||
<shortDescription><xsl:value-of select="desc" /></shortDescription>
|
||||
<description><xsl:value-of select="longdesc" /></description>
|
||||
<xsl:call-template name="parameters" />
|
||||
<returnType datatype="{@return}" />
|
||||
<xsl:call-template name="examples" />
|
||||
</method>
|
||||
</xsl:for-each>
|
||||
</methods>
|
||||
</class>
|
||||
</api>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="scope">
|
||||
<xsl:attribute name="scope">
|
||||
<xsl:choose>
|
||||
<xsl:when test="starts-with(@name, 'jQuery.')">static</xsl:when>
|
||||
<xsl:when test="not(starts-with(@name, 'jQuery.'))">instance</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="parameters">
|
||||
<parameters>
|
||||
<xsl:for-each select="params">
|
||||
<parameter name="{@name}" datatype="{@type}">
|
||||
<xsl:attribute name="usage">
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(@optional)">required</xsl:when>
|
||||
<xsl:when test="@optional">optional</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<description><xsl:value-of select="desc" /></description>
|
||||
<!-- TODO part of the spec, but with a very different interpretation -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="../option">
|
||||
<properties>
|
||||
<xsl:for-each select="../option">
|
||||
<property name="{@name}" datatype="{@type}" default="{@default}">
|
||||
<description><xsl:value-of select="desc" /></description>
|
||||
</property>
|
||||
</xsl:for-each>
|
||||
</properties>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</parameter>
|
||||
</xsl:for-each>
|
||||
</parameters>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="examples">
|
||||
<examples>
|
||||
<xsl:for-each select="example">
|
||||
<example>
|
||||
<description><xsl:value-of select="desc" /></description>
|
||||
<xsl:copy-of select="code|html|css" />
|
||||
</example>
|
||||
</xsl:for-each>
|
||||
</examples>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
Loading…
Reference in a new issue