Skip to main content

Sphinx objects.inv Inspection/Manipulation Tool

Project description

Current Development Version:

https://img.shields.io/azure-devops/build/brianskinn/09020ac4-1ef2-4890-8c23-c3128d2029e3/4?label=azure-pipelines&logo=azure-devops https://img.shields.io/travis/com/bskinn/sphobjinv?label=travis-ci&logo=travis https://codecov.io/gh/bskinn/sphobjinv/branch/master/graph/badge.svg

Most Recent Stable Release:

https://img.shields.io/pypi/v/sphobjinv.svg?logo=pypi https://img.shields.io/pypi/pyversions/sphobjinv.svg?logo=python

Info:

https://img.shields.io/readthedocs/sphobjinv/v2.0.svg https://img.shields.io/github/license/mashape/apistatus.svg https://img.shields.io/badge/code%20style-black-000000.svg

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 highly 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, 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 50

  Name                                                     Score
--------------------------------------------------------  -------
:py:method:`sphobjinv.data.SuperDataObj.as_rst`             60
:py:function:`sphobjinv.cmdline.getparser`                  50
:py:method:`sphobjinv.data.SuperDataObj.as_str`             50
:py:method:`sphobjinv.inventory.Inventory.objects_rst`      50

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, just 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/1.18/reference/index.html linspace -su

No inventory at provided URL.
Attempting "https://numpy.org/doc/1.18/reference/index.html/objects.inv" ...
Attempting "https://numpy.org/doc/1.18/reference/objects.inv" ...
Attempting "https://numpy.org/doc/1.18/objects.inv" ...
Remote inventory found.


  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.1a2, 184 objects>
>>> inv.project
'sphobjinv'
>>> inv.version
'2.1a2'
>>> inv.objects[0]
DataObjStr(name='sphobjinv.cmdline', domain='py', role='module', priority='0', uri='cli/implementation.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) Brian Skinn 2016-2020

License: The MIT License. See LICENSE.txt for full license terms.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sphobjinv-2.1a2-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file sphobjinv-2.1a2-py3-none-any.whl.

File metadata

  • Download URL: sphobjinv-2.1a2-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for sphobjinv-2.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 c4c30998a90662fe44fa361a9f4848bdf942d35dff8b72f55b93eb51c1939aa0
MD5 71ed44f0fcf4b7f92daf74b8c2c890e3
BLAKE2b-256 c6c4a5fa723755ba763edbe27bebe750f6bf4c1af9b0f8ab1140600baaa6222f

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