-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathDocumentation.xsl
220 lines (184 loc) · 7.06 KB
/
Documentation.xsl
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?xml version="1.0" encoding="utf-8"?>
<!-- ================================================================================ -->
<!-- Amend, distribute, spindle and mutilate as desired, but don't remove this header -->
<!-- A simple XML Documentation to basic HTML transformation stylesheet -->
<!-- (c)2005 by Emma Burrows -->
<!-- ================================================================================ -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- DOCUMENT TEMPLATE -->
<!-- Format the whole document as a valid HTML document -->
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">
//just wow
</script>
</head>
<body>
<xsl:apply-templates select="//assembly"/>
</body>
</html>
</xsl:template>
<!-- ASSEMBLY TEMPLATE -->
<!-- For each Assembly, display its name and then its member types -->
<xsl:template match="assembly">
<H1><xsl:value-of select="name"/></H1>
<xsl:apply-templates select="//member[contains(@name,'T:')]"/>
</xsl:template>
<!-- TYPE TEMPLATE -->
<!-- Loop through member types and display their properties and methods -->
<xsl:template match="//member[contains(@name,'T:')]">
<!-- Two variables to make code easier to read -->
<!-- A variable for the name of this type -->
<xsl:variable name="MemberName"
select="substring-after(@name, '.')"/>
<!-- Get the type's fully qualified name without the T: prefix -->
<xsl:variable name="FullMemberName"
select="substring-after(@name, ':')"/>
<!-- Display the type's name and information -->
<H2><xsl:value-of select="$MemberName"/></H2>
<!-- If this type has public fields, display them -->
<xsl:if test="//member[contains(@name,concat('F:',$FullMemberName))]">
<H3>Fields</H3>
<xsl:for-each select="//member[contains(@name,concat('F:',$FullMemberName))]">
<H4><xsl:value-of select="substring-after(@name, concat('F:',$FullMemberName,'.'))"/></H4>
<xsl:apply-templates/>
</xsl:for-each>
</xsl:if>
<!-- If this type has properties, display them -->
<xsl:if test="//member[contains(@name,concat('P:',$FullMemberName))]">
<H3>Properties</H3>
<xsl:for-each select="//member[contains(@name,concat('P:',$FullMemberName))]">
<H4><xsl:value-of select="substring-after(@name, concat('P:',$FullMemberName,'.'))"/></H4>
<xsl:apply-templates/>
</xsl:for-each>
</xsl:if>
<!-- If this type has methods, display them -->
<xsl:if test="//member[contains(@name,concat('M:',$FullMemberName))]">
<H3>Methods</H3>
<xsl:for-each select="//member[contains(@name,concat('M:',$FullMemberName))]">
<!-- If this is a constructor, display the type name
(instead of "#ctor"), or display the method name -->
<H4>
<xsl:choose>
<xsl:when test="contains(@name, '#ctor')">
Constructor:
<xsl:value-of select="$MemberName"/>
<xsl:value-of select="substring-after(@name, '#ctor')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after(@name, concat('M:',$FullMemberName,'.'))"/>
</xsl:otherwise>
</xsl:choose>
</H4>
<xsl:apply-templates select="summary"/>
<!-- Display parameters if there are any -->
<xsl:if test="count(param)!=0">
<H5>Parameters</H5>
<xsl:apply-templates select="param"/>
</xsl:if>
<!-- Display return value if there are any -->
<xsl:if test="count(returns)!=0">
<H5>Return Value</H5>
<xsl:apply-templates select="returns"/>
</xsl:if>
<!-- Display exceptions if there are any -->
<xsl:if test="count(exception)!=0">
<H5>Exceptions</H5>
<xsl:apply-templates select="exception"/>
</xsl:if>
<!-- Display examples if there are any -->
<xsl:if test="count(example)!=0">
<H5>Example</H5>
<xsl:apply-templates select="example"/>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>
<!-- OTHER TEMPLATES -->
<!-- Templates for other tags -->
<xsl:template match="c">
<CODE><xsl:apply-templates /></CODE>
</xsl:template>
<xsl:template match="code">
<PRE><xsl:apply-templates /></PRE>
</xsl:template>
<xsl:template match="example">
<P><STRONG>Example: </STRONG><xsl:apply-templates /></P>
</xsl:template>
<xsl:template match="exception">
<P><STRONG><xsl:value-of select="substring-after(@cref,'T:')"/>: </STRONG><xsl:apply-templates /></P>
</xsl:template>
<xsl:template match="include">
<A HREF="{@file}">External file</A>
</xsl:template>
<xsl:template match="para">
<P><xsl:apply-templates /></P>
</xsl:template>
<xsl:template match="param">
<P><STRONG><xsl:value-of select="@name"/>: </STRONG><xsl:apply-templates /></P>
</xsl:template>
<xsl:template match="paramref">
<EM><xsl:value-of select="@name" /></EM>
</xsl:template>
<xsl:template match="permission">
<P><STRONG>Permission: </STRONG><EM><xsl:value-of select="@cref" /> </EM><xsl:apply-templates /></P>
</xsl:template>
<xsl:template match="remarks">
<P><xsl:apply-templates /></P>
</xsl:template>
<xsl:template match="returns">
<P><STRONG>Return Value: </STRONG><xsl:apply-templates /></P>
</xsl:template>
<xsl:template match="see">
<EM>See: <xsl:value-of select="@cref" /></EM>
</xsl:template>
<xsl:template match="seealso">
<EM>See also: <xsl:value-of select="@cref" /></EM>
</xsl:template>
<xsl:template match="summary">
<P><xsl:apply-templates /></P>
</xsl:template>
<xsl:template match="list">
<xsl:choose>
<xsl:when test="@type='bullet'">
<UL>
<xsl:for-each select="listheader">
<LI><strong><xsl:value-of select="term"/>: </strong><xsl:value-of select="definition"/></LI>
</xsl:for-each>
<xsl:for-each select="list">
<LI><strong><xsl:value-of select="term"/>: </strong><xsl:value-of select="definition"/></LI>
</xsl:for-each>
</UL>
</xsl:when>
<xsl:when test="@type='number'">
<OL>
<xsl:for-each select="listheader">
<LI><strong><xsl:value-of select="term"/>: </strong><xsl:value-of select="definition"/></LI>
</xsl:for-each>
<xsl:for-each select="list">
<LI><strong><xsl:value-of select="term"/>: </strong><xsl:value-of select="definition"/></LI>
</xsl:for-each>
</OL>
</xsl:when>
<xsl:when test="@type='table'">
<TABLE>
<xsl:for-each select="listheader">
<TH>
<TD><xsl:value-of select="term"/></TD>
<TD><xsl:value-of select="definition"/></TD>
</TH>
</xsl:for-each>
<xsl:for-each select="list">
<TR>
<TD><strong><xsl:value-of select="term"/>: </strong></TD>
<TD><xsl:value-of select="definition"/></TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>