NAME

ObjcDoc - Objective-C documentation tool


SYNOPSIS

objcdoc
[-itvhV] [-d dir] [-x class] [-f type] [--compat] [--dir dir] [--exclude class] [--format type] [--frames] [--include-src] [--index] [--noclasses] [--nosrc] [--resolve file] [--tree] [--verbose] [--help] [--version] [file] ...


DESCRIPTION

ObjcDoc is a tool designed to aid programmers in documenting Objective-C class libraries. It can parse Objective-C source code (both include and implementation files) and will create HTML output files containing class documentation extracted from special comments inside the source code.

Additionally, ObjcDoc can also create a class and protocol index and a view of the complete class inheritance hierarchy with links to the individual documentation files.

Each non-option argument on the command line may either be an Objective-C include (`*.h') or implementation file (`*.m') or the name of a directory, which is then searched for source code files (recursively). All files collected in this way are scanned for public class and protocol declarations.

For every class found, ObjcDoc will create two output files containing hypertext documentation for this class, its instance variables and its class and instance methods. Also included are links to all direct subclasses and implemented protocols. If a methods is re-implemented in a subclass, a link to the implementation in the base class is provided (if documentation for this exists). Methods from categories are incorporated into the documentation for the class they augment, grouped by category name.

Options

ObjcDoc currently supports the following options:

--compat
Enable ObjcDoc 2.x compatibility mode (not recommended). This in not really a full compatibility mode, since only some of the undocumented features of older ObjcDoc versions are recognized.

-d directory, --dir directory
Set the destination directory for the generated documentation files. The directory will be created if it does not already exist. If it does exist, it is not cleared of files however.

-x class, --exclude class
Skip the given class or protocol when creating the documentation files. You can list any number of class names here (using separate -x or --exclude options) that should not be documented. Equivalent to using `@nodoc' in the class comment (see Magic Section Keywords).

-f type, --format type
Select the documentation format (in future versions). The only output format currently available is `html', which is the default.

--frames
Create a separate HTML frameset file (if the output format is `html'), which can be used to emulate a simple class browser. Some authors consider the use of frames bad style, so this feature is turned off by default. This option also implies --tree, since the inheritance hierarchy is displayed in the initial frameset.

--include-src
Include the complete source code for each method body into the generated documentation files. This option is rarely useful and may produce large output files. It cannot be used together with the --nosrc option, of course.

-i, --index
Create an alphabetical index of all classes and protocols for which documentation has been generated. The output file name is `index.html'.

--noclasses
Do not create the individual documentation files for each class. In this mode, ObjcDoc only creates output for the --index and --tree options, if these have been specified.

--nosrc
Do not read and parse any implementation files, use the include files only.

--resolve file
Try to resolve references to unknown (external) classes and protocols by scanning the given file or directory (recursively) for class declarations. No documentation will be generated for these classes, but they will be included in the class hierarchy and method lists, if appropriate. Multiple --resolve options are allowed.

-t, --tree
Create an overview of the library's class inheritance hierarchy, including links to the individual documentation files of all classes for which output has been generated. The output file name is `classtree.html'.

-v, --verbose
Enable verbose (debug) mode. Prints a lot of debug output while the program is running. Giving this option multiple times increases the amount of debug output.

-h, --help
Print a short help text to the standard output and exit immediately. The help text contains a short description of all available options.

-V, --version
Print the version number of ObjcDoc and copyright information to the standard output and exit immediately.


INPUT FILE FORMAT

ObjcDoc can parse two different kinds of input files: Objective-C header (i.e. include) files and Objective-C implementation files. It does not impose any restrictions on the contents of these files, but it will only recognize and extract documentation from comments in these files if they appear ``in the right places''. All comment text is assumed to be ISO 8859-1 (``Latin-1'') encoded (this matters only if non-ASCII characters appear inside), which is also the default encoding of HTML documents. Character entities may be used to represent other Unicode characters.

Comments for documented classes, categories or protocols must be placed as a single comment block immediately before (or on the same line after) the corresponding `@interface', `@implementation' or `@protocol' line. Empty lines between comment block and declaration are always ignored.

A short description for individual instance variables and class or instance methods should precede each variable or method declaration, respectively, as a single comment block. Alternatively, a single-line comment may be appended to the declaration on the same line (see the examples below).

Methods may be grouped together into ``categories'' (just sets of methods, not Objective-C categories) by grouping them in the interface or protocol declaration and preceding them with a separate comment block for this group. A group lasts until the next group begins or there are no more methods in this interface.

Longer documentation texts for each method should be included in the implementation files for the corresponding classes. These can be used to describe how the method can be used, its parameters, return value, exceptions etc. Again, this must be placed as a single comment block per method immediately before the method implementation. If a method overrides an implementation in another class, but does not provide a comment block of its own, the corresponding comment from the base class is used.

Comment Styles

ObjcDoc (unlike Javadoc) does not require the use of a special comment type and will accept a wide range of different comment styles. For example, all of the following are exactly equivalent:

    /*
     * Validate internal state.
     */
    - (BOOL) isValid;
    /*
       Validate internal state.
    */
    - (BOOL) isValid;
    //
    // Validate internal state.
    //
    - (BOOL) isValid;
    - (BOOL) isValid;   /* Validate internal state. */
    - (BOOL) isValid;   // Validate internal state.

Each of the above would be treated as a single comment block. A comment appended to a code fragment on the same line is internally treated just as if it appeared immediately before the code fragment on its own line.

A comment block is defined as:

However, if you place a comment after a declaration on the same line, as shown in the last two examples above, there is no way to extend this comment block across multiple lines. (well, almost: You can use the line continuation feature of ANSI-C to join multiple source code lines into a single logical line.)

Link Keywords

All types of comments mentioned above may contain any number of the keywords listed here to add (inline) hypertext links. If the output format does not support links, text is inserted instead.

@self
@super
@class
Create a reference to the current class, its super class or the given class, respectively (if documentation for this class exists). If a class name is given (third form), it must start with an uppercase letter.

@class(class)
Create a reference to the given class, preceded by the word `class' in the output (if documentation for this class exists). class must be a valid identifier.

@proto(protocol)
Create a reference to the given protocol, preceded by the word `protocol' in the output (if documentation for this protocol exists). protocol must be a valid identifier.

@self#selector or @selector
@super#selector
@class#selector
Create a reference to the given selector in the current class, its super class or the class specified by class, respectively (if documentation for this method exists). If a class name is given (third form), it must start with an uppercase letter. selector must be preceded by either `+' or `-' (though this is optional after `#') to distinguish between class and instance methods.

@method(selector)
@method(class, selector)
Create a reference to the given selector in the current class or the class specified by class, respectively (if documentation for this method exists). class must be a valid identifier. selector must be preceded by `+' if it refers to a class method (and can optionally be preceded by `-' if it refers to an instance method).

@link(URI)
@link(URI, text)
Create a hypertext link to the given URI (e.g a URL). The text of the link is either the URI itself or the specified text.

Section Keywords

The following keywords can be used to add pre-defined sections to the generated documentation (typically a method documentation). Section keywords should only appear at the start of a comment line, and consume all text until the end of the current (logical) line.

If the text for a section keywords needs to span multiple input lines, you have to add line continuation characters to all but the last line (see the example for `\newline' under Special Characters).

@param parameter ...
Describe a method parameter. The text following the parameter name until the end of the current line is used as the description text. Multiple `@param' keywords are allowed (one per parameter).

@return ...
Describe the return value of this method. The following text until the end of the current line is used as the description text. This keyword may occur at most once.

@raises exception ...
@throws exception ...
Describe an exception that this method may raise. The text following the exception name until the end of the current line is used as the description text. Multiple `@raises' or `@throws' keywords are allowed.

@see ...
Add the following text until the end of the current line as a `See also:' section to this documentation entry. Multiple `@see' keywords are allowed.

Magic Section Keywords

These technically also count as section keywords, but are interpreted in a different way:

@nodoc
Omit the documented feature from the generated output. May be used in comments for a class (removes the whole class), an instance variable (skips just this variable declaration) or method (completely omits the method).

@example ...
Add all the following text right until the end of the comment block as a multi-line `Example:' section to this description. All special characters (including < and >) must be left unescaped, since this is handled automatically.

Special Characters

All comments mentioned above may contain text marked by the characters listed below to change the visible appearance or interpretation of the text:

word!!
Render this word in bold print, if possible. A word can contain letters, digits, underscores, colons and hyphens (minus sign).

/text/
Render some text (a list of words as defined above, separated by whitespace) in italics, if possible.

|text|
Render this text (any character except `|', which can be escaped) in a fixed width font, if possible.

\newline
A backslash followed by a newline character is removed, effectively concatenating this and the next input line (as defined by ANSI-C). This can be used to extend a single ``logical comment line'' across several lines in the input file, like this:
   * [...]
   * @param foobar    This is a very long \
   *                  parameter description.
   * [...]

\char
Escape the next character (char), if it is non-alphanumeric. It preserves the literal value of the character that follows the backslash and suppresses any special interpretation that would otherwise occur.

HTML Tags

If all of this is not enough, HTML tags may be embedded directly into the comment text to add images, lists or other effects. Note that for this reason, the characters &, < and > always need to be escaped unless you want to write HTML tags or character entities.


EXAMPLE

 /*
  * Send the current selector to the target. The action
  * will pass the /sender/ object, /count/ arguments from
  * the argument array starting at /args/ and the user data
  * (if it has been set) to the method. The return value
  * will be stored in args[count], which must contain the
  * correct type information for the return value.
  * <p>
  * If the selector's return type is |void| and /count/ is
  * |0|, args may be |NULL|.
  * <p>
  * Note:!! The current implementation will only pass up to
  * 6 arguments from the /args/ array. If it contains more
  * values, the argument list will be truncated.
  *
  * @see @GTK#-connectSignal:withAction: in @class(GTK)
  */
 - (void) performWithSender:(id) sender args:(GtkArg *) args
          count:(unsigned) count
 {
     [...]
 }


FILES

/usr/share/ObjcDoc
contains some supporting files for ObjcDoc


BUGS

Output format selection (-f) is only partly implemented.

Empty lines within comments should be recognized as paragraph breaks (insert `<p>'), unless they are part of example code.

It may be useful to select an input file encoding other than ISO 8859-1, but translating different character sets is a non-trivial task.


HISTORY

As you might have guessed, this program was inspired by the Javadoc tool included in the Java Development Kit, which can be used to create documentation for Java classes. ObjcDoc tries to provide equivalent functionality to Objective-C developers.

The current version (3.0) is the result of a complete rewrite and - though functionally equivalent and mostly compatible - internally bears almost no resemblance to ObjcDoc 2.x.


SEE ALSO

javadoc(1), ocdoc(1)


AUTHORS

Holger Ludwig, Elmar Ludwig < elmar@informatik.uni-osnabrueck.de >