class documentation

class ObjectDescription(SphinxDirective, Generic[T]):

Known subclasses: sphinx.domains.c.CAliasObject, sphinx.domains.cpp.CPPAliasObject

View In Hierarchy

Directive to describe a class, function or similar object. Not used directly, but subclassed (in domain-specific directives) to add custom behavior.
Method add​_target​_and​_index Add cross-reference IDs and entries to self.indexnode, if applicable.
Method after​_content Called after parsing content. Used to reset information about the current directive context on the build environment.
Method before​_content Called before parsing content. Used to set information about the current directive context on the build environment.
Method get​_signatures Retrieve the signatures to document from the directive arguments. By default, signatures are given as arguments, one per line.
Method handle​_signature Parse the signature sig into individual nodes and append them to signode. If ValueError is raised, parsing is aborted and the whole sig is put into a single desc_name node.
Method run Main directive entry function, called by docutils upon encountering the directive.
Method transform​_content No summary
Method get​_field​_type​_map Undocumented
Class Variable doc​_field​_types Undocumented
Class Variable final​_argument​_whitespace Undocumented
Class Variable has​_content Undocumented
Class Variable option​_spec Undocumented
Class Variable optional​_arguments Undocumented
Class Variable required​_arguments Undocumented
Instance Variable ​_doc​_field​_type​_map Undocumented
Instance Variable domain Undocumented
Instance Variable indexnode Undocumented
Instance Variable names Undocumented
Instance Variable objtype Undocumented

Inherited from SphinxDirective:

Method get​_location Get current location info for logging.
Method get​_source​_info Get source and line number.
Method set​_source​_info Set source and line number to the node.
Property config Reference to the .Config object.
Property env Reference to the .BuildEnvironment object.
def add_target_and_index(self, name, sig, signode):

Add cross-reference IDs and entries to self.indexnode, if applicable.

name is whatever handle_signature() returned.

Parameters
name:TUndocumented
sig:strUndocumented
signode:desc_signatureUndocumented
def after_content(self):
Called after parsing content. Used to reset information about the current directive context on the build environment.
def before_content(self):
Called before parsing content. Used to set information about the current directive context on the build environment.
def get_signatures(self):
Retrieve the signatures to document from the directive arguments. By default, signatures are given as arguments, one per line.
Returns
List[str]Undocumented
def handle_signature(self, sig, signode):

Parse the signature sig into individual nodes and append them to signode. If ValueError is raised, parsing is aborted and the whole sig is put into a single desc_name node.

The return value should be a value that identifies the object. It is passed to add_target_and_index() unchanged, and otherwise only used to skip duplicates.

Parameters
sig:strUndocumented
signode:desc_signatureUndocumented
Returns
TUndocumented
def run(self):

Main directive entry function, called by docutils upon encountering the directive.

This directive is meant to be quite easily subclassable, so it delegates to several additional methods. What it does:

  • find out if called as a domain-specific directive, set self.domain
  • create a desc node to fit all description inside
  • parse standard options, currently noindex
  • create an index node if needed as self.indexnode
  • parse all given signatures (as returned by self.get_signatures()) using self.handle_signature(), which should either return a name or raise ValueError
  • add index entries using self.add_target_and_index()
  • parse the content and handle doc fields in it
Returns
List[Node]Undocumented
def transform_content(self, contentnode):
Called after creating the content through nested parsing, but before the object-description-transform event is emitted, and before the info-fields are transformed. Can be used to manipulate the content.
Parameters
contentnode:addnodes.desc_contentUndocumented
def get_field_type_map(self):

Undocumented

Returns
Dict[str, Tuple[Field, bool]]Undocumented
doc_field_types: List[Field] =

Undocumented

final_argument_whitespace: bool =

Undocumented

has_content: bool =

Undocumented

optional_arguments: int =

Undocumented

required_arguments: int =

Undocumented

_doc_field_type_map: dict =

Undocumented

indexnode =

Undocumented

names: List[T] =