Index of /localdocs/ruby/rdoc

  Name                    Last modified       Size  Description

[DIR] Parent Directory        15-Sep-2003 11:35      -  
[TXT] ChangeLog               15-Sep-2003 11:35    20k  
[TXT] NEW_FEATURES            15-Sep-2003 11:35     6k  
[TXT] ToDo                    15-Sep-2003 11:35     1k  

= RDOC - Ruby Documentation System

This package contains Rdoc and SimpleMarkup. Rdoc is an application
that produces documentation for one or more Ruby source files. We work
similarly to JavaDoc, parsing the source, and extracting the
definition for classes, modules, and methods (along with includes and
requires).  We associate with these optional documentation contained
in the immediately preceding comment block, and then render the result
using a pluggable output formatter. (Currently, HTML is the only
supported format. Markup is a library that converts plain text into
various output formats. The Markup library is used to interpret the
comment blocks that Rdoc uses to document methods, classes, and so on.


== Installation

This distribution contains two packages, rdoc itself and a text markup
library, 'markup'. You can install them both using the single command

  % ruby install.rb

in this directory. If you just want to install 'markup', change to the
markup directory and run the install.rb script there.


== Roadmap

* If you want to use Rdoc to create documentation for your Ruby source
  files, read on.
* If you want to include extensions written in C, see rdoc/c_parse.rb.
* For information on the various markups available in comment
  blocks, see markup/simple_markup.rb.
* If you want to drive Rdoc programatically, see RDoc::RDoc.
* If you want to use the library to format text blocks into HTML,
  have a look at SM::SimpleMarkup.
* If you want to try writing your own HTML output template, see
  RDoc::Page.

== Summary

Once installed, you can create documentation using the 'rdoc' command
(the command is 'rdoc.rb' under Windows)

  % rdoc [options]  [names...]

Type "rdoc --help" for an up-to-date option summary.

A typical use might be to generate documentation for a package of Ruby
source (such as rdoc itself). 

  % rdoc

This command generates documentation for all the Ruby and C source
files in and below the current directory. These will be stored in a
documentation tree starting in the subdirectory 'doc'.

You can make this slightly more useful for your readers by having the
index page contain the documentation for the primary file. In our
case, we could type

  % rdoc --main rdoc/rdoc.rb

You'll find information on the various formatting tricks you can use
in comment blocks in the documentation this generates.

RDoc uses file extensions to determine how to process each file. File
names ending <tt>.rb</tt> and <tt>.rbw</tt> are assumed to be Ruby
source. Files ending <tt>.c</tt> are parsed as C files. All other
files are assumed to contain just SimpleMarkup-style markup (with or
without leading '#' comment markers). If directory names are passed to
RDoc, they are scanned recursively for C and Ruby source files only.

== Credits

* The Ruby parser in rdoc/parse.rb is based heavily on the outstanding
  work of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby
  parser for irb and the rtags package.

* Code to diagram classes and modules was written by Sergey A Yanovitsky
  (Jah) of Enticla. 

* Charset patch from MoonWolf.

* Rich Kilmer wrote the kilmer.rb output template.

* Dan Brickley designed led the RDF format.

== License

RDoc is Copyright (c) 2002 Dave Thomas, The Pragmatic Programmers.  It
is free software, and may be redistributed under the terms specified
in the README file of the Ruby distribution.


== Support

The Rdoc homepage is http://rdoc.sourceforge.net. There you'll find
links for downloading the Rdoc package, and instructions on how to get
the still-quivering sources from CVS. I'm also using Sourceforge to
track bugs and manage feature requests. If you submit patches, it
would help if they were inline (not attachments) and generated using
"diff -u".  I don't have access to a wide variety of browsers, so
reports that output looks funny under Browser XYZ aren't too helpful:
far better are suggested changes to the generated HTML that fix the
problem.

For other information, feel free to ask on the ruby-talk mailing list
(which is mirrored to comp.lang.ruby) or contact
mailto:dave@pragmaticprogrammer.com.

----

= Usage

RDoc is invoked from the command line using:

   % rdoc <options> [name...]

Files are parsed, and the information they contain collected, before
any output is produced. This allows cross references between all files
to be resolved. If a name is a directory, it is traversed. If no
names are specified, all Ruby files in the current directory (and
subdirectories) are processed.

Options are:

[<tt>--all</tt>]
    include protected and private methods in the output (by default
    only public methods are included)

[<tt>--main</tt> _name_]
    set the class, module, or file to appear on the index page

[<tt>--exclude</tt> <i>pattern</i>]
    exclude files and directories matching this pattern from processing

[<tt>--quiet</tt>]
    do not display progress messages

[<tt>--one_file</tt>]
    place all the output into a single file

[<tt>--op</tt> _dir_]
    set the output directory to _dir_ (the default is the directory
    "doc")

[<tt>--opname</tt> _name_]
    set the output name (has no effect for HTML).

[<tt>--charset</tt> _charset_]
    Set the character set for the generated HTML.

[<tt>--fmt</tt> _fmt_]
    generate output in a particular format.

[<tt>--include</tt> <i>dir,...</i>]
    specify one or more directories to be searched when satifying
    :include: directives. Multiple <tt>--include</tt> options may be
    given. The directory containing the file currently being processed
    is always searched.

[<tt>--inline_source</tt>]
    By default, the source code of methods is shown in a popup. With
    this option, it's displayed inline.

[<tt>--show_hash</tt>]
    A name of the form #name in a comment is a possible hyperlink to
    an instance method name. When displayed, the '#' is removed unless
    this option is specified

[<tt>--template</tt> <i>name</i>]
    specify an alternate template to use when generating output (the
    default is 'standard'). This template should be in a directory
    accessible via $: as rdoc/generators/xxxx_template, where 'xxxx'
    depends on the output formatter.

[<tt>--diagram</tt>]
    include diagrams showing modules and classes.  This is currently
    an experimental feature, and may not be supported by all output
    templates.

= Example

A typical small Ruby program commented using RDoc might be as follows. You
can see the formatted result in EXAMPLE.rb and Anagram.

      :include: EXAMPLE.rb

= Markup

Comment blocks can be written fairly naturally. 

Paragraphs are lines that share the left margin. Text indented past
this margin are formatted verbatim.

1. Lists are typed as indented paragraphs with:
   * a '*' or '-' (for bullet lists)
   * a digit followed by a period for 
     numbered lists

   For example, the input that produced the above paragraph looked like
       1. Lists are typed as indented 
          paragraphs with:
          * a '*' or '-' (for bullet lists)
          * a digit followed by a period for 
            numbered lists

2. Labeled lists (sometimes called description
   lists are typed using square brackets for the label.
      [cat]   small domestic animal
      [+cat+] command to copy standard input

3. Labeled lists may also be produced by putting a double colon
   after the label. This sets the result in tabular form, so the
   descriptions all line up. This was used to create the 'author'
   block at the bottom of this description.
      cat::   small domestic animal
      +cat+:: command to copy standard input

   For both kinds of labeled lists, if the body text starts on the same
   line as the label, then the start of that text determines the block
   indent for the rest of the body. The text may also start on the line
   following the label, indented from the start of the label. This is
   often preferable if the label is long. Both the following are
   valid labeled list entries:

      <tt>--output</tt> <i>name [, name]</i>::
          specify the name of one or more output files. If multiple
          files are present, the first is used as the index.

      <tt>--quiet:</tt>:: do not output the names, sizes, byte counts,
                          index areas, or bit ratios of units as
                          they are processed.

4. Headings are entered using equals signs

      = Level One Heading
      == Level Two Heading
   and so on

5. Rules (horizontal lines) are entered using three or
   more hyphens.

6. Non-verbatim text can be marked up:

   _italic_::     \_word_ or \<em>text</em>
   *bold*::       \*word* or \<b>text</b>
   +typewriter+:: \+word+ or \<tt>text</tt>

   Putting a backslash before inline markup stops it
   being interpreted, which is how I created the table above:

     _italic_::     \_word_ or \<em>text</em>
     *bold*::       \*word* or \<b>text</b>
     +typewriter+:: \+word+ or \<tt>text</tt>

7. Names of classes, source files, and any method names
   containing an underscore or preceded by a hash
   character are automatically hyperlinked from
   comment text to their description. 

8. Hyperlinks to the web starting http:, mailto:, ftp:, or www. are
   recognized. An HTTP url that references an external image file is
   converted into an inline <IMG..>.  Hyperlinks starting 'link:' are
   assumed to refer to local files whose path is relative to the --op
   directory.
       
9. Method parameter lists are extracted and displayed with
   the method description. If a method calls +yield+, then
   the parameters passed to yield will also be displayed:

      def fred
        ...
        yield line, address

   This will get documented as

      fred() { |line, address| ... }

   You can override this using a comment containing 
   ':yields: ...' immediately after the method definition

      def fred      # :yields: index, position
        ...
        yield line, address

   which will get documented as

       fred() { |index, position| ... }


10. ':yields:' is an example of a documentation modifier. These appear
    immediately after the start of the document element they are modifying.
    Other modifiers include

    [<tt>:nodoc:</tt><i>[all]</i>]
         don't include this element in the documentation.  For classes
         and modules, methods, aliases, and attributes directly within
         the affect class will also be omitted.  By default, though,
         modules and classes within that class of module _will_ be
         documented. This is turned off by adding the +all+ modifier.

              module SM  #:nodoc:
                class Input
                end
              end
              module Markup #:nodoc: all
                class Output
                end
              end

         In the above code, only class <tt>SM::Input</tt> will be
         documented.

    [<tt>:notnew:</tt>]
         only applicable to the +initialize+ instance method. Normally
         RDoc assumes that the documentation and parameters for
         #initialize are actually for the ::new method, and so fakes
         out a ::new for the class. THe :notnew: modifier stops
         this. Remember that #initialize is protected, so you won't
         see the documentation unless you use the -a command line
         option.


11. RDoc stops processing comments if it finds a comment
    line containing '<tt>#--</tt>'. This can be used to 
    separate external from internal comments, or 
    to stop a comment being associated with a method, 
    class, or module. Commenting can be turned back on with
    a line that starts '<tt>#++</tt>'.

        # Extract the age and calculate the
        # date-of-birth.
        #--
        # FIXME: fails if the birthday falls on
        # February 29th
        #++
        # The DOB is returned as a Time object.

        def get_dob(person)
           ...

12. Comment blocks can contain other directives:

    [<tt>:include:</tt><i>filename</i>] 
         include the contents of the named file at this point. The
         file will be searched for in the directories listed by
         the <tt>--include</tt> option, or in the current
         directory by default.  The contents of the file will be
         shifted to have the same indentation as the ':' at the
         start of the :include: directive.

---

See also markup/simple_markup.rb.

= Other stuff

Author::   Dave Thomas <dave@pragmaticprogrammer.com>
Requires:: Ruby 1.6.5 or later
License::  Copyright (c) 2001 Dave Thomas.
           Released under the same license as Ruby.

== Warranty

This software is provided "as is" and without any express or
implied warranties, including, without limitation, the implied
warranties of merchantibility and fitness for a particular
purpose.