-
Notifications
You must be signed in to change notification settings - Fork 19
/
Leafdoc.html
286 lines (244 loc) · 8.7 KB
/
Leafdoc.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
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style>
table {
border-collapse: collapse;
}
table td, table th {
border: 1px solid #888;
}
pre code {
display: inline-block;
background: #eee;
}
td:last-child code {
background: #eee;
}
body {
font-family: Sans;
}
</style>
</head>
<body>
<h2>Leafdoc generated API reference</h2>
<h2 id='leafdoc'>Leafdoc</h2>
<p>Represents the Leafdoc parser</p>
<h3 id='leafdoc-example'>Usage example</h3>
<section>
<p>Output Leafdoc's own documentation to the console with:</p>
<pre><code>var LeafDoc = require('./src/leafdoc.js');
var doc = new LeafDoc();
doc.addFile('src/leafdoc.js');
console.log( doc.outputStr() );
</code></pre>
</section>
<h3 id='leafdoc-constructor'>Constructor</h3>
<section>
<table><thead>
<tr>
<th>Constructor</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr id='leafdoc-leafdoc'>
<td><code>new <b>Leafdoc</b>(<nobr><<a href='#leafdoc-option'>Leafdoc options</a>> <i>options</i></nobr>)</nobr></code></td>
<td>Constructor for a new Leafdoc parser</td>
</tr>
</tbody></table>
</section>
<h3 id='leafdoc-option'>Options</h3>
<section>
<table><thead>
<tr>
<th>Option</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr id='leafdoc-templatedir'>
<td><code><b>templateDir</b></code></td>
<td><code>String</code>
<td><code>'templates/basic'</code></td>
<td>Defines which subdirectory (relative to the directory the curent JS
script is running) holds the handlebars template files for building up the HTML.</td>
</tr>
<tr id='leafdoc-showinheritanceswhenempty'>
<td><code><b>showInheritancesWhenEmpty</b></code></td>
<td><code>Boolean</code>
<td><code>false</code></td>
<td>When <code>true</code>, child classes/namespaces will display documentables from ancestors, even if the child class doesn't have any of such documentables.
e.g. display inherited events even if the child doesn't define any new events.</td>
</tr>
<tr id='leafdoc-leadingcharacter'>
<td><code><b>leadingCharacter</b></code></td>
<td><code>String</code>
<td><code>'🍂'</code></td>
<td>Overrides the Leaf symbol as the leading character for documentation lines.
See also <a href="#leafdoc-setleadingcharacter"><code>setLeadingCharacter</code></a>.</td>
</tr>
<tr id='leafdoc-customdocumentables'>
<td><code><b>customDocumentables</b></code></td>
<td><code>Map</code>
<td><code>{}</code></td>
<td>A key-value map. Each pair will be passed to <a href="#leafdoc-registerdocumentable"><code>registerDocumentable</code></a>.</td>
</tr>
<tr id='leafdoc-verbose'>
<td><code><b>verbose</b></code></td>
<td><code>Boolean</code>
<td><code>false</code></td>
<td>Set to <code>true</code> to display more information as files are being read.</td>
</tr>
</tbody></table>
</section>
<h3 id='leafdoc-method'>Methods</h3>
<section>
<table><thead>
<tr>
<th>Method</th>
<th>Returns</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr id='leafdoc-registerdocumentable'>
<td><code><b>registerDocumentable</b>(<nobr><String> <i>name</i></nobr>, <nobr><String> <i>label?</i></nobr>, <nobr><Boolean> <i>inheritable?</i></nobr>)</nobr></code></td>
<td><code>this</code></td>
<td>Registers a new documentable type, beyond the preset ones (function,
property, etc). New documentable should also not be an already used
keyword (class, namespace, inherits, etc).
When registering new documentables, make sure that there is an appropriate
template file for it.
Set <code>label</code> to the text for the sections in the generated docs.
<code>inheritable</code> parameter determines documentable can be inherited via inherits keyword in a subclass.</td>
</tr>
<tr id='leafdoc-gettemplateengine'>
<td><code><b>getTemplateEngine</b>()</nobr></code></td>
<td><code>Handlebars</code></td>
<td>Returns handlebars template engine used to render templates.
You can use it for override helpers or register a new one.</td>
</tr>
<tr id='leafdoc-setleadingcharacter'>
<td><code><b>setLeadingCharacter</b>(<nobr><String> <i>char</i></nobr>)</nobr></code></td>
<td><code>this</code></td>
<td>In the rare case you don't want to use 🍂 as the leading character for
leaf directives, run this function with the desired character, e.g.
<code>setLeadingCharacter('@');</code>
The new leading character will apply only to files/dirs/strings parsed from
that moment on, so it's a good idea to call this before anything else.</td>
</tr>
<tr id='leafdoc-adddir'>
<td><code><b>addDir</b>(<nobr><String> <i>dirname</i></nobr>, <nobr><String[]> <i>extensions?</i></nobr>)</nobr></code></td>
<td><code>this</code></td>
<td>Recursively scans a directory, and parses any files that match the
given <code>extensions</code> (by default <code>.js</code> and <code>.leafdoc</code>, mind the dots).
Files with a <code>.leafdoc</code> extension will be treated as leafdoc-only
instead of source.</td>
</tr>
<tr id='leafdoc-addfile'>
<td><code><b>addFile</b>(<nobr><String> <i>filename</i></nobr>)</nobr></code></td>
<td><code>this</code></td>
<td>Parses the given file using <a href="#leafdoc-addbuffer"><code>addBuffer</code></a>.</td>
</tr>
<tr id='leafdoc-addbuffer'>
<td><code><b>addBuffer</b>(<nobr><Buffer> <i>buf</i></nobr>, <nobr><String> <i>filename?</i></nobr>)</nobr></code></td>
<td><code>this</code></td>
<td>Parses the given buffer using <a href="#leafdoc-addstr"><code>addStr</code></a> underneath.</td>
</tr>
<tr id='leafdoc-addstr'>
<td><code><b>addStr</b>(<nobr><String> <i>str</i></nobr>, <nobr><String> <i>filename?</i></nobr>)</nobr></code></td>
<td><code>this</code></td>
<td>Parses the given string for Leafdoc directives.
directive.</td>
</tr>
<tr id='leafdoc-outputstr'>
<td><code><b>outputStr</b>()</nobr></code></td>
<td><code>String</code></td>
<td>Outputs the documentation to a string.
Use only after all the needed files have been parsed.</td>
</tr>
<tr id='leafdoc-outputjson'>
<td><code><b>outputJSON</b>()</nobr></code></td>
<td><code>String</code></td>
<td>Outputs the internal documentation tree to a JSON blob, without any formatting.
Use only after all the needed files have been parsed.</td>
</tr>
</tbody></table>
</section>
<h2 id='command-line-usage'>Command-line usage</h2>
<p>Leafdoc includes a small command-line utility, useful when running from a console or a shell script, accepting some of the Leafdoc options. The syntax is:</p>
<p><code>leafdoc [options] [files]</code></p>
<h3 id='command-line-usage-example'>Usage example</h3>
<section>
<p><code>leafdoc -t templates/pretty -c '@' --verbose -o documentation.html src</code></p>
</section>
<h3 id='command-line-usage-option'>Options</h3>
<section>
<table><thead>
<tr>
<th>Option</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr id='command-line-usage-template'>
<td><code><b>template</b></code></td>
<td><code>String</code>
<td><code>'templates/basic'</code></td>
<td>Akin to <a href="#leafdoc.templatedir">Leafdoc.templateDir</a></td>
</tr>
<tr id='command-line-usage-t'>
<td><code><b>t</b></code></td>
<td><code></code>
<td><code></code></td>
<td>Alias of <code>template</code></td>
</tr>
<tr id='command-line-usage-character'>
<td><code><b>character</b></code></td>
<td><code>String</code>
<td><code>'🍂'</code></td>
<td>Akin to <a href="#leafdoc.leadingcharacter">Leafdoc.leadingCharacter</a></td>
</tr>
<tr id='command-line-usage-c'>
<td><code><b>c</b></code></td>
<td><code></code>
<td><code></code></td>
<td>Alias of <code>character</code></td>
</tr>
<tr id='command-line-usage-verbose'>
<td><code><b>verbose</b></code></td>
<td><code>Boolean</code>
<td><code>false</code></td>
<td>Akin to <a href="#leafdoc.verbose">Leafdoc.verbose</a></td>
</tr>
<tr id='command-line-usage-v'>
<td><code><b>v</b></code></td>
<td><code></code>
<td><code></code></td>
<td>Alias of <code>verbose</code></td>
</tr>
<tr id='command-line-usage-output'>
<td><code><b>output</b></code></td>
<td><code>String</code>
<td><code>undefined</code></td>
<td>File to write the documentation to. If left empty, documentation will be outputted to <code>stdout</code> instead.</td>
</tr>
<tr id='command-line-usage-o'>
<td><code><b>o</b></code></td>
<td><code></code>
<td><code></code></td>
<td>Alias of <code>output</code>
Alias of <code>output</code></td>
</tr>
<tr id='command-line-usage-json'>
<td><code><b>json</b></code></td>
<td><code>Boolean</code>
<td><code>false</code></td>
<td>Write the internal JSON representation of the documentation instead of a templated HTML file.</td>
</tr>
</tbody></table>
</section>
</body></html>