Skip to main content

Better python object resolution in Sphinx

Project description


A sphinx extension that fixes or warns about missing references to Python objects

The extension is useful because it's often annoying to write out the full path to an object in your docs which you know is imported in the current module. This is also true for neighboring modules which would be easier referenced with a relative name.

This extension resolves these issues by allowing you to reference functions or classes which are imported in the current module as if they had been defined there and creates a backlink to their true location.

from some_package import MyClass

def my_function():
    '''Uses :class:`MyClass`'''
    # The above reference would normally fail because `MyClass`
    # is not defined in this module. However this extension
    # automatically resolves the reference

This is done by analyzing the AST to find import statements and trace them back to the place where the target was defined. This is more robust than looking at the __module__ and __name__ attributes of classes and functions because not all documentable objects have these properties (e.g. global variables).

Project details

Download files

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

Files for sphinx-resolve-py-references, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size sphinx_resolve_py_references-0.1.0.tar.gz (5.5 kB) File type Source Python version None Upload date Hashes View
Filename, size sphinx_resolve_py_references-0.1.0-py2.py3-none-any.whl (6.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page