pytools.sphinx.util.CollapseModulePathsInDocstring#

class pytools.sphinx.util.CollapseModulePathsInDocstring(collapsible_submodules, collapse_private_modules=True)[source]#

Replace private module paths in docstrings with their public prefix so that object references can be matched by intersphinx.

Bases

AutodocProcessDocstring, CollapseModulePaths

Metaclasses

ABCMeta

Parameters
  • collapsible_submodules (Mapping[str, str]) – mapping from module paths to their public prefix, e.g., {"pandas.core.frame": "pandas"}

  • collapse_private_modules (bool) – if True, collapse module sub-paths consisting of one or more protected modules (i.e. the module name starts with an underscore)

Method summary

collapse_module_paths

In the given line, replace all module paths with their collapsed version.

connect

Register this callback to be called when event is emitted.

disconnect

Disconnect this callback from its Sphinx application.

process

Process an event.

Attribute summary

app

The Sphinx application this callback is connected to.

event

"autodoc-process-docstring"

listener_id

The listener ID of this callback.

Definitions

__call__(app, what, name, obj, options, lines)#

Call self as a function.

Return type

None

collapse_module_paths(line)#

In the given line, replace all module paths with their collapsed version.

Parameters

line (str) – the line in which to collapse module paths

Return type

str

Returns

the resulting line with collapsed module paths

connect(app, priority=None)#

Register this callback to be called when event is emitted.

Registered callbacks will be invoked on event in the order of priority and registration. The priority is ascending order.

Parameters
  • app (Any) – the Sphinx application to register this processor with

  • priority (Optional[int]) – the priority of this processor

Return type

int

Returns

a listener ID that can be used as an argument to disconnect().

disconnect()#

Disconnect this callback from its Sphinx application.

Return type

None

process(app, what, name, obj, options, lines)[source]#

Process an event.

Parameters
  • app (Sphinx) – the Sphinx application object

  • what (str) – the type of the object which the docstring belongs to (one of “module”, “class”, “exception”, “function”, “method”, “attribute”)

  • name (str) – the fully qualified name of the object

  • obj (object) – the object itself

  • options (object) – the options given to the directive: an object with attributes inherited_members, undoc_members, show_inheritance and noindex that are True if the flag option of same name was given to the auto directive

  • lines (list[str]) – the lines of the docstring

Return type

None

property app: Optional[Any]#

The Sphinx application this callback is connected to.

Return type

Optional[Any]

Returns

the Sphinx application, or None if not connected.

property event: str#

"autodoc-process-docstring"

Return type

str

property listener_id: int | None#

The listener ID of this callback.

Return type

Optional[int]

Returns

the listener ID, or None if not connected.