-
Notifications
You must be signed in to change notification settings - Fork 19
/
doc.html
174 lines (152 loc) · 5.68 KB
/
doc.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
<!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 data-type='[object Object]'>
<p>Output Leafdoc's own documentation to the console with:</p>
<pre><code>var LeafDoc = require('./src/leafdoc.js');
var doc = new LeafDoc();
doc.addDir('src');
console.log( doc.outputStr() );
</code></pre>
</section>
<h3 id='leafdoc-factory'>Creation</h3>
<section data-type='[object Object]'>
<table><thead>
<tr>
<th>Instantiation</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr id='leafdoc-leafdoc'>
<td><code>new <b>Leafdoc</b>(<nobr><Leafdoc options> <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 data-type='[object Object]'>
<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>
</tbody></table>
</section>
<h3 id='leafdoc-method'>Methods</h3>
<section data-type='[object Object]'>
<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></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 appropiate
template file for it.
Set <code>label</code> to the text for the sections in the generated docs.</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><Boolean> <i>isSource?</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><Boolean> <i>isSource?</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><Boolean> <i>isSource?</i></nobr>, <nobr><bar"> <i>foo</i></nobr>)</nobr></code></td>
<td><code>this</code></td>
<td>Parses the given string for Leafdoc comments. The string is assumed to
be source code with comments, unless <code>isSource</code> is explicitly set to <code>false</code>.
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>
</tbody></table>
</section>
</body></html>