-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateDocumentation.xsl
371 lines (349 loc) · 10.7 KB
/
generateDocumentation.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no"/>
<xsl:variable name="goBackLinkPrefix" select="'--!--'"/>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes"><!DOCTYPE html></xsl:text>
<html>
<head>
<title>
<xsl:value-of select="diderotProject/@name"/>
</title>
<link rel="stylesheet" href="style.css"/>
<link rel="stylesheet" href="highlight_js/monokai-sublime.css"/>
<script src="highlight_js/highlight.min.js"/>
<script src="folding.js"/>
<script>
hljs.initHighlightingOnLoad();
folder.setUpFoldingOnLoad(true);
</script>
</head>
<body>
<xsl:comment>
Documentation generated with Diderot: https://github.com/JosephCaillet/Diderot
</xsl:comment>
<xsl:comment>
Syntax highlighting provided by https://github.com/isagalaev/highlight.js
</xsl:comment>
<header>
<img src="logo.png">
<xsl:attribute name="alt">
<xsl:value-of select="@name"/> project logo.
</xsl:attribute>
</img>
<h1>
<xsl:value-of select="diderotProject/@name"/>
</h1>
</header>
<h2>
<xsl:value-of select="diderotProject/@name"/>
</h2>
<p>Made by <xsl:value-of select="diderotProject/@authors"/>, for <xsl:value-of
select="diderotProject/@company"/>.
</p>
<xsl:apply-templates/>
<div class="expand">
<span>↡ Expand all</span>
<span>↟ Collapse all</span>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="pluginsProperties"/>
<xsl:template match="diderotProject/description">
<p>
<xsl:call-template name="decodeNewLine">
<xsl:with-param name="text" select="."/>
</xsl:call-template>
</p>
</xsl:template>
<xsl:template match="responseOutputFormat">
<!--<p>-->
<!--These routes can produce the following outputs:-->
<!--<ul>-->
<!--<xsl:for-each select="format">-->
<!--<li>-->
<!--<xsl:value-of select="."/>-->
<!--</li>-->
<!--</xsl:for-each>-->
<!--</ul>-->
<!--</p>-->
</xsl:template>
<xsl:template match="userDefinedProperties">
<!--<xsl:if test="property">-->
<!--<p>-->
<!--The following routes' properties as been defined:-->
<!--<ul>-->
<!--<xsl:for-each select="property">-->
<!--<li>-->
<!--<xsl:value-of select="@name"/>-->
<!--</li>-->
<!--</xsl:for-each>-->
<!--</ul>-->
<!--</p>-->
<!--</xsl:if>-->
</xsl:template>
<xsl:template match="/diderotProject/route">
<h2>Routes summary</h2>
<div class="routesSummarySection">
<xsl:call-template name="printRoutesSummary">
<xsl:with-param name="route" select="."/>
<xsl:with-param name="tree" select="''"/>
</xsl:call-template>
</div>
<h2>Routes details</h2>
<div class="routesDetailsSection">
<xsl:call-template name="printRoutesDetails">
<xsl:with-param name="route" select="."/>
<xsl:with-param name="tree" select="''"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="printRoutesSummary">
<xsl:param name="route"/>
<xsl:param name="tree"/>
<span class="routeSummaryName">
<xsl:choose>
<xsl:when test="$route/methods/method or $route/description != ''">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#', $tree)"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="concat($goBackLinkPrefix, $tree)"/>
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</xsl:when>
<xsl:when test="true()">
<xsl:value-of select="@name"/>
</xsl:when>
</xsl:choose>
<xsl:for-each select="$route/routes/route">
<xsl:call-template name="printRoutesSummary">
<xsl:with-param name="route" select="."/>
<xsl:with-param name="tree" select="concat($tree, '/', @name)"/>
</xsl:call-template>
</xsl:for-each>
</span>
</xsl:template>
<xsl:template name="printRoutesDetails">
<xsl:param name="route"/>
<xsl:param name="tree"/>
<xsl:if test="$route/methods/method or $route/description != ''">
<div class="routeDetails">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#', $goBackLinkPrefix, $tree)"/>
</xsl:attribute>
⇧
</a>
<h3>
<xsl:attribute name="id">
<xsl:value-of select="$tree"/>
</xsl:attribute>
<xsl:if test="($route/methods/method or $route/description != '') and $tree = ''">
/
</xsl:if>
<xsl:value-of select="$tree"/>
</h3>
<span>
<xsl:value-of select="count($route/methods/method)"/> method(s)
</span>
<xsl:call-template name="printRouteDetail"/>
</div>
</xsl:if>
<xsl:for-each select="$route/routes/route">
<xsl:call-template name="printRoutesDetails">
<xsl:with-param name="route" select="."/>
<xsl:with-param name="tree" select="concat($tree, '/', @name)"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="printRouteDetail">
<div>
<p>
<xsl:call-template name="decodeNewLine">
<xsl:with-param name="text" select="description"/>
</xsl:call-template>
</p>
<xsl:if test="methods/method">
<xsl:for-each select="methods/method">
<div>
<xsl:variable name="baseClassName" select="'methodContainer'"/>
<xsl:choose>
<xsl:when test="@name = 'GET'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> getMethod
</xsl:attribute>
</xsl:when>
<xsl:when test="@name = 'HEAD'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> headMethod
</xsl:attribute>
</xsl:when>
<xsl:when test="@name = 'POST'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> postMethod
</xsl:attribute>
</xsl:when>
<xsl:when test="@name = 'OPTIONS'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> optionsMethod
</xsl:attribute>
</xsl:when>
<xsl:when test="@name = 'CONNECT'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> connectMethod
</xsl:attribute>
</xsl:when>
<xsl:when test="@name = 'TRACE'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> traceMethod
</xsl:attribute>
</xsl:when>
<xsl:when test="@name = 'PUT'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> putMethod
</xsl:attribute>
</xsl:when>
<xsl:when test="@name = 'PATCH'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> patchMethod
</xsl:attribute>
</xsl:when>
<xsl:when test="@name = 'DELETE'">
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/> deleteMethod
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">
<xsl:value-of select="$baseClassName"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<h4>
<xsl:value-of select="@name"/>
</h4>
<div class="method">
<p>
<xsl:call-template name="decodeNewLine">
<xsl:with-param name="text" select="description"/>
</xsl:call-template>
</p>
<xsl:if test="userDefinedProperties/value">
<div class="propertyContainer">
<h5>Properties</h5>
<table>
<xsl:for-each select="userDefinedProperties/value">
<tr>
<td>
<xsl:value-of select="@property"/>:
</td>
<td>
<xsl:value-of select="."/>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</xsl:if>
<xsl:if test="parameters/parameter">
<div>
<h5>Parameter(s)</h5>
<table class="params">
<tr>
<th>Name</th>
<th>Required</th>
<th>Description</th>
</tr>
<xsl:for-each select="parameters/parameter">
<tr>
<td>
<xsl:value-of select="@name"/>
</td>
<td>
<xsl:if test="@required = 'true'">
✔
</xsl:if>
</td>
<td>
<xsl:value-of select="@description"/>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</xsl:if>
<xsl:if test="responses/response">
<h5>Response(s)</h5>
<div class="responsesContainer">
<xsl:for-each select="responses/response">
<div class="responseContainer">
<h6>
<xsl:value-of select="@name"/>
</h6>
<div class="response">
<pre>
<xsl:call-template name="decodeNewLine">
<xsl:with-param name="text" select="description"/>
</xsl:call-template>
</pre>
<i>
Output:
<xsl:value-of select="@outputFormat"/>
</i>
<xsl:if test="string-length(outputSchema) != 0">
<pre>
<code>
<xsl:attribute name="class">
<xsl:value-of select="@outputFormat"/>
</xsl:attribute>
<xsl:call-template name="decodeNewLine">
<xsl:with-param name="text" select="outputSchema"/>
</xsl:call-template>
</code>
</pre>
</xsl:if>
</div>
</div>
</xsl:for-each>
</div>
</xsl:if>
</div>
</div>
</xsl:for-each>
</xsl:if>
</div>
</xsl:template>
<xsl:template name="decodeNewLine">
<xsl:param name="text"/>
<xsl:call-template name="replaceString">
<xsl:with-param name="text" select="$text"/>
<xsl:with-param name="replace" select="'&#xA;'"/>
<xsl:with-param name="by" select="'<br>'"/>
</xsl:call-template>
</xsl:template>
<!--by Mads Hansen : http://stackoverflow.com/questions/7520762/xslt-1-0-string-replace-function-->
<xsl:template name="replaceString">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="by"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of disable-output-escaping="yes" select="$by"/>
<xsl:call-template name="replaceString">
<xsl:with-param name="text"
select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="by" select="$by"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>