class documentation

class Documenter:

Known subclasses: sphinx.ext.autodoc.ClassLevelDocumenter, sphinx.ext.autodoc.ModuleDocumenter, sphinx.ext.autodoc.ModuleLevelDocumenter

View In Hierarchy

A Documenter knows how to autodocument a single object type. When registered with the AutoDirective, it will be used to document objects of that type when needed by autodoc.

Its objtype attribute selects what auto directive it is assigned to (the directive name is 'auto' + objtype), and what directive it generates by default, though that can be overridden by an attribute called directivetype.

A Documenter has an option_spec that works like a docutils directive's; in fact, it will be used to parse an auto directive's options that matches the Documenter.

Class Method can​_document​_member Called to see if a member can be documented by this Documenter.
Method __init__ Undocumented
Method ​_call​_format​_args Undocumented
Method add​_content Add content from docstrings, attribute documentation and user.
Method add​_directive​_header Add the directive header and options to the generated content.
Method add​_line Append one line of generated reST to the output.
Method check​_module Check if self.object is really defined in the module given by self.modname.
Method document​_members Generate reST for member documentation.
Method filter​_members Filter the given member list.
Method format​_args Format the argument signature of self.object.
Method format​_name Format the name of self.object.
Method format​_signature Format the signature (arguments and return annotation) of the object.
Method generate Generate reST for the object given by self.name, and possibly for its members.
Method get​_attr getattr() override for types such as Zope interfaces.
Method get​_doc Decode and return lines of the docstring(s) for the object.
Method get​_object​_members Return (members_check_module, members) where members is a list of (membername, member) pairs of the members of self.object.
Method get​_real​_modname Get the real module name of an object to document.
Method get​_sourcename Undocumented
Method import​_object Import the object given by self.modname and self.objpath and set it as self.object.
Method parse​_name Determine what module to import and what attribute to document.
Method process​_doc Let the user process the docstrings before adding them.
Method resolve​_name Resolve the module and name of the object to document given by the arguments and the current module/class.
Method sort​_members Sort the given member list.
Class Variable content​_indent Undocumented
Class Variable member​_order Undocumented
Class Variable objtype Undocumented
Class Variable option​_spec Undocumented
Class Variable priority Undocumented
Class Variable titles​_allowed Undocumented
Instance Variable analyzer Undocumented
Instance Variable args Undocumented
Instance Variable config Undocumented
Instance Variable directive Undocumented
Instance Variable env Undocumented
Instance Variable fullname Undocumented
Instance Variable indent Undocumented
Instance Variable modname Undocumented
Instance Variable module Undocumented
Instance Variable name Undocumented
Instance Variable object Undocumented
Instance Variable object​_name Undocumented
Instance Variable objpath Undocumented
Instance Variable options Undocumented
Instance Variable parent Undocumented
Instance Variable real​_modname Undocumented
Instance Variable retann Undocumented
Property documenters Returns registered Documenter classes
@classmethod
def can_document_member(cls, member, membername, isattr, parent):
Called to see if a member can be documented by this Documenter.
Parameters
member:AnyUndocumented
membername:strUndocumented
isattr:boolUndocumented
parent:AnyUndocumented
Returns
boolUndocumented
def _call_format_args(self, **kwargs):

Undocumented

Parameters
**kwargs:AnyUndocumented
Returns
strUndocumented
def add_content(self, more_content, no_docstring=False):
Add content from docstrings, attribute documentation and user.
Parameters
more​_content:Optional[StringList]Undocumented
no​_docstring:boolUndocumented
def add_line(self, line, source, *lineno):
Append one line of generated reST to the output.
Parameters
line:strUndocumented
source:strUndocumented
*lineno:intUndocumented
def check_module(self):
Check if self.object is really defined in the module given by self.modname.
Returns
boolUndocumented
def document_members(self, all_members=False):

Generate reST for member documentation.

If all_members is True, document all members, else those given by self.options.members.

Parameters
all​_members:boolUndocumented
def filter_members(self, members, want_all):

Filter the given member list.

Members are skipped if

  • they are private (except if given explicitly or the private-members option is set)
  • they are special methods (except if given explicitly or the special-members option is set)
  • they are undocumented (except if the undoc-members option is set)

The user can override the skipping decision by connecting to the autodoc-skip-member event.

Parameters
members:ObjectMembersUndocumented
want​_all:boolUndocumented
Returns
List[Tuple[str, Any, bool]]Undocumented
def format_args(self, **kwargs):

Format the argument signature of self.object.

Should return None if the object does not have a signature.

Parameters
**kwargs:AnyUndocumented
Returns
strUndocumented
def format_name(self):

Format the name of self.object.

This normally should be something that can be parsed by the generated directive, but doesn't need to be (Sphinx will display it unparsed then).

Returns
strUndocumented
def format_signature(self, **kwargs):

Format the signature (arguments and return annotation) of the object.

Let the user process it via the autodoc-process-signature event.

Parameters
**kwargs:AnyUndocumented
Returns
strUndocumented
def generate(self, more_content=None, real_modname=None, check_module=False, all_members=False):

Generate reST for the object given by self.name, and possibly for its members.

If more_content is given, include that content. If real_modname is given, use that module name to find attribute docs. If check_module is True, only generate if the object is defined in the module name it is imported from. If all_members is True, document all members.

Parameters
more​_content:Optional[StringList]Undocumented
real​_modname:strUndocumented
check​_module:boolUndocumented
all​_members:boolUndocumented
def get_attr(self, obj, name, *defargs):
getattr() override for types such as Zope interfaces.
Parameters
obj:AnyUndocumented
name:strUndocumented
*defargs:AnyUndocumented
Returns
AnyUndocumented
def get_doc(self, ignore=None):

Decode and return lines of the docstring(s) for the object.

When it returns None, autodoc-process-docstring will not be called for this object.

Parameters
ignore:intUndocumented
Returns
Optional[List[List[str]]]Undocumented
def get_object_members(self, want_all):

Return (members_check_module, members) where members is a list of (membername, member) pairs of the members of self.object.

If want_all is True, return all members. Else, only return those members given by self.options.members (which may also be None).

Parameters
want​_all:boolUndocumented
Returns
Tuple[bool, ObjectMembers]Undocumented
def get_real_modname(self):

Get the real module name of an object to document.

It can differ from the name of the module through which the object was imported.

Returns
strUndocumented
def get_sourcename(self):

Undocumented

Returns
strUndocumented
def import_object(self, raiseerror=False):

Import the object given by self.modname and self.objpath and set it as self.object.

Returns True if successful, False if an error occurred.

Parameters
raiseerror:boolUndocumented
Returns
boolUndocumented
def parse_name(self):

Determine what module to import and what attribute to document.

Returns True and sets self.modname, self.objpath, self.fullname, self.args and self.retann if parsing and resolving was successful.

Returns
boolUndocumented
def process_doc(self, docstrings):
Let the user process the docstrings before adding them.
Parameters
docstrings:List[List[str]]Undocumented
Returns
Iterator[str]Undocumented
def resolve_name(self, modname, parents, path, base):

Resolve the module and name of the object to document given by the arguments and the current module/class.

Must return a pair of the module name and a chain of attributes; for example, it would return ('zipfile', ['ZipFile', 'open']) for the zipfile.ZipFile.open method.

Parameters
modname:strUndocumented
parents:AnyUndocumented
path:strUndocumented
base:AnyUndocumented
Returns
Tuple[str, List[str]]Undocumented
def sort_members(self, documenters, order):
Sort the given member list.
Parameters
documenters:List[Tuple[Documenter, bool]]Undocumented
order:strUndocumented
Returns
List[Tuple[Documenter, bool]]Undocumented
content_indent: str =

Undocumented

titles_allowed: bool =

Undocumented

args =

Undocumented

config: Config =

Undocumented

directive =

Undocumented

Undocumented

fullname =

Undocumented

indent =

Undocumented

modname =

Undocumented

module =

Undocumented

name =

Undocumented

object_name =

Undocumented

objpath =

Undocumented

options =

Undocumented

parent =

Undocumented

real_modname: str =

Undocumented

retann =

Undocumented

@property
documenters: Dict[str, Type[Documenter]] =
Returns registered Documenter classes