File: rdtool.xml

package info (click to toggle)
rubybook 0.2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,252 kB
  • ctags: 1,043
  • sloc: xml: 60,486; makefile: 25
file content (327 lines) | stat: -rw-r--r-- 10,754 bytes parent folder | download | duplicates (3)
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
<ppdoc>
<copyright>
    Copyright (c) 2001 by Addison Wesley Longman.  This
    material may be distributed only subject to the terms and
    conditions set forth in the Open Publication License, v1.0 or
    later (the latest version is presently available at
    http://www.opencontent.org/openpub/).
</copyright>
<chapter name="Embedded Documentation">
<p/>
<figure type="figure">Figure not available...</figure>
<p/>
<figure type="figure">Figure not available...</figure>
<p/>
So you've written a masterpiece, a class in a class of its own, and
you'd like to share it with the world. But, being a responsible
developer, you feel the need to document your creation. What do you
do?  The simplest solution is to use Ruby's built-in documentation
format, RD, and <tt>rdtool</tt>, a Ruby utility suite that converts this
documentation into a variety of output formats.
<p/>
<tt>rdtool</tt> scans a file for <tt>=begin</tt> and <tt>=end</tt>{=begin...=end@<tt></tt>{=begin
pairs, and
extracts the text between them all. This text is assumed to be
documentation in RD format. The text is then processed according to a
simple set of rules:
<p/>
<ul>
<li> Lines of text flush to the left margin are converted to
  paragraphs.
</li><li> Lines starting with one to four equals signs are headings. ``=''
  is a first-level heading, ``=='' a second-level heading, and so
  on. ``+'' and ``++'' can be used to signal fifth- and sixth-level
  headings if you really want to go that deep.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[    = Top Level Heading
    == Second Level Heading
    ...
]]></fullcode>
=<nbsp/>Top<nbsp/>Level<nbsp/>Heading
==<nbsp/>Second<nbsp/>Level<nbsp/>Heading
...
</alltt>
</codefragment>
</li><li> Lines in which the first nonspace is an asterisk indicate the
  beginnings of bullet lists. Continuation lines for each bullet item
  should line up with the text on the first line. Lists may be nested.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[    This is normal text
    * start of a
      multiline bullet item
    * and another
      * nested item
      * second nested
    * third item at top level
]]></fullcode>
This<nbsp/>is<nbsp/>normal<nbsp/>text
*<nbsp/>start<nbsp/>of<nbsp/>a
<nbsp/><nbsp/>multiline<nbsp/>bullet<nbsp/>item
*<nbsp/>and<nbsp/>another
<nbsp/><nbsp/>*<nbsp/>nested<nbsp/>item
<nbsp/><nbsp/>*<nbsp/>second<nbsp/>nested
*<nbsp/>third<nbsp/>item<nbsp/>at<nbsp/>top<nbsp/>level
</alltt>
</codefragment>
</li><li> Lines where the first nonspace characters are digits between
  parentheses indicate numbered lists. The actual digits used are
  ignored. Again, lists may be nested.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[    (1) A numbered item
        * subitem in a bulleted list
        * subitem
    (2) Second numbered item
    (9) This will actually be labeled '3.'
]]></fullcode>
(1)<nbsp/>A<nbsp/>numbered<nbsp/>item
<nbsp/><nbsp/><nbsp/><nbsp/>*<nbsp/>subitem<nbsp/>in<nbsp/>a<nbsp/>bulleted<nbsp/>list
<nbsp/><nbsp/><nbsp/><nbsp/>*<nbsp/>subitem
(2)<nbsp/>Second<nbsp/>numbered<nbsp/>item
(9)<nbsp/>This<nbsp/>will<nbsp/>actually<nbsp/>be<nbsp/>labeled<nbsp/>'3.'
</alltt>
</codefragment>
</li><li> Lines starting with a colon indicate labeled lists. The text on
  the colon line is the label. The immediately following text (which
  may not be indented less than the label) is the descriptive
  text. Again, each type of list may be nested.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[    : red
      when the light is red, you
      must stop
    : amber
      the amber light means that things are about to change. Either:
      * step on the gas, or
      * slam on the brakes
    : green
      green means GO
]]></fullcode>
:<nbsp/>red
<nbsp/><nbsp/>when<nbsp/>the<nbsp/>light<nbsp/>is<nbsp/>red,<nbsp/>you
<nbsp/><nbsp/>must<nbsp/>stop
:<nbsp/>amber
<nbsp/><nbsp/>the<nbsp/>amber<nbsp/>light<nbsp/>means<nbsp/>that<nbsp/>things<nbsp/>are<nbsp/>about<nbsp/>to<nbsp/>change.<nbsp/>Either:
<nbsp/><nbsp/>*<nbsp/>step<nbsp/>on<nbsp/>the<nbsp/>gas,<nbsp/>or
<nbsp/><nbsp/>*<nbsp/>slam<nbsp/>on<nbsp/>the<nbsp/>brakes
:<nbsp/>green
<nbsp/><nbsp/>green<nbsp/>means<nbsp/>GO
</alltt>
</codefragment>
</li><li> Lines starting with three minus signs are a special kind of
  labeled list, when the labels are method names and signatures. The
  source in Figure A.1 on page 518 shows a handful of these in
  action.
</li></ul>
<p/>
Indented text that isn't part of a list is set verbatim (such as the
stuff under ``Synopsis'' in Figures A.1 and A.2).
<section>Inline Formatting</section>
<p/>
Within blocks of text and headings, you can use special <em>inline
  sequences</em> to control text formatting. All sequences are nested
within a set of double parentheses.
<p/>
<table>
<th>
  <td><b>Sequence</b></td>
  <td><b>Example</b></td>
  <td><b>Intended Use</b></td>
</th>
<tr>
  <td>((*emphasis*))</td>
  <td><em>emphasis</em></td>
  <td>Emphasis (normally italic)</td>
</tr>
<tr>
  <td>(({code stuff}))</td>
  <td><tt>code stuff</tt></td>
  <td>Code</td>
</tr>
<tr>
  <td>((|variable|))</td>
  <td><em>variable</em></td>
  <td>Variable name</td>
</tr>
<tr>
  <td>((%type me%))</td>
  <td><tt>type me</tt></td>
  <td>Keyboard input</td>
</tr>
<tr>
  <td>((:index term:))</td>
  <td>index term</td>
  <td>Something to be indexed</td>
</tr>
<tr>
  <td>((&lt;reference&gt;))</td>
  <td><u>reference</u></td>
  <td>Hyperlink reference</td>
</tr>
<tr>
  <td>((-footnote-))</td>
  <td>text.<sup>4</sup></td>
  <td>Footnote text. A reference is placed
inline, and the text of the footnote appears at the bottom of the
page.</td>
</tr>
<tr>
  <td>(('verb'))</td>
  <td>verb</td>
  <td>Verbatim text</td>
</tr>
<bottomrule/></table>
<p/>
<section>Cross References</section>
<p/>
The content of headings, the labels of labeled lists, and the names of
methods are automatically
made into potential cross reference targets.  You make links to these
targets from elsewhere in the document by citing their contents in the
<tt>((&lt;...&gt;))</tt> construct.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[  = Synopsis
  ...
  See ((<Return Codes>)) for details.
  ..
  == Instance Methods

  --- Tempfile.open( filename )
      Opens the file...
      
  == Return Codes
  ..
  The method ((<Tempfile.open>)) raises an (({IOException}))...
]]></fullcode>
=<nbsp/>Synopsis
...
See<nbsp/>((&lt;Return<nbsp/>Codes&gt;))<nbsp/>for<nbsp/>details.
..
==<nbsp/>Instance<nbsp/>Methods
<p/>
---<nbsp/>Tempfile.open(<nbsp/>filename<nbsp/>)
<nbsp/><nbsp/><nbsp/><nbsp/>Opens<nbsp/>the<nbsp/>file...
<p/>
==<nbsp/>Return<nbsp/>Codes
..
The<nbsp/>method<nbsp/>((&lt;Tempfile.open&gt;))<nbsp/>raises<nbsp/>an<nbsp/>(({IOException}))...
</alltt>
</codefragment>
<p/>
If a reference starts with ``URL:'', <tt>rdtool</tt> attempts to format it as an
external hyperlink.
<p/>
The reference  <tt>((&lt;display part|label&gt;))</tt> generates a link to
<tt>label</tt> but places the text ``display part'' in the output
document. This is used in the description section of the example in
Figure A.1 on page 518 to generate references to the method names:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[perspective, apart from the unusual ((<(({new}))|Tempfile.new>)),
...
]]></fullcode>
perspective,<nbsp/>apart<nbsp/>from<nbsp/>the<nbsp/>unusual<nbsp/>((&lt;(({new}))|Tempfile.new&gt;)),
...
</alltt>
</codefragment>
<p/>
This construct displays the word ``new'' in code font but uses it as
a hyperlink to the method <tt>Tempfile.new</tt>.
<section>Method Names</section>
<p/>
<tt>rdtool</tt> makes certain assumptions about the format of method
names. Class or module methods should appear as <tt>Class.method</tt>, 
instance methods as <tt>Class#method</tt>, and class or module
constants as <tt>Class::Const</tt>.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[  --- Tempfile::IOWRITE
      Open the file write-only.
      ...
  --- Tempfile.new( filename )
      Constructs a temporary file in the given directory. The file
      ...
  --- Tempfile#open
      Reopens ((|aTempfile|)) using mode ``r+'', which allows reading
      ..
]]></fullcode>
---<nbsp/>Tempfile::IOWRITE
<nbsp/><nbsp/><nbsp/><nbsp/>Open<nbsp/>the<nbsp/>file<nbsp/>write-only.
<nbsp/><nbsp/><nbsp/><nbsp/>...
---<nbsp/>Tempfile.new(<nbsp/>filename<nbsp/>)
<nbsp/><nbsp/><nbsp/><nbsp/>Constructs<nbsp/>a<nbsp/>temporary<nbsp/>file<nbsp/>in<nbsp/>the<nbsp/>given<nbsp/>directory.<nbsp/>The<nbsp/>file
<nbsp/><nbsp/><nbsp/><nbsp/>...
---<nbsp/>Tempfile#open
<nbsp/><nbsp/><nbsp/><nbsp/>Reopens<nbsp/>((|aTempfile|))<nbsp/>using<nbsp/>mode<nbsp/>``r+'',<nbsp/>which<nbsp/>allows<nbsp/>reading
<nbsp/><nbsp/><nbsp/><nbsp/>..
</alltt>
</codefragment>
<section>Including Other Files</section>
<p/>
The contents of <em>filename</em> will be inserted  wherever the
document contains
<p/>
<syntax>
&lt;&lt;&lt; <nt>filename</nt>
</syntax>
<p/>
If the file is specified with an <tt>.rd</tt> or <tt>.rb</tt> extension, it
will be interpreted as RD documentation.
<p/>
If the filename has no extension, <tt>rdtool</tt> will look for a file with an
extension that matches the type of output being produced (<tt>.html</tt>
for HTML files, <tt>.man</tt> for man files, and so on) and interpolate
that file's contents in the <tt>output</tt> stream. Thus, a line such as:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[  <<< header
]]></fullcode>
&lt;&lt;&lt;<nbsp/>header
</alltt>
</codefragment>
<p/>
could be used to add an output-dependent header to a document.
<section>Using rdtool</section>
<p/>
RD documentation can be included directly in a Ruby source program or 
written into a separate file (which by convention will have the
extension <tt>.rd</tt>). These files are processed using the <tt>rd2</tt>
command to produce appropriately formatted output.
<p/>
<syntax>
rd2  <opt><nt>options</nt></opt>  <nt>inputfile</nt>   <opt> &gt;<nt>outputfile</nt> </opt>
</syntax>
<p/>
Some common options include:
<p/>
<table>
<tr>
  <td><tt>-r</tt><em>format</em></td>
  <td>Select an output
  format. <tt>-rrd/rd2html-lib.rb</tt> produces HTML output (the
  default). <tt>-rrd/rd2man-lib.rb</tt> produces Unix man page output.</td>
</tr>
<tr>
  <td><tt>-o</tt><em>name</em></td>
  <td>Set the base part of the output filename.</td>
</tr>
<tr>
  <td><tt>--help</tt></td>
  <td>List the full set of options.</td>
</tr>
</table>
<p/>
<section>Mandatory Disclaimer</section>
<p/>
As we are writing this, RD and <tt>rdtool</tt> are undergoing continuous
development. It is likely that some of the details we give here will
be out of date (or just plain wrong) by the time you read this.
<p/>
Included with the <tt>rdtool</tt> distribution is the file <tt>README.rd</tt>. We
suggest you do so, as it will give you the current scoop on producing
Ruby documentation.
</chapter>
</ppdoc>