Skip to main content

sphobjinv: Manipulate and inspect Sphinx objects.inv files

Current Development Version

GitHub Workflow Status

Most Recent Stable Release

PyPI Version Python Versions

Info

ReadTheDocs status gitter chat

MIT License black formatted PePY stats


Using Sphinx?

Having trouble writing cross-references?

sphobjinv (short for 'sphinx objects.inv') can help!

The syntax required for a functional Sphinx cross-reference is non-obvious in many cases. Sometimes Sphinx can guess correctly what you mean, but it's pretty hit-or-miss. The best approach is to provide Sphinx with a completely specified cross-reference, and that's where sphobjinv comes in.

After a pip install sphobjinv (or pipx install sphobjinv), find the documentation set you want to cross-reference into, and pass it to sphobjinv suggest.

For internal cross-references, locate objects.inv within build/html:

$ sphobjinv suggest doc/build/html/objects.inv as_rst -st 58

-----------------------------------------------------------------------------------------------------------

Cannot infer intersphinx_mapping from a local objects.inv.

-----------------------------------------------------------------------------------------------------------

Project: sphobjinv
Version: 2.4

151 objects in inventory.

-----------------------------------------------------------------------------------------------------------

10 results found at/above current threshold of 58.

  Name                                                Score
---------------------------------------------------  -------
:py:property:`sphobjinv.data.SuperDataObj.as_rst`      60
:py:class:`sphobjinv.data.DataFields`                  59
:py:class:`sphobjinv.data.DataObjBytes`                59
:py:class:`sphobjinv.data.DataObjStr`                  59
:py:class:`sphobjinv.data.SuperDataObj`                59
:py:class:`sphobjinv.enum.HeaderFields`                59
:py:class:`sphobjinv.enum.SourceTypes`                 59
:py:function:`sphobjinv.fileops.writebytes`            59
:py:function:`sphobjinv.fileops.writejson`             59
:py:class:`sphobjinv.inventory.Inventory`              59

The -s argument in the above shell command indicates to print the fuzzywuzzy match score along with each search result, and -t 50 changes the reporting threshold for the match score.

For external references, find the API documentation wherever it lives on the web, and pass sphobjinv suggest a URL from within the documentation set with the --url/-u flag. For example, say I need to know how to cross-reference the linspace function from numpy (see here):

$ sphobjinv suggest https://numpy.org/doc/2.4/reference/index.html linspace -su

Attempting https://numpy.org/doc/2.4/reference/index.html ...
  ... no recognized inventory.
Attempting "https://numpy.org/doc/2.4/reference/index.html/objects.inv" ...
  ... HTTP error: 404 Not Found.
Attempting "https://numpy.org/doc/2.4/reference/objects.inv" ...
  ... HTTP error: 404 Not Found.
Attempting "https://numpy.org/doc/2.4/objects.inv" ...
  ... inventory found.

-----------------------------------------------------------------------------------------------------------

The intersphinx_mapping for this docset is LIKELY:

  (https://numpy.org/doc/2.4/, None)

-----------------------------------------------------------------------------------------------------------

Project: NumPy
Version: 2.4

8456 objects in inventory.

-----------------------------------------------------------------------------------------------------------

8 results found at/above current threshold of 75.

  Name                                                           Score
--------------------------------------------------------------  -------
:py:function:`numpy.linspace`                                     90
:py:method:`numpy.polynomial.chebyshev.Chebyshev.linspace`        90
:py:method:`numpy.polynomial.hermite.Hermite.linspace`            90
:py:method:`numpy.polynomial.hermite_e.HermiteE.linspace`         90
:py:method:`numpy.polynomial.laguerre.Laguerre.linspace`          90
:py:method:`numpy.polynomial.legendre.Legendre.linspace`          90
:py:method:`numpy.polynomial.polynomial.Polynomial.linspace`      90
:std:doc:`reference/generated/numpy.linspace`                     90

NOTE that the results from sphobjinv suggest are printed using the longer block directives, whereas cross-references must be composed using the inline directives. Thus, the above linspace() function must be cross-referenced as :func:`numpy.linspace` , not :function:`numpy.linspace`.

Need to edit an inventory after it's created, or compose one from scratch?

sphobjinv can help with that, too.

objects.inv files can be decompressed to plaintext at the commandline:

$ sphobjinv convert plain -o doc/build/html/objects.inv doc/scratch/
Conversion completed.
'...objects.inv' converted to '...objects.txt' (plain).

JSON output is supported (sphobjinv convert json ...), and inventories can be re-compressed to the partially-zlib-compressed form that intersphinx reads (sphobjinv convert zlib ...).

Alternatively, sphobjinv exposes an API to enable automation of inventory creation/modification:

>>> import sphobjinv as soi
>>> inv = soi.Inventory('doc/build/html/objects.inv')
>>> print(inv)
<Inventory (fname_zlib): sphobjinv v2.4, 151 objects>
>>> inv.project
'sphobjinv'
>>> inv.version
'2.4'
>>> inv.objects[0]
DataObjStr(name='sphobjinv.data', domain='py', role='module', priority='0', uri='api/data.html#module-$', dispname='-')

The API also enables straightforward re-export of an inventory, for subsequent use with intersphinx cross-references. See the docs for more details.


Full documentation is hosted at Read The Docs.

Available on PyPI (pip install sphobjinv).

Source on GitHub. Bug reports and feature requests are welcomed at the Issues page there.

Copyright (c) 2016-2026 Brian Skinn and community contributors

The sphobjinv documentation (including docstrings and README) is licensed under a Creative Commons Attribution 4.0 International License (CC-BY). The sphobjinv codebase is released under the MIT License. See LICENSE.txt for full license terms.

Release files for sphobjinv 2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphobjinv 2.4
File Size Uploaded
sphobjinv-2.4.tar.gz 250.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphobjinv 2.4
File Interpreter ABI Platform
sphobjinv-2.4-py3-none-any.whl Python 3 none any Details

Total release size: 301.3 kB

Release files / sphobjinv-2.4.tar.gz

Download URL sphobjinv-2.4.tar.gz
Size 250.0 kB
Tags Source
SHA-256 checksum
How to use checksums
44d57e7e87e17d8c7b053c853dcc36f80cbf7d1fc152d57634fd7bcae38ca48a
BLAKE2b-256 checksum
How to use checksums
1f6719f33eeb4ffff0e2fd39afd4783a6ee38a6d58bcc1ddade779712a7e2e49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / sphobjinv-2.4-py3-none-any.whl

Download URL sphobjinv-2.4-py3-none-any.whl
Size 51.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35f3239e9a6161c20d60146c16645687d06d43e5875d2bda71010c3ee7fd54bc
BLAKE2b-256 checksum
How to use checksums
2c97840be4a99531292f8f41069bfcd0654f68296ef4089bfe828607d63ee0ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page