1 = RDOC - Ruby Documentation System
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.
15 * If you want to use RDoc to create documentation for your Ruby source files,
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
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
23 * If you want to try writing your own HTML output template, see
28 Once installed, you can create documentation using the 'rdoc' command
29 (the command is 'rdoc.bat' under Windows)
31 % rdoc [options] [names...]
33 Type "rdoc --help" for an up-to-date option summary.
35 A typical use might be to generate documentation for a package of Ruby
36 source (such as rdoc itself).
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'.
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
50 You'll find information on the various formatting tricks you can use
51 in comment blocks in the documentation this generates.
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.
62 For information on how to make lists, hyperlinks, & etc. with RDoc, see
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:
70 Documentation to be processed by RDoc.
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 '+#+++'.
81 # Extract the age and calculate the date-of-birth.
83 # FIXME: fails if the birthday falls on February 29th
85 # The DOB is returned as a Time object.
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
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
103 This will get documented as:
105 fred() { |line, address| ... }
107 You can override this using a comment containing ':yields: ...' immediately
108 after the method definition
110 def fred # :yields: index, position
115 which will get documented as
117 fred() { |index, position| ... }
119 +:yields:+ is an example of a documentation directive. These appear immediately
120 after the start of the document element they are modifying.
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.
132 module MyModule # :nodoc:
137 module OtherModule # :nodoc: all
142 In the above code, only class +MyModule::Input+ will be documented.
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.
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.
156 Comment blocks can contain other directives:
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:
167 # ----------------------------------------
168 # :section: My Section
169 # This is the section that I wrote.
170 # See it glisten in the noon-day sun.
171 # ----------------------------------------
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
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.
185 Sets the title for the document. Equivalent to the --title command line
186 parameter. (The command line parameter overrides any :title: directive in
190 Document nothing further at the current level.
193 Equivalent to the --main command line parameter.
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.
204 Author:: Dave Thomas <dave@pragmaticprogrammer.com>
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.
212 * Code to diagram classes and modules was written by Sergey A Yanovitsky
215 * Charset patch from MoonWolf.
217 * Rich Kilmer wrote the kilmer.rb output template.
219 * Dan Brickley led the design of the RDF format.
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.
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.