OSDN Git Service

ruby-1.9.1-rc1
[splhack/AndroidRuby.git] / lib / ruby-1.9.1-rc1 / lib / rdoc / README
1 = RDOC - Ruby Documentation System
2
3 This package contains RDoc and RDoc::Markup.  RDoc is an application that
4 produces documentation for one or more Ruby source files.  We work similarly to
5 JavaDoc, parsing the source, and extracting the definition for classes,
6 modules, and methods (along with includes and requires).  We associate with
7 these optional documentation contained in the immediately preceding comment
8 block, and then render the result using a pluggable output formatter.
9 RDoc::Markup is a library that converts plain text into various output formats.
10 The markup library is used to interpret the comment blocks that RDoc uses to
11 document methods, classes, and so on.
12
13 == Roadmap
14
15 * If you want to use RDoc to create documentation for your Ruby source files,
16   read on.
17 * If you want to include extensions written in C, see RDoc::C_Parser
18 * For information on the various markups available in comment blocks, see
19   RDoc::Markup.
20 * If you want to drive RDoc programmatically, see RDoc::RDoc.
21 * If you want to use the library to format text blocks into HTML, have a look
22   at RDoc::Markup.
23 * If you want to try writing your own HTML output template, see
24   RDoc::Generator::HTML
25
26 == Summary
27
28 Once installed, you can create documentation using the 'rdoc' command
29 (the command is 'rdoc.bat' under Windows)
30
31   % rdoc [options] [names...]
32
33 Type "rdoc --help" for an up-to-date option summary.
34
35 A typical use might be to generate documentation for a package of Ruby
36 source (such as rdoc itself). 
37
38   % rdoc
39
40 This command generates documentation for all the Ruby and C source
41 files in and below the current directory.  These will be stored in a
42 documentation tree starting in the subdirectory 'doc'.
43
44 You can make this slightly more useful for your readers by having the
45 index page contain the documentation for the primary file.  In our
46 case, we could type
47
48   % rdoc --main rdoc.rb
49
50 You'll find information on the various formatting tricks you can use
51 in comment blocks in the documentation this generates.
52
53 RDoc uses file extensions to determine how to process each file.  File names
54 ending +.rb+ and <tt>.rbw</tt> are assumed to be Ruby source.  Files
55 ending +.c+ are parsed as C files.  All other files are assumed to
56 contain just Markup-style markup (with or without leading '#' comment markers).
57 If directory names are passed to RDoc, they are scanned recursively for C and
58 Ruby source files only.
59
60 = Markup
61
62 For information on how to make lists, hyperlinks, & etc. with RDoc, see
63 RDoc::Markup.
64
65 Comment blocks can be written fairly naturally, either using '#' on successive
66 lines of the comment, or by including the comment in an =begin/=end block.  If
67 you use the latter form, the =begin line must be flagged with an RDoc tag:
68
69   =begin rdoc
70   Documentation to be processed by RDoc.
71   
72   ...
73   =end
74
75 RDoc stops processing comments if it finds a comment line containing '+#--+'.
76 This can be used to separate external from internal comments, or to stop a
77 comment being associated with a method, class, or module.  Commenting can be
78 turned back on with a line that starts '+#+++'.
79
80   ##
81   # Extract the age and calculate the date-of-birth.
82   #--
83   # FIXME: fails if the birthday falls on February 29th
84   #++
85   # The DOB is returned as a Time object.
86   
87   def get_dob(person)
88     # ...
89   end
90
91 Names of classes, source files, and any method names containing an underscore
92 or preceded by a hash character are automatically hyperlinked from comment text
93 to their description. 
94
95 Method parameter lists are extracted and displayed with the method description.
96 If a method calls +yield+, then the parameters passed to yield will also be
97 displayed:
98
99   def fred
100     ...
101     yield line, address
102
103 This will get documented as:
104
105   fred() { |line, address| ... }
106
107 You can override this using a comment containing ':yields: ...' immediately
108 after the method definition
109
110   def fred # :yields: index, position
111     # ...
112   
113     yield line, address
114
115 which will get documented as
116
117    fred() { |index, position| ... }
118
119 +:yields:+ is an example of a documentation directive.  These appear immediately
120 after the start of the document element they are modifying.
121
122 == Directives
123
124 [+:nodoc:+ / +:nodoc:+ all]
125   Don't include this element in the documentation.  For classes
126   and modules, the methods, aliases, constants, and attributes
127   directly within the affected class or module will also be
128   omitted.  By default, though, modules and classes within that
129   class of module _will_ be documented.  This is turned off by
130   adding the +all+ modifier.
131   
132     module MyModule # :nodoc:
133       class Input
134       end
135     end
136     
137     module OtherModule # :nodoc: all
138       class Output
139       end
140     end
141   
142   In the above code, only class +MyModule::Input+ will be documented.
143
144 [+:doc:+]
145   Force a method or attribute to be documented even if it wouldn't otherwise
146   be.  Useful if, for example, you want to include documentation of a
147   particular private method.
148
149 [+:notnew:+]
150   Only applicable to the +initialize+ instance method.  Normally RDoc assumes
151   that the documentation and parameters for #initialize are actually for the
152   ::new method, and so fakes out a ::new for the class.  The :notnew: modifier
153   stops this.  Remember that #initialize is protected, so you won't see the
154   documentation unless you use the -a command line option.
155
156 Comment blocks can contain other directives:
157
158 [+:section: title+]
159   Starts a new section in the output.  The title following +:section:+ is used
160   as the section heading, and the remainder of the comment containing the
161   section is used as introductory text.  Subsequent methods, aliases,
162   attributes, and classes will be documented in this section.  A :section:
163   comment block may have one or more lines before the :section: directive.
164   These will be removed, and any identical lines at the end of the block are
165   also removed.  This allows you to add visual cues such as:
166     
167     # ----------------------------------------
168     # :section: My Section
169     # This is the section that I wrote.
170     # See it glisten in the noon-day sun.
171     # ----------------------------------------
172
173 [+:call-seq:+]
174   Lines up to the next blank line in the comment are treated as the method's
175   calling sequence, overriding the default parsing of method parameters and
176   yield arguments.
177
178 [+:include:+ _filename_]
179   Include the contents of the named file at this point.  The file will be
180   searched for in the directories listed by the +--include+ option, or in the
181   current directory by default.  The contents of the file will be shifted to
182   have the same indentation as the ':' at the start of the :include: directive.
183
184 [+:title:+ _text_]
185   Sets the title for the document.  Equivalent to the --title command line
186   parameter.  (The command line parameter overrides any :title: directive in
187   the source).
188
189 [+:enddoc:+]
190   Document nothing further at the current level.
191
192 [+:main:+ _name_]
193   Equivalent to the --main command line parameter.
194
195 [+:stopdoc:+ / +:startdoc:+]
196   Stop and start adding new documentation elements to the current container.
197   For example, if a class has a number of constants that you don't want to
198   document, put a +:stopdoc:+ before the first, and a +:startdoc:+ after the
199   last.  If you don't specify a +:startdoc:+ by the end of the container,
200   disables documentation for the entire class or module.
201
202 = Other stuff
203
204 Author::   Dave Thomas <dave@pragmaticprogrammer.com>
205
206 == Credits
207
208 * The Ruby parser in rdoc/parse.rb is based heavily on the outstanding
209   work of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby
210   parser for irb and the rtags package.
211
212 * Code to diagram classes and modules was written by Sergey A Yanovitsky
213   (Jah) of Enticla. 
214
215 * Charset patch from MoonWolf.
216
217 * Rich Kilmer wrote the kilmer.rb output template.
218
219 * Dan Brickley led the design of the RDF format.
220
221 == License
222
223 RDoc is Copyright (c) 2001-2003 Dave Thomas, The Pragmatic Programmers.  It
224 is free software, and may be redistributed under the terms specified
225 in the README file of the Ruby distribution.
226
227 == Warranty
228
229 This software is provided "as is" and without any express or implied
230 warranties, including, without limitation, the implied warranties of
231 merchantibility and fitness for a particular purpose.
232