tomdoc 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module TomDoc
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,320 @@
1
+ .\" generated with Ronn/v0.5
2
+ .\" http://github.com/rtomayko/ronn/
3
+ .
4
+ .TH "TOMDOC" "5" "May 2010" "MOJOMBO" "TomDoc Manual"
5
+ .
6
+ .SH "NAME"
7
+ \fBtomdoc\fR \-\- TomDoc for Ruby \- Version 0.9.0
8
+ .
9
+ .SH "Purpose"
10
+ TomDoc is a code documentation specification that helps you write precise
11
+ documentation that is nice to read in plain text, yet structured enough to be
12
+ automatically extracted and processed by a machine.
13
+ .
14
+ .P
15
+ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
16
+ "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
17
+ interpreted as described in RFC 2119.
18
+ .
19
+ .SH "Class/Module Documentation"
20
+ TomDoc for classes and modules consists of a block of single comment markers
21
+ (#) that appear directly above the class/module definition. Lines SHOULD be
22
+ wrapped at 80 characters. Lines that contain text MUST be separated from the
23
+ comment marker by a single space. Lines that do not contain text SHOULD
24
+ consist of just a comment marker (no trailing spaces).
25
+ .
26
+ .P
27
+ Code examples SHOULD be indented two spaces (three spaces from the comment
28
+ marker).
29
+ .
30
+ .IP "" 4
31
+ .
32
+ .nf
33
+
34
+ # Various methods useful for performing mathematical operations. All
35
+ # methods are module methods and should be called on the Math module.
36
+ # For example:
37
+ #
38
+ # Math.square_root(9)
39
+ # # => 3
40
+ #
41
+ module Math
42
+ ...
43
+ end
44
+ .
45
+ .fi
46
+ .
47
+ .IP "" 0
48
+ .
49
+ .SH "Method Documentation"
50
+ A quick example will serve to best illustrate the TomDoc method documentation
51
+ format:
52
+ .
53
+ .IP "" 4
54
+ .
55
+ .nf
56
+
57
+ # Duplicate some text an abitrary number of times.
58
+ #
59
+ # text \- The String to be duplicated.
60
+ # count \- The Integer number of times to duplicate the text.
61
+ #
62
+ # Examples
63
+ #
64
+ # multiplex('Tom', 4)
65
+ # # => 'TomTomTomTom'
66
+ #
67
+ # Returns the duplicated String.
68
+ def multiplex(text, count)
69
+ text * count
70
+ end
71
+ .
72
+ .fi
73
+ .
74
+ .IP "" 0
75
+ .
76
+ .P
77
+ TomDoc for a specific method consists of a block of single comment markers (#)
78
+ that appears directly above the method. There MUST NOT be a blank line between
79
+ the comment block and the method definition. A TomDoc method block consists of
80
+ a description section (required), an arguments section (required if the method
81
+ takes any arguments), an examples section (optional), and a returns section
82
+ (required). Lines that contain text MUST be separated from the comment
83
+ marker by a single space. Lines that do not contain text SHOULD consist of
84
+ just a comment marker (no trailing spaces).
85
+ .
86
+ .SS "The Description Section"
87
+ The description section SHOULD be in plain sentences. Each sentence SHOULD end
88
+ with a period. Good descriptions explain what the code does at a high level.
89
+ Make sure to explain any unexpected behavior that the method may have, or any
90
+ pitfalls that the user may experience. Lines SHOULD be wrapped at 80
91
+ characters.
92
+ .
93
+ .P
94
+ If a method's description begins with "Public:" then that method will be
95
+ considered part of the project's public API. For example:
96
+ .
97
+ .IP "" 4
98
+ .
99
+ .nf
100
+
101
+ # Public: Initialize a new Widget.
102
+ .
103
+ .fi
104
+ .
105
+ .IP "" 0
106
+ .
107
+ .P
108
+ This annotation is designed to let developers know which methods are
109
+ considered stable. You SHOULD use this to document the public API of your
110
+ project. This information can then be used along with \fISemantic
111
+ Versioning\fR to inform decisions on when major, minor, and
112
+ patch versions should be incremented.
113
+ .
114
+ .P
115
+ If a method's description begins with "Deprecated:" then that method will be
116
+ considered as deprecated and users will know that it will be removed in a
117
+ future version.
118
+ .
119
+ .SS "The Arguments Section"
120
+ The arguments section consists of a list of arguments. Each list item MUST be
121
+ comprised of the name of the argument, a dash, and an explanation of the
122
+ argument in plain sentences. The expected type (or types) of each argument
123
+ SHOULD be clearly indicated in the explanation. When you specify a type, use
124
+ the proper classname of the type (for instance, use 'String' instead of
125
+ 'string' to refer to a String type). The dashes following each argument name
126
+ should be lined up in a single column. Lines SHOULD be wrapped at 80 columns.
127
+ If an explanation is longer than that, additional lines MUST be indented at
128
+ least two spaces but SHOULD be indented to match the indentation of the
129
+ explanation. For example:
130
+ .
131
+ .IP "" 4
132
+ .
133
+ .nf
134
+
135
+ # element \- The Symbol representation of the element. The Symbol should
136
+ # contain only lowercase ASCII alpha characters.
137
+ .
138
+ .fi
139
+ .
140
+ .IP "" 0
141
+ .
142
+ .P
143
+ All arguments are assumed to be required. If an argument is optional, you MUST
144
+ specify the default value:
145
+ .
146
+ .IP "" 4
147
+ .
148
+ .nf
149
+
150
+ # host \- The String hostname to bind (default: '0.0.0.0').
151
+ .
152
+ .fi
153
+ .
154
+ .IP "" 0
155
+ .
156
+ .P
157
+ For hash arguments, you SHOULD enumerate each valid option in a way similar
158
+ to how normal arguments are defined:
159
+ .
160
+ .IP "" 4
161
+ .
162
+ .nf
163
+
164
+ # options \- The Hash options used to refine the selection (default: {}):
165
+ # :color \- The String color to restrict by (optional).
166
+ # :weight \- The Float weight to restrict by. The weight should
167
+ # be specified in grams (optional).
168
+ .
169
+ .fi
170
+ .
171
+ .IP "" 0
172
+ .
173
+ .SS "The Examples Section"
174
+ The examples section MUST start with the word "Examples" on a line by
175
+ itself. The next line SHOULD be blank. The following lines SHOULD be indented
176
+ by two spaces (three spaces from the initial comment marker) and contain code
177
+ that shows off how to call the method and (optional) examples of what it
178
+ returns. Everything under the "Examples" line should be considered code, so
179
+ make sure you comment out lines that show return values. Separate examples
180
+ should be separated by a blank line. For example:
181
+ .
182
+ .IP "" 4
183
+ .
184
+ .nf
185
+
186
+ # Examples
187
+ #
188
+ # multiplex('x', 4)
189
+ # # => 'xxxx'
190
+ #
191
+ # multiplex('apple', 2)
192
+ # # => 'appleapple'
193
+ .
194
+ .fi
195
+ .
196
+ .IP "" 0
197
+ .
198
+ .SS "The Returns Section"
199
+ The returns section should explain in plain sentences what is returned from
200
+ the method. The line MUST begin with "Returns". If only a single thing is
201
+ returned, state the nature and type of the value. For example:
202
+ .
203
+ .IP "" 4
204
+ .
205
+ .nf
206
+
207
+ # Returns the duplicated String.
208
+ .
209
+ .fi
210
+ .
211
+ .IP "" 0
212
+ .
213
+ .P
214
+ If several different types may be returned, list all of them. For example:
215
+ .
216
+ .IP "" 4
217
+ .
218
+ .nf
219
+
220
+ # Returns the given element Symbol or nil if none was found.
221
+ .
222
+ .fi
223
+ .
224
+ .IP "" 0
225
+ .
226
+ .P
227
+ If the return value of the method is not intended to be used, then you should
228
+ simply state:
229
+ .
230
+ .IP "" 4
231
+ .
232
+ .nf
233
+
234
+ # Returns nothing.
235
+ .
236
+ .fi
237
+ .
238
+ .IP "" 0
239
+ .
240
+ .P
241
+ If the method raises exceptions that the caller may be interested in, add
242
+ additional lines that explain each exception and under what conditions it may
243
+ be encountered. The lines MUST begin with "Raises". For example:
244
+ .
245
+ .IP "" 4
246
+ .
247
+ .nf
248
+
249
+ # Returns nothing.
250
+ # Raises Errno::ENOENT if the file cannot be found.
251
+ # Raises Errno::EACCES if the file cannot be accessed.
252
+ .
253
+ .fi
254
+ .
255
+ .IP "" 0
256
+ .
257
+ .P
258
+ Lines SHOULD be wrapped at 80 columns. Wrapped lines MUST be indented under
259
+ the above line by at least two spaces. For example:
260
+ .
261
+ .IP "" 4
262
+ .
263
+ .nf
264
+
265
+ # Returns the atomic mass of the element as a Float. The value is in
266
+ # unified atomic mass units.
267
+ .
268
+ .fi
269
+ .
270
+ .IP "" 0
271
+ .
272
+ .SH "Special Considerations"
273
+ .
274
+ .SS "Attributes"
275
+ Ruby's built in \fBattr_reader\fR, \fBattr_writer\fR, and \fBattr_accessor\fR require a
276
+ bit more consideration. With TomDoc you SHOULD NOT use \fBattr_access\fR since it
277
+ represents two methods with different signatures. Restricting yourself in this
278
+ way also makes you think more carefully about the read vs. write behavior and
279
+ whether each should be part of the Public API.
280
+ .
281
+ .P
282
+ Here is an example TomDoc for \fBattr_reader\fR.
283
+ .
284
+ .IP "" 4
285
+ .
286
+ .nf
287
+
288
+ # Public: Get the user's name.
289
+ #
290
+ # Returns the String name of the user.
291
+ attr_reader :name
292
+ .
293
+ .fi
294
+ .
295
+ .IP "" 0
296
+ .
297
+ .P
298
+ Here is an example TomDoc for \fBattr_writer\fR. The parameter name should be the
299
+ same as the attribute name.
300
+ .
301
+ .IP "" 4
302
+ .
303
+ .nf
304
+
305
+ # Set the user's name.
306
+ #
307
+ # name \- The String name of the user.
308
+ #
309
+ # Returns nothing.
310
+ attr_writer :name
311
+ .
312
+ .fi
313
+ .
314
+ .IP "" 0
315
+ .
316
+ .P
317
+ While this approach certainly takes up more space than listing dozens of
318
+ attributes on a single line, it allows for individual documentation of each
319
+ attribute. Attributes are an extremely important part of a class and should be
320
+ treated with the same care as any other methods.
@@ -0,0 +1,285 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v0.5'>
6
+ <title>tomdoc(5) -- TomDoc for Ruby - Version 0.9.0</title>
7
+ <style type='text/css'>
8
+ body {margin:0}
9
+ #man, #man code, #man pre, #man tt, #man kbd, #man samp {
10
+ font-family:consolas,monospace;
11
+ font-size:16px;
12
+ line-height:1.3;
13
+ color:#343331;
14
+ background:#fff; }
15
+ #man { max-width:89ex; text-align:justify; margin:0 25px 25px 25px }
16
+ #man h1, #man h2, #man h3 { color:#232221;clear:left }
17
+ #man h1 { font-size:28px; margin:15px 0 30px 0; text-align:center }
18
+ #man h2 { font-size:18px; margin-bottom:0; margin-top:10px; line-height:1.3; }
19
+ #man h3 { font-size:16px; margin:0 0 0 4ex; }
20
+ #man p, #man ul, #man ol, #man dl, #man pre { margin:0 0 18px 0; }
21
+ #man pre {
22
+ color:#333231;
23
+ background:#edeceb;
24
+ padding:5px 7px;
25
+ margin:0px 0 20px 0;
26
+ border-left:2ex solid #ddd}
27
+ #man pre + h2, #man pre + h3 {
28
+ margin-top:22px;
29
+ }
30
+ #man h2 + pre, #man h3 + pre {
31
+ margin-top:5px;
32
+ }
33
+ #man > p, #man > ul, #man > ol, #man > dl, #man > pre { margin-left:8ex; }
34
+ #man dt { margin:0; clear:left }
35
+ #man dt.flush { float:left; width:8ex }
36
+ #man dd { margin:0 0 0 9ex }
37
+ #man code, #man strong, #man b { font-weight:bold; color:#131211; }
38
+ #man pre code { font-weight:normal; color:#232221; background:inherit }
39
+ #man em, var, u {
40
+ font-style:normal; color:#333231; border-bottom:1px solid #999; }
41
+ #man h1.man-title { display:none; }
42
+ #man ol.man, #man ol.man li { margin:2px 0 10px 0; padding:0;
43
+ float:left; width:33%; list-style-type:none;
44
+ text-transform:uppercase; font-size:18px; color:#999;
45
+ letter-spacing:1px;}
46
+ #man ol.man { width:100%; }
47
+ #man ol.man li.tl { text-align:left }
48
+ #man ol.man li.tc { text-align:center;letter-spacing:4px }
49
+ #man ol.man li.tr { text-align:right }
50
+ #man ol.man a { color:#999 }
51
+ #man ol.man a:hover { color:#333231 }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <div id='man'>
56
+
57
+ <h1 class='man-title'>tomdoc(5)</h1>
58
+
59
+ <ol class='head man'>
60
+ <li class='tl'>tomdoc(5)</li>
61
+ <li class='tc'>TomDoc Manual</li>
62
+ <li class='tr'>tomdoc(5)</li>
63
+ </ol>
64
+
65
+ <h2 id='NAME'>NAME</h2>
66
+ <p><code>tomdoc</code> -- TomDoc for Ruby - Version 0.9.0</p>
67
+
68
+ <h2>Purpose</h2>
69
+
70
+ <p>TomDoc is a code documentation specification that helps you write precise
71
+ documentation that is nice to read in plain text, yet structured enough to be
72
+ automatically extracted and processed by a machine.</p>
73
+
74
+ <p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
75
+ "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
76
+ interpreted as described in RFC 2119.</p>
77
+
78
+ <h2>Class/Module Documentation</h2>
79
+
80
+ <p>TomDoc for classes and modules consists of a block of single comment markers
81
+ (#) that appear directly above the class/module definition. Lines SHOULD be
82
+ wrapped at 80 characters. Lines that contain text MUST be separated from the
83
+ comment marker by a single space. Lines that do not contain text SHOULD
84
+ consist of just a comment marker (no trailing spaces).</p>
85
+
86
+ <p>Code examples SHOULD be indented two spaces (three spaces from the comment
87
+ marker).</p>
88
+
89
+ <pre><code># Various methods useful for performing mathematical operations. All
90
+ # methods are module methods and should be called on the Math module.
91
+ # For example:
92
+ #
93
+ # Math.square_root(9)
94
+ # # =&gt; 3
95
+ #
96
+ module Math
97
+ ...
98
+ end
99
+ </code></pre>
100
+
101
+ <h2>Method Documentation</h2>
102
+
103
+ <p>A quick example will serve to best illustrate the TomDoc method documentation
104
+ format:</p>
105
+
106
+ <pre><code># Duplicate some text an abitrary number of times.
107
+ #
108
+ # text - The String to be duplicated.
109
+ # count - The Integer number of times to duplicate the text.
110
+ #
111
+ # Examples
112
+ #
113
+ # multiplex('Tom', 4)
114
+ # # =&gt; 'TomTomTomTom'
115
+ #
116
+ # Returns the duplicated String.
117
+ def multiplex(text, count)
118
+ text * count
119
+ end
120
+ </code></pre>
121
+
122
+ <p>TomDoc for a specific method consists of a block of single comment markers (#)
123
+ that appears directly above the method. There MUST NOT be a blank line between
124
+ the comment block and the method definition. A TomDoc method block consists of
125
+ a description section (required), an arguments section (required if the method
126
+ takes any arguments), an examples section (optional), and a returns section
127
+ (required). Lines that contain text MUST be separated from the comment
128
+ marker by a single space. Lines that do not contain text SHOULD consist of
129
+ just a comment marker (no trailing spaces).</p>
130
+
131
+ <h3>The Description Section</h3>
132
+
133
+ <p>The description section SHOULD be in plain sentences. Each sentence SHOULD end
134
+ with a period. Good descriptions explain what the code does at a high level.
135
+ Make sure to explain any unexpected behavior that the method may have, or any
136
+ pitfalls that the user may experience. Lines SHOULD be wrapped at 80
137
+ characters.</p>
138
+
139
+ <p>If a method's description begins with "Public:" then that method will be
140
+ considered part of the project's public API. For example:</p>
141
+
142
+ <pre><code># Public: Initialize a new Widget.
143
+ </code></pre>
144
+
145
+ <p>This annotation is designed to let developers know which methods are
146
+ considered stable. You SHOULD use this to document the public API of your
147
+ project. This information can then be used along with <a href="http://semver.org">Semantic
148
+ Versioning</a> to inform decisions on when major, minor, and
149
+ patch versions should be incremented.</p>
150
+
151
+ <p>If a method's description begins with "Deprecated:" then that method will be
152
+ considered as deprecated and users will know that it will be removed in a
153
+ future version.</p>
154
+
155
+ <h3>The Arguments Section</h3>
156
+
157
+ <p>The arguments section consists of a list of arguments. Each list item MUST be
158
+ comprised of the name of the argument, a dash, and an explanation of the
159
+ argument in plain sentences. The expected type (or types) of each argument
160
+ SHOULD be clearly indicated in the explanation. When you specify a type, use
161
+ the proper classname of the type (for instance, use 'String' instead of
162
+ 'string' to refer to a String type). The dashes following each argument name
163
+ should be lined up in a single column. Lines SHOULD be wrapped at 80 columns.
164
+ If an explanation is longer than that, additional lines MUST be indented at
165
+ least two spaces but SHOULD be indented to match the indentation of the
166
+ explanation. For example:</p>
167
+
168
+ <pre><code># element - The Symbol representation of the element. The Symbol should
169
+ # contain only lowercase ASCII alpha characters.
170
+ </code></pre>
171
+
172
+ <p>All arguments are assumed to be required. If an argument is optional, you MUST
173
+ specify the default value:</p>
174
+
175
+ <pre><code># host - The String hostname to bind (default: '0.0.0.0').
176
+ </code></pre>
177
+
178
+ <p>For hash arguments, you SHOULD enumerate each valid option in a way similar
179
+ to how normal arguments are defined:</p>
180
+
181
+ <pre><code># options - The Hash options used to refine the selection (default: {}):
182
+ # :color - The String color to restrict by (optional).
183
+ # :weight - The Float weight to restrict by. The weight should
184
+ # be specified in grams (optional).
185
+ </code></pre>
186
+
187
+ <h3>The Examples Section</h3>
188
+
189
+ <p>The examples section MUST start with the word "Examples" on a line by
190
+ itself. The next line SHOULD be blank. The following lines SHOULD be indented
191
+ by two spaces (three spaces from the initial comment marker) and contain code
192
+ that shows off how to call the method and (optional) examples of what it
193
+ returns. Everything under the "Examples" line should be considered code, so
194
+ make sure you comment out lines that show return values. Separate examples
195
+ should be separated by a blank line. For example:</p>
196
+
197
+ <pre><code># Examples
198
+ #
199
+ # multiplex('x', 4)
200
+ # # =&gt; 'xxxx'
201
+ #
202
+ # multiplex('apple', 2)
203
+ # # =&gt; 'appleapple'
204
+ </code></pre>
205
+
206
+ <h3>The Returns Section</h3>
207
+
208
+ <p>The returns section should explain in plain sentences what is returned from
209
+ the method. The line MUST begin with "Returns". If only a single thing is
210
+ returned, state the nature and type of the value. For example:</p>
211
+
212
+ <pre><code># Returns the duplicated String.
213
+ </code></pre>
214
+
215
+ <p>If several different types may be returned, list all of them. For example:</p>
216
+
217
+ <pre><code># Returns the given element Symbol or nil if none was found.
218
+ </code></pre>
219
+
220
+ <p>If the return value of the method is not intended to be used, then you should
221
+ simply state:</p>
222
+
223
+ <pre><code># Returns nothing.
224
+ </code></pre>
225
+
226
+ <p>If the method raises exceptions that the caller may be interested in, add
227
+ additional lines that explain each exception and under what conditions it may
228
+ be encountered. The lines MUST begin with "Raises". For example:</p>
229
+
230
+ <pre><code># Returns nothing.
231
+ # Raises Errno::ENOENT if the file cannot be found.
232
+ # Raises Errno::EACCES if the file cannot be accessed.
233
+ </code></pre>
234
+
235
+ <p>Lines SHOULD be wrapped at 80 columns. Wrapped lines MUST be indented under
236
+ the above line by at least two spaces. For example:</p>
237
+
238
+ <pre><code># Returns the atomic mass of the element as a Float. The value is in
239
+ # unified atomic mass units.
240
+ </code></pre>
241
+
242
+ <h2>Special Considerations</h2>
243
+
244
+ <h3>Attributes</h3>
245
+
246
+ <p>Ruby's built in <code>attr_reader</code>, <code>attr_writer</code>, and <code>attr_accessor</code> require a
247
+ bit more consideration. With TomDoc you SHOULD NOT use <code>attr_access</code> since it
248
+ represents two methods with different signatures. Restricting yourself in this
249
+ way also makes you think more carefully about the read vs. write behavior and
250
+ whether each should be part of the Public API.</p>
251
+
252
+ <p>Here is an example TomDoc for <code>attr_reader</code>.</p>
253
+
254
+ <pre><code># Public: Get the user's name.
255
+ #
256
+ # Returns the String name of the user.
257
+ attr_reader :name
258
+ </code></pre>
259
+
260
+ <p>Here is an example TomDoc for <code>attr_writer</code>. The parameter name should be the
261
+ same as the attribute name.</p>
262
+
263
+ <pre><code># Set the user's name.
264
+ #
265
+ # name - The String name of the user.
266
+ #
267
+ # Returns nothing.
268
+ attr_writer :name
269
+ </code></pre>
270
+
271
+ <p>While this approach certainly takes up more space than listing dozens of
272
+ attributes on a single line, it allows for individual documentation of each
273
+ attribute. Attributes are an extremely important part of a class and should be
274
+ treated with the same care as any other methods.</p>
275
+
276
+
277
+ <ol class='foot man'>
278
+ <li class='tl'>MOJOMBO</li>
279
+ <li class='tc'>May 2010</li>
280
+ <li class='tr'>tomdoc(5)</li>
281
+ </ol>
282
+
283
+ </div>
284
+ </body>
285
+ </html>