A Domain is meant to be a group of “object” description directives for objects of a similar nature, and corresponding roles to create references to them. Examples would be Python modules, classes, functions etc., elements of a templating language, Sphinx roles and directives, etc.
Each domain has a separate storage for information about existing objects and how to reference them in self.data, which must be a dictionary. It also must implement several functions that expose the object information in a uniform way to parts of Sphinx that allow the user to reference or search for objects in a domain-agnostic way.
About self.data: since all object and cross-referencing information is stored on a BuildEnvironment instance, the domain.data object is also stored in the env.domaindata dict under the key domain.name. Before the build process starts, every active domain is instantiated and given the environment object; the domaindata dict must then either be nonexistent or a dictionary whose ‘version’ key is equal to the domain class’ data_version attribute. Otherwise, IOError is raised and the pickled environment is discarded.
Remove traces of a document in the domain-specific inventories.
Return a directive adapter class that always gives the registered directive its full name (‘domain:name’) as self.name.
Return an iterable of “object descriptions”, which are tuples with five items:
Return full name for given ObjType.
Process a document after it is read by the environment.
Resolve the pending_xref node with the given typ and target.
This method should return a new node, to replace the xref node, containing the contnode which is the markup content of the cross-reference.
If no resolution can be found, None can be returned; the xref node will then given to the ‘missing-reference’ event, and if that yields no resolution, replaced by contnode.
The method can also raise sphinx.environment.NoUri to suppress the ‘missing-reference’ event being emitted.
Return a role adapter function that always gives the registered role its full name (‘domain:name’) as the first argument.
role name -> a warning message if reference is missing
data version, bump this when the format of self.data changes
directive name -> directive class
a list of Index subclasses
data value for a fresh environment
domain label: longer, more descriptive (used in messages)
domain name: should be short, but unique
type (usually directive) name -> ObjType instance
role name -> role callable
An ObjType is the description for a type of object that a domain can document. In the object_types attribute of Domain subclasses, object type names are mapped to instances of this class.
An Index is the description for a domain-specific index. To add an index to a domain, subclass Index, overriding the three name attributes:
Return entries for the index given by name. If docnames is given, restrict to entries referring to these docnames.
The return value is a tuple of (content, collapse), where collapse is a boolean that determines if sub-entries should start collapsed (for output formats that support collapsing sub-entries).
content is a sequence of (letter, entries) tuples, where letter is the “heading” for the given entries, usually the starting letter.
entries is a sequence of single entries, where a single entry is a sequence [name, subtype, docname, anchor, extra, qualifier, descr]. The items in this sequence have the following meaning:
Qualifier and description are not rendered e.g. in LaTeX output.