aboutsummaryrefslogtreecommitdiffstats
path: root/build/style.xsl
blob: 14e61321e9498129b10f66a857a83cc41eaaeed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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>