Skip to main content

auto substitution for python types like modules, classes and functions (created by auxilium)

Project description

Python Project sphinx-pytype-substitution

codeship readthedocs license github_version pip_version py_version pypi_downloads

Introduction

sphinx-pytype-substitution generates restructuredtext substitutions for python cross references.

Once added to the extensions list of the Sphinx configuration file conf.py it adds short and handy substitutions for modules and classes.

So, on one side it becomes easy to add cross references to some api documentation in the project. And on the other side these references are still easy readable, even if the text is displayed directly (as it happens on GitHub.com or on PyPi.org).

Install

The latest stable version can always be installed or updated via pip:

$ pip install sphinx-pytype-substitution

Usage

Once available add the extension to then extensions list in config.py

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx_pytype_substitution',
    'sphinx_rtd_theme',
    'sphinx.ext.autodoc',
    'sphinx.ext.autosummary',
    'sphinx.ext.doctest',
    'sphinx.ext.mathjax',
    'sphinx.ext.viewcode',
    'sphinx.ext.napoleon'
]

And add the modules or classes to reference to as

# -- Config for pytype_substitution extension ------------------------------

pytype_substitutions = pkg,  # package, module or class to reference to

Additional options let select specific references

pytype_match_pattern = ''  # regex to filter entities to ref to
pytype_exclude_pattern = ''  # regex to exclude entities to ref to

and decide if the substitution should have short or full format, i.e.

pytype_short_ref = True  # drop module from reference (if it does not conflict)

for |date()| rather than |datetime.date()|. Note, sometimes the defining module matters as for |open()| vs |gzip.open()|.

During initialisation process of Sphinx the list of substitutions is generated and added to rst_epilog.

So the substitutions are available for every page.

To see which substitutions are added add

pytype_show = True  # print out all pytype_substitutions

License

Code and documentation are available according to the license (see LICENSE file in repository).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_pytype_substitution-0.1.2.zip (18.3 kB view details)

Uploaded Source

File details

Details for the file sphinx_pytype_substitution-0.1.2.zip.

File metadata

  • Download URL: sphinx_pytype_substitution-0.1.2.zip
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for sphinx_pytype_substitution-0.1.2.zip
Algorithm Hash digest
SHA256 1f52113205545d191fed0f91e445411609f15d2a1cad20bb74aa4aff8e1a2711
MD5 6a1e409801e8d0c718b703399b18c48a
BLAKE2b-256 eb5dfeab982f5dce36abaa9a9c8a0aaefc3da1dc2cc44cbf0bdef2ad226cb46d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page