1 | # Format
|
2 |
|
3 | ### Documentation comments
|
4 |
|
5 | Start comments with `/**` to begin a comment block. Things will be inferred based on the next line.
|
6 |
|
7 | ```js
|
8 | /**
|
9 | * Clears the screen after a specified `delay`.
|
10 | */
|
11 |
|
12 | function clear(delay) {
|
13 | }
|
14 | ```
|
15 |
|
16 | This will be the output. Notice how the `title`, `type` and `signature` are all derived automatically.
|
17 |
|
18 | ```js
|
19 | { blocks: [
|
20 | { title: "clear",
|
21 | type: "function",
|
22 | signature: "clear(delay)",
|
23 | body: "Clears the screen after a specified `delay`.",
|
24 | ... } ] }
|
25 | ```
|
26 |
|
27 | In markdown output mode (`-f markdown`), it will appear like so:
|
28 |
|
29 | > ### clear
|
30 | > > `clear(delay)`
|
31 | >
|
32 | > Clears the screen after a specified `delay`.
|
33 |
|
34 | ### Titles
|
35 |
|
36 | Titles are automatically-inferred, but they can be explicitly stated by a first line that ends in `:`.
|
37 |
|
38 | ```js
|
39 | /**
|
40 | * Mdx:
|
41 | * Generic documentation extractor.
|
42 | */
|
43 |
|
44 | module.exports = {
|
45 | ```
|
46 |
|
47 | ### Title and signature
|
48 |
|
49 | To define a signature, use the format `<title> : <signature>` for the first line.
|
50 |
|
51 | ```js
|
52 | /**
|
53 | * on : on(event, handler)
|
54 | * Binds an event.
|
55 | */
|
56 |
|
57 | on () { ... }
|
58 | ```
|
59 |
|
60 | ### Types
|
61 |
|
62 | Types are also automatically-inferred, but they can be explicitly stated by adding `(...)` before the title ends.
|
63 |
|
64 | ```js
|
65 | /**
|
66 | * Mdx (module):
|
67 | * Generic documentation extractor.
|
68 | */
|
69 |
|
70 | module.exports = {
|
71 | ```
|
72 |
|
73 | If you don't have a title, you can begin the first line with `(...)`:
|
74 |
|
75 | ```js
|
76 | /**
|
77 | * (attribute) The ratio between the circumference and diameter.
|
78 | */
|
79 |
|
80 | const PI = 3.14159;
|
81 | ```
|
82 |
|
83 | ### Tags
|
84 |
|
85 | Tags begin with `word:`. This convention is taken from [tomdoc].
|
86 |
|
87 | ```js
|
88 | /**
|
89 | * Internal: returns the full name.
|
90 | */
|
91 |
|
92 | function fullName(first, last) {
|
93 | }
|
94 | ```
|
95 |
|
96 | They can be used in conjunction with titles, just place the tag in the second line.
|
97 |
|
98 | ```js
|
99 | /**
|
100 | * fullName:
|
101 | * Internal: returns the full name.
|
102 | */
|
103 |
|
104 | function fullName(first, last) {
|
105 | }
|
106 | ```
|
107 |
|
108 | ### Parameters
|
109 |
|
110 | (TODO)
|
111 |
|
112 | ```js
|
113 | /* ...
|
114 | * title - the title of the article
|
115 | * options - (Object) a list of available options
|
116 | */
|
117 | ```
|
118 |
|
119 | ### Code blocks
|
120 |
|
121 | Indent them by 2 spaces. (TODO)
|
122 |
|
123 | ```js
|
124 | /**
|
125 | * Find Records by a specific field name and value.
|
126 | *
|
127 | * let r = Record.find(name)
|
128 | * //=> { ... }
|
129 | */
|
130 | ```
|
131 |
|
132 | ### Subheadings
|
133 |
|
134 | (TODO)
|
135 |
|
136 | ```js
|
137 | /**
|
138 | * Find Records by a specific field name and value.
|
139 | *
|
140 | * Caveats:
|
141 | * This is not available in Win32 environments.
|
142 | *
|
143 | * See also:
|
144 | * - [where]
|
145 | */
|
146 | ```
|
147 |
|
148 | ### Custom signatures
|
149 |
|
150 | You may format the title line like so: (TODO)
|
151 |
|
152 | ```js
|
153 | /**
|
154 | * addClass : addClass(classname, ...)
|
155 | * Adds more classes.
|
156 | */
|
157 | ```
|
158 |
|
159 | Alternatively, you can define it like tomdoc: (TODO)
|
160 |
|
161 | ```js
|
162 | /**
|
163 | * Adds more classes.
|
164 | *
|
165 | * Signature:
|
166 | * addClass(classname, ...)
|
167 | */
|
168 | ```
|
169 |
|
170 | ## Format
|
171 |
|
172 | ```
|
173 | # [TITLE [(TYPE):]
|
174 | # [TAG, TAGn:] [(TYPE)] [DESCRIPTION]
|
175 | # [BODY]
|
176 | ```
|
177 |
|
178 | * Title is inferred if not available
|
179 | * A block is only recognized if it has a type, tag, or title
|
180 | * ...or if it has an extra `*` or `#` in the beginning of the comment block
|
181 |
|
182 | [tomdoc]: http://tomdoc.org/
|