Epydoc Fields

Fields are used to describe specific properties of a documented object. For example, fields can be used to define the parameters and return value of a function; the instance variables of a class; and the author of a module. Each field consists of a tag, an optional argument, and a body.

1. Field Markup

Each docstring markup langauge marks fields differently. The following table shows the basic fields syntax for each markup language. For more information, see the definition of field syntax for each markup language.

Epytext ReStructuredText Javadoc
@tag: body...
@tag arg: body...
:tag: body...
:tag arg: body...
@tag body...
@tag arg body...
Definition of
epytext fields
Definition of
ReStructuredText fields
Definition of
Javadoc fields

2. Supported Fields

The following table lists the fields that epydoc currently recognizes. Field tags are written using epytext markup; if you are using a different markup language, then you should adjust the markup accordingly.

Functions and Methods (function or method docstrings)
@param p: ... A description of the parameter p for a function or method.
@type p: ... The expected type for the parameter p.
@return: ... The return value for a function or method.
@rtype: ... The type of the return value for a function or method.
@keyword p: ... A description of the keyword parameter p.
@raise e: ... A description of the circumstances under which a function or method raises exception e.
Variables (module or class docstrings)
@ivar v: ... A description of the class instance variable v.
@cvar v: ... A description of the static class variable v.
@var v: ... A description of the module variable v.
@type v: ... The type of the variable v.
Properties (property docstrings)
@type: ... The type of the property.
Grouping and Sorting (module, class, function, or method docstrings)
@group gc1,...,cn Organizes a set of related children of a module or class into a group. g is the name of the group; and c1,...,cn are the names of the children in the group. To define multiple groups, use multiple group fields.
@sortc1,...,cn Specifies the sort order for the children of a module or class. c1,...,cn are the names of the children, in the order in which they should appear. Any children that are not included in this list will appear after the children from this list, in alphabetical order.
Related Topics
@see: ... A description of a related topic. see fields typically use documentation crossreference links or external hyperlinks that link to the related topic.
Notes and Warnings
@note: ... A note about an object. Multiple note fields may be used to list separate notes.
@attention: ... An important note about an object. Multiple attention fields may be used to list separate notes.
@bug: ... A description of a bug in an object. Multiple bug fields may be used to report separate bugs.
@warning: ... A warning about an object. Multiple warning fields may be used to report separate warnings.
Status
@version: ... The current version of an object.
@todo [ver]: ... A planned change to an object. If the optional argument ver is given, then it specifies the version for which the change will be made. Multiple todo fields may be used if multiple changes are planned.
@depreciated: ... Indicates that an object is depreciated. The body of the field describe the reason why the object is depreciated.
@since: ... The date or version when an object was first introduced.
@status: ... The current status of an object.
Formal Conditions
@requires: ... A requirement for using an object. Multiple requires fields may be used if an object has multiple requirements.
@precondition: ... A condition that must be true before an object is used. Multiple precondition fields may be used if an object has multiple preconditions.
@postcondition: ... A condition that is guaranteed to be true after an object is used. Multiple postcondition fields may be used if an object has multiple postconditions.
@invariant: ... A condition which should always be true for an object. Multiple invariant fields may be used if an object has multiple invariants.
Bibliographic Information
@author: ... The author(s) of an object. Multiple author fields may be used if an object has multiple authors.
@organiation: ... The organization that created or maintains an object.
@copyright: ... The copyright information for an object.
@license: ... The licensing information for an object.
@contact: ... Contact information for the author or maintainer of a module, class, function, or method. Multiple contact fields may be used if an object has multiple contacts.
Summarization
@summary: ... A summary description for an object. This description overrides the default summary (which is constructed from the first sentence of the object's description).

2.1. Notes on Supported Fields

3. Field Synonyms

Several fields have "synonyms," or alternate tags. The following table lists all field synonyms. Field tags are written using epytext markup; if you are using a different markup language, then you should adjust the markup accordingly.

NameSynonyms
@param p: ... @parameter p: ...
@arg p: ...
@argument p: ...
@return: ... @returns: ...
@rtype: ... @returntype: ...
@raise e: ... @raises e: ...
@except e: ...
@exception e: ...
@keyword p: ... @kwarg p: ...
@kwparam p: ...
@ivar v: ... @ivariable v: ...
@cvar v: ... @cvariable v: ...
NameSynonyms
@var v: ... @variable v: ...
@see: ... @seealso: ...
@warning: ... @warn: ...
@requires: ... @require: ...
@requirement: ...
@precondition: ... @precond: ...
@postcondition: ... @postcod: ...
@organization: ... @org: ...
@copyright: ... @(c): ...

4. Adding New Fields

New fields can be defined for the docstrings in a module with the special module-level variable "__extra_epydoc_fields__". This variable should contain a list of field specifications, where each field specification is one of the following:

The following example illustrates how the special variable "__extra_epydoc_fields__" can be used:

Docstring InputRendered Output
__extra_epydoc_fields__ = [
    ('corpus', 'Corpus', 'Corpora')]

def example():
    """
    @corpus: Bob's wordlist.
    @corpus: The British National Corpus.
    """
    [...]

Corpora:

  • Bob's wordlist.
  • The British National Corpus.

New fields can also be defined for an individual docstring, using the special @newfield field. In particular, "@newfield tag: label [, plural]" will define a new field, whose tag is tag; and which is labeled in output documentation as label. The optional argument plural specifies the label that should be used if the field has multiple entries.

5. Markup-Specific Notes

For the most part, fields are treated identically, regardless of what markup language is used to encode them. However, there are a few minor differences, which are intended to accomodate existing standards for each markup language. In particular:

For more information about these differences, read the subsections below.

5.1. ReStructuredText Fields

In ReStructuredText, a single field can be used to encode the documentation for a group of related items. For example, a single :Parameters: field is often used to describe all of the parameters for a function or method:

def fox_speed(size, weight, age):
    """
    Return the maximum speed for a fox.

    :Parameters:
      - `size`: The size of the fox (in meters)
      - `weight`: The weight of the fox (in stones)
      - `age`: The age of the fox (in years)
    """
    [...]

These types of combined fields are called consolidated fields, and epydoc automatically divides them into their constituant basic fields. The following consolidated fields are currently supported by epydoc:

Consolidated
Field Tag
Corresponding
Base Field Tag
:Parameters: :param:
:Exceptions: :except:
:Groups: :group:
:Keywords: :keyword:
Consolidated
Field Tag
Corresponding
Base Field Tag
:Variables: :var:
:Ivariables: :ivar:
:Cvariables: :cvar:
:Types: :type:

Consolidated fields are required to contain a single list, where each list item begins with a paragraph that begins with an interpreted text string (`...`).

5.2. Javadoc Fields

For compatibility with Javadoc, every @see field is assumed to contain a single crossreference link, unless its body is quoted, or it start with an HTML tag. See the Javadoc reference manual for more information about how the @see field is encoded in Javadoc.

Because Javadoc does not mark end of the optional argument, field arguments must contain exactly one word. Thus, multi-word arguments are not available in Javadoc. In particular, all group names must be single words.

Last modified: Sun Feb 29 00:45:51 EST 2004