sciline.sphinxext.domain_types#

A Sphinx extension for improved typehints rendering.

sphinx-autodoc-typehints implements formatting for typehints but often results in hard-to-read annotations for typing.NewType. As those may be ubiquitous when using Sciline, this extension improves formatting.

Usage#

This extension relies on sphinx-autodoc-typehints for the core implementation of typehints rendering. Install it as well as Sciline and add both to extensions in your conf.py:

extensions = [
    ...,
    'sphinx-autodoc-typehints',
    'sciline.sphinxext.domain_types'
]

sciline.sphinxext.domain_types registers a custom typehints_formatter used by sphinx-autodoc-typehints, so do not define your own!

Options#

  • sciline_domain_types_prefix (default ''): Strip this prefix from type names. For example, if a type is defined as mypackage.types.SomeType, setting sciline_domain_types_prefix = 'mypackage' results in this type being rendered as types.SomeType.

  • sciline_domain_types_aliases (default {}): This extension can render aliases instead of the regular type names. This is useful, e.g., for abbreviating long types or types defined in internal modules. For example,

    sciline_domain_types_aliases = {'mypackage._types.SomeType': 'mypackage.SomeType'}
    

    Renders occurrences of SomeType as mypackage.types.SomeType instead of using the fully qualified name.

Functions

setup(app)

Setup sciline.sphinxext.domain_types.