-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
446 lines (414 loc) · 27.3 KB
/
index.html
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<a href="http://github.com/visionmedia/dox"><img alt="Fork me on GitHub" id="ribbon" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a><html>
<head>
<title>Dox</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style>body {
margin: 0;
padding: 0;
font: 14px/1.5 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
color: #252519;
}
a {
color: #252519;
}
a:hover {
text-decoration: underline;
color: #19469D;
}
p {
margin: 12px 0;
}
h1, h2, h3 {
margin: 0;
padding: 0;
}
table#source {
width: 100%;
border-collapse: collapse;
}
table#source td:first-child {
padding: 30px 40px 30px 40px;
vertical-align: top;
}
table#source td:first-child,
table#source td:first-child pre {
width: 450px;
}
table#source td:last-child {
padding: 30px 0 30px 40px;
border-left: 1px solid #E5E5EE;
background: #F5F5FF;
}
table#source tr {
border-bottom: 1px solid #E5E5EE;
}
table#source tr.filename {
padding-top: 40px;
border-top: 1px solid #E5E5EE;
}
table#source tr.filename td:first-child {
text-transform: capitalize;
}
table#source tr.filename td:last-child {
font-size: 12px;
}
table#source tr.filename h2 {
margin: 0;
padding: 0;
cursor: pointer;
}
table#source tr.code h1,
table#source tr.code h2,
table#source tr.code h3 {
margin-top: 30px;
font-family: "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;
font-size: 18px;
}
table#source tr.code h2 {
font-size: 16px;
}
table#source tr.code h3 {
font-size: 14px;
}
table#source tr.code ul {
margin: 15px 0 15px 35px;
padding: 0;
}
table#source tr.code ul li {
margin: 0;
padding: 1px 0;
}
table#source tr.code ul li p {
margin: 0;
padding: 0;
}
table#source tr.code td:first-child pre {
padding: 20px;
}
#ribbon {
position: fixed;
top: 0;
right: 0;
}
code .string { color: #219161; }
code .regexp { color: #219161; }
code .keyword { color: #954121; }
code .number { color: #19469D; }
code .comment { color: #bbb; }
code .this { color: #19469D; }</style>
<script>
$(function(){
$('tr.code').hide();
$('tr.filename').toggle(function(){
$(this).nextUntil('.filename').fadeIn();
}, function(){
$(this).nextUntil('.filename').fadeOut();
});
});
</script>
</head>
<body>
<table id="source"><tbody><tr><td><h1>Dox</h1><p>JavaScript documentation parser for <a href="http://ndoejs.org">node</a>. Check out the <a href="http://github.com/visionmedia/dox">Github Repo</a> for the source and installation guide.</p></td><td></td></tr><tr class="filename"><td><h2 id="lib/dox/index.js"><a href="#">index</a></h2></td><td>lib/dox/index.js</td></tr><tr class="code">
<td class="docs">
<p>Module dependencies.
</p>
</td>
<td class="code">
<pre><code><span class="variable">require</span>.<span class="variable">paths</span>.<span class="variable">unshift</span>(<span class="variable">__dirname</span> + <span class="string">'/koala/lib'</span>);
<span class="keyword">var</span> <span class="variable">sys</span> = <span class="variable">require</span>(<span class="string">'sys'</span>),
<span class="variable">fs</span> = <span class="variable">require</span>(<span class="string">'fs'</span>),
<span class="variable">path</span> = <span class="variable">require</span>(<span class="string">'path'</span>),
<span class="variable">koala</span> = <span class="variable">require</span>(<span class="string">'koala'</span>),
<span class="variable">utils</span> = <span class="variable">require</span>(<span class="string">'./utils'</span>),
<span class="variable">markdown</span> = <span class="variable">require</span>(<span class="string">'./markdown/lib/markdown'</span>);</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Library version.
</p>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">version</span> = <span class="string">'0.0.3'</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Style name.</p>
<ul><li><p><strong>type</strong>: <em>String</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">style</span> = <span class="string">'default'</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Project title.</p>
<ul><li><p><strong>type</strong>: <em>String</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">title</span> = <span class="string">'Dont forget to use --title to specify me!'</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Parse JSDoc.</p>
<ul><li><p><strong>type</strong>: <em>Boolean</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">jsdoc</span> = <span class="variable">true</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Project description.</p>
<ul><li><p><strong>type</strong>: <em>String</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">desc</span> = <span class="string">''</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Show private code.</p>
<ul><li><p><strong>type</strong>: <em>Boolean</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">showPrivate</span> = <span class="variable">false</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Github url for the ribbon.</p>
<ul><li><p><strong>type</strong>: <em>String</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">ribbon</span> = <span class="string">''</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Usage documentation.
</p>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">usage</span> = <span class="string">''</span>
+ <span class="string">'Usage: dox [options] <file ...>\n'</span>
+ <span class="string">'\n'</span>
+ <span class="string">'Options:\n'</span>
+ <span class="string">' -t, --title STR Project title\n'</span>
+ <span class="string">' -d, --desc STR Project description (markdown)\n'</span>
+ <span class="string">' -r, --ribbon URL Github ribbon url\n'</span>
+ <span class="string">' -s, --style NAME Document style, available: ["default"]\n'</span>
+ <span class="string">' -J, --no-jsdoc Disable jsdoc parsing (coverts to markdown)\n'</span>
+ <span class="string">' -p, --private Output private code in documentation\n'</span>
+ <span class="string">' -v, --version Output dox library version\n'</span>
+ <span class="string">' -h, --help Display help information'</span>
+ <span class="string">'\n'</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Parse the given arguments.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>Array</em> args</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="variable">exports</span>.<span class="variable">parse</span> = <span class="keyword">function</span>(<span class="variable">args</span>){
<span class="keyword">var</span> <span class="variable">files</span> = [];
<span class="comment">// Require an argument</span>
<span class="keyword">function</span> <span class="variable">requireArg</span>(){
<span class="keyword">if</span> (<span class="variable">args</span>.<span class="variable">length</span>) {
<span class="keyword">return</span> <span class="variable">args</span>.<span class="variable">shift</span>();
} <span class="keyword">else</span> {
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="class">Error</span>(<span class="variable">arg</span> + <span class="string">' requires an argument.'</span>);
}
}
<span class="comment">// Parse arguments</span>
<span class="keyword">while</span> (<span class="variable">args</span>.<span class="variable">length</span>) {
<span class="keyword">var</span> <span class="variable">arg</span> = <span class="variable">args</span>.<span class="variable">shift</span>();
<span class="keyword">switch</span> (<span class="variable">arg</span>) {
<span class="keyword">case</span> <span class="string">'-h'</span>:
<span class="keyword">case</span> <span class="string">'--help'</span>:
<span class="variable">sys</span>.<span class="variable">puts</span>(<span class="variable">usage</span>);
<span class="variable">process</span>.<span class="variable">exit</span>(<span class="number integer">1</span>);
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="string">'-v'</span>:
<span class="keyword">case</span> <span class="string">'--version'</span>:
<span class="variable">sys</span>.<span class="variable">puts</span>(<span class="variable">version</span>);
<span class="variable">process</span>.<span class="variable">exit</span>(<span class="number integer">1</span>);
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="string">'-t'</span>:
<span class="keyword">case</span> <span class="string">'--title'</span>:
<span class="variable">title</span> = <span class="variable">requireArg</span>();
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="string">'-d'</span>:
<span class="keyword">case</span> <span class="string">'--desc'</span>:
<span class="variable">desc</span> = <span class="variable">requireArg</span>();
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="string">'-s'</span>:
<span class="keyword">case</span> <span class="string">'--style'</span>:
<span class="variable">style</span> = <span class="variable">requireArg</span>();
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="string">'-J'</span>:
<span class="keyword">case</span> <span class="string">'--no-jsdoc'</span>:
<span class="variable">jsdoc</span> = <span class="variable">false</span>;
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="string">'-p'</span>:
<span class="keyword">case</span> <span class="string">'--private'</span>:
<span class="variable">showPrivate</span> = <span class="variable">true</span>;
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="string">'-r'</span>:
<span class="keyword">case</span> <span class="string">'--ribbon'</span>:
<span class="variable">ribbon</span> = <span class="variable">requireArg</span>();
<span class="keyword">break</span>;
<span class="keyword">default</span>:
<span class="variable">files</span>.<span class="variable">push</span>(<span class="variable">arg</span>);
}
}
<span class="keyword">if</span> (<span class="variable">files</span>.<span class="variable">length</span>) {
<span class="variable">log</span>(<span class="string">'parsing '</span> + <span class="variable">files</span>.<span class="variable">length</span> + <span class="string">' file(s)'</span>);
<span class="keyword">var</span> <span class="variable">pending</span> = <span class="variable">files</span>.<span class="variable">length</span>;
<span class="comment">// Style</span>
<span class="variable">log</span>(<span class="string">'loading '</span> + <span class="variable">style</span> + <span class="string">' style'</span>);
<span class="keyword">var</span> <span class="variable">head</span> = <span class="variable">fs</span>.<span class="variable">readFileSync</span>(<span class="variable">__dirname</span> + <span class="string">'/styles/'</span> + <span class="variable">style</span> + <span class="string">'/head.html'</span>, <span class="string">'utf8'</span>);
<span class="keyword">var</span> <span class="variable">foot</span> = <span class="variable">fs</span>.<span class="variable">readFileSync</span>(<span class="variable">__dirname</span> + <span class="string">'/styles/'</span> + <span class="variable">style</span> + <span class="string">'/foot.html'</span>, <span class="string">'utf8'</span>);
<span class="keyword">var</span> <span class="variable">css</span> = <span class="variable">fs</span>.<span class="variable">readFileSync</span>(<span class="variable">__dirname</span> + <span class="string">'/styles/'</span> + <span class="variable">style</span> + <span class="string">'/style.css'</span>, <span class="string">'utf8'</span>);
<span class="comment">// Substitutions</span>
<span class="variable">head</span> = <span class="variable">head</span>.<span class="variable">replace</span>(<span class="regexp">/\{\{title\}\}/g</span>, <span class="variable">title</span>).<span class="variable">replace</span>(<span class="regexp">/\{\{style\}\}/</span>, <span class="variable">css</span>);
<span class="comment">// Ribbon</span>
<span class="keyword">if</span> (<span class="variable">ribbon</span>) {
<span class="variable">log</span>(<span class="string">'generating ribbon'</span>);
<span class="variable">sys</span>.<span class="variable">print</span>(<span class="string">'<a href="'</span> + <span class="variable">ribbon</span> + <span class="string">'">'</span>
+ <span class="string">'<img alt="Fork me on GitHub" id="ribbon"'</span>
+ <span class="string">' src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">'</span>
+ <span class="string">'</a>'</span>);
}
<span class="variable">sys</span>.<span class="variable">print</span>(<span class="variable">head</span>);
<span class="variable">sys</span>.<span class="variable">print</span>(<span class="string">'<table id="source"><tbody>'</span>);
<span class="comment">// Render files</span>
<span class="keyword">var</span> <span class="variable">first</span> = <span class="variable">true</span>;
<span class="variable">files</span>.<span class="variable">forEach</span>(<span class="keyword">function</span>(<span class="variable">file</span>){
<span class="variable">log</span>(<span class="string">'parsing '</span> + <span class="variable">file</span>);
<span class="variable">fs</span>.<span class="variable">readFile</span>(<span class="variable">file</span>, <span class="string">'utf8'</span>, <span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">str</span>){
<span class="keyword">if</span> (<span class="variable">err</span>) <span class="keyword">throw</span> <span class="variable">err</span>;
<span class="keyword">if</span> (<span class="variable">first</span>) {
<span class="keyword">if</span> (<span class="variable">desc</span>) <span class="variable">desc</span> = <span class="variable">markdown</span>.<span class="variable">toHTML</span>(<span class="variable">desc</span>);
<span class="variable">sys</span>.<span class="variable">print</span>(<span class="string">'<tr><td><h1>'</span> + <span class="variable">title</span> + <span class="string">'</h1>'</span> + <span class="variable">desc</span> + <span class="string">'</td><td></td></tr>'</span>);
<span class="variable">first</span> = <span class="variable">false</span>;
}
<span class="variable">sys</span>.<span class="variable">print</span>(<span class="string">'<tr class="filename"><td><h2 id="'</span> + <span class="variable">file</span> + <span class="string">'"><a href="#">'</span>
+ <span class="variable">path</span>.<span class="variable">basename</span>(<span class="variable">file</span>, <span class="string">'.js'</span>) + <span class="string">'</a></h2></td><td>'</span>
+ <span class="variable">file</span> + <span class="string">'</td></tr>'</span>);
<span class="variable">sys</span>.<span class="variable">print</span>(<span class="variable">render</span>(<span class="variable">str</span>, <span class="variable">file</span>));
--<span class="variable">pending</span> || <span class="variable">sys</span>.<span class="variable">print</span>(<span class="variable">foot</span>, <span class="string">'</tbody></table>'</span>);
});
});
} <span class="keyword">else</span> {
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="class">Error</span>(<span class="string">'files required.'</span>);
}
};</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Generate html for the given string of code.</p>
<ul><li>foo<ul><li>bar</li></ul></li><li>baz</li></ul>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>param</strong>: <em>String</em> file</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="variable">render</span> = <span class="variable">exports</span>.<span class="variable">render</span> = <span class="keyword">function</span>(<span class="variable">str</span>, <span class="variable">file</span>){
<span class="keyword">var</span> <span class="variable">parts</span> = <span class="variable">str</span>.<span class="variable">split</span>(<span class="regexp">/\s*\/</span>\*([^]+?)\*\<span class="regexp">/\s*/g</span>),
<span class="variable">blocks</span> = [];
<span class="comment">// Populate blocks</span>
<span class="keyword">for</span> (<span class="keyword">var</span> <span class="variable">i</span> = <span class="number integer">0</span>, <span class="variable">len</span> = <span class="variable">parts</span>.<span class="variable">length</span>; <span class="variable">i</span> &<span class="variable">lt</span>; <span class="variable">len</span>; ++<span class="variable">i</span>) {
<span class="keyword">var</span> <span class="variable">part</span> = <span class="variable">parts</span>[<span class="variable">i</span>],
<span class="variable">next</span> = <span class="variable">parts</span>[<span class="variable">i</span> + <span class="number integer">1</span>] || <span class="string">''</span>;
<span class="comment">// Empty</span>
<span class="keyword">if</span> (<span class="regexp">/^\s*$/</span>.<span class="variable">test</span>(<span class="variable">part</span>)) {
<span class="keyword">continue</span>;
<span class="comment">// Ignored comment</span>
} <span class="keyword">else</span> <span class="keyword">if</span> (<span class="regexp">/^!\s*\*/</span>.<span class="variable">test</span>(<span class="variable">part</span>)) {
<span class="keyword">continue</span>;
} <span class="keyword">else</span> {
++<span class="variable">i</span>;
<span class="comment">// Support @ignore and --private</span>
<span class="keyword">if</span> (<span class="variable">utils</span>.<span class="variable">ignore</span>(<span class="variable">part</span>) || (<span class="variable">utils</span>.<span class="variable">isPrivate</span>(<span class="variable">part</span>) &<span class="variable">amp</span>;&<span class="variable">amp</span>; !<span class="variable">showPrivate</span>)) <span class="keyword">continue</span>;
<span class="keyword">var</span> <span class="variable">part</span> = <span class="variable">part</span>.<span class="variable">replace</span>(<span class="regexp">/^ *\* ?/gm</span>, <span class="string">''</span>);
<span class="variable">blocks</span>.<span class="variable">push</span>({
<span class="variable">comment</span>: <span class="variable">markdown</span>.<span class="variable">toHTML</span>(<span class="variable">utils</span>.<span class="variable">toMarkdown</span>(<span class="variable">part</span>)),
<span class="variable">code</span>: <span class="variable">koala</span>.<span class="variable">render</span>(&<span class="variable">quot</span>;.<span class="variable">js</span>&<span class="variable">quot</span>;, <span class="variable">utils</span>.<span class="variable">escape</span>(<span class="variable">next</span>))
});
}
}
<span class="comment">// Generate html</span>
<span class="keyword">var</span> <span class="variable">html</span> = [];
<span class="keyword">for</span> (<span class="keyword">var</span> <span class="variable">i</span> = <span class="number integer">0</span>, <span class="variable">len</span> = <span class="variable">blocks</span>.<span class="variable">length</span>; <span class="variable">i</span> &<span class="variable">lt</span>; <span class="variable">len</span>; ++<span class="variable">i</span>) {
<span class="keyword">var</span> <span class="variable">block</span> = <span class="variable">blocks</span>[<span class="variable">i</span>];
<span class="variable">html</span>.<span class="variable">push</span>(<span class="string">'<tr class="code">'</span>);
<span class="variable">html</span>.<span class="variable">push</span>(<span class="string">'<td class="docs">'</span>, <span class="variable">block</span>.<span class="variable">comment</span> || <span class="string">''</span>, <span class="string">'</td>'</span>);
<span class="variable">html</span>.<span class="variable">push</span>(<span class="string">'<td class="code">'</span>, <span class="variable">block</span>.<span class="variable">code</span>
? <span class="string">'<pre><code>'</span> + <span class="variable">block</span>.<span class="variable">code</span> + <span class="string">'</code></pre>'</span>
: <span class="string">''</span>, <span class="string">'</td>'</span>);
<span class="variable">html</span>.<span class="variable">push</span>(<span class="string">'</tr>'</span>);
}
<span class="keyword">return</span> <span class="variable">html</span>.<span class="variable">join</span>(<span class="string">'\n'</span>);
};</code></pre>
</td>
</tr><tr class="filename"><td><h2 id="lib/dox/utils.js"><a href="#">utils</a></h2></td><td>lib/dox/utils.js</td></tr><tr class="code">
<td class="docs">
<p>Check if the given string of docs appears to be private.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>Boolean</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="variable">exports</span>.<span class="variable">isPrivate</span> = <span class="keyword">function</span>(<span class="variable">str</span>) {
<span class="keyword">return</span> <span class="variable">str</span>.<span class="variable">indexOf</span>(<span class="string">'@private'</span>) &<span class="variable">gt</span>;= <span class="number integer">0</span>
|| <span class="variable">str</span>.<span class="variable">indexOf</span>(<span class="string">'@api private'</span>) &<span class="variable">gt</span>;= <span class="number integer">0</span>;
}</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Convert the given string of jsdoc to markdown.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="variable">exports</span>.<span class="variable">toMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>) {
<span class="keyword">var</span> <span class="variable">first</span> = <span class="variable">true</span>;
<span class="keyword">return</span> <span class="variable">str</span>
.<span class="variable">replace</span>(<span class="regexp">/^((?:[A-Z]\w* ?)+):/gm</span>, <span class="string">'## $1'</span>)
.<span class="variable">replace</span>(<span class="regexp">/^ *@(\w+) *\{([^}]+)\}( *[^\n]+)?/gm</span>, <span class="keyword">function</span>(<span class="variable">_</span>, <span class="variable">key</span>, <span class="variable">type</span>, <span class="variable">desc</span>){
<span class="keyword">var</span> <span class="variable">prefix</span> = <span class="string">''</span>;
<span class="keyword">if</span> (<span class="variable">first</span>) {
<span class="variable">first</span> = <span class="variable">false</span>;
<span class="variable">prefix</span> = <span class="string">'## \n'</span>;
}
<span class="keyword">return</span> <span class="variable">prefix</span> + <span class="string">'\n - **'</span> + <span class="variable">key</span> + <span class="string">'**: _'</span> + <span class="variable">type</span>.<span class="variable">split</span>(<span class="regexp">/ *[|\/</span>] */).<span class="variable">join</span>(<span class="string">' | '</span>) + <span class="string">'_ '</span> + (<span class="variable">desc</span> || <span class="string">''</span>) + <span class="string">'\n'</span>;
})
.<span class="variable">replace</span>(<span class="regexp">/^ *@(\w+) *(\w+)/gm</span>, <span class="string">' - **$1**: _$2_\n'</span>);
}</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Escape the given string of html.</p>
<h2>Examples</h2>
<pre><code>escape('<foo>');
// => "&lt;foo&gt;"</code></pre>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="variable">exports</span>.<span class="variable">escape</span> = <span class="keyword">function</span>(<span class="variable">html</span>){
<span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)
.<span class="variable">replace</span>(<span class="regexp">/&(?!\w+;)/g</span>, <span class="string">'&'</span>)
.<span class="variable">replace</span>(<span class="regexp">/</g</span>, <span class="string">'<'</span>)
.<span class="variable">replace</span>(<span class="regexp">/>/g</span>, <span class="string">'>'</span>)
.<span class="variable">replace</span>(<span class="regexp">/"/g</span>, <span class="string">'"'</span>);
}</code></pre>
</td>
</tr> </body>
</html></tbody></table>