Skip to main content

Sphinx Lens

CI docs pypi version Changelog Ruff ty License

Structure-aware indexing and precise navigation for Sphinx documentation.

Sphinx knows things about your documentation that nothing downstream gets to use: which text belongs to which section, that django.db.transaction.atomic is a documented object with a canonical name, and where every cross-reference points. Then it renders HTML and throws that away.

Sphinx Lens is a Sphinx builder that writes it down instead. The output is a single JSON index of documents, sections, and domain objects, each with a stable reference and its own scoped text, plus the compiled link graph between them. Coding agents get to read one precise scope instead of grepping a source tree.

Quick start

Install Sphinx Lens in the same environment as your documentation and build the index like any other Sphinx artifact:

sphinx-build -b lens docs/ docs/_build/lens/
sphinx-lens locate "connection timeout" --index docs/_build/lens/
sphinx-lens inspect py:class:example.Client --index docs/_build/lens/
sphinx-lens read guide/network#timeouts --index docs/_build/lens/
sphinx-lens links guide/network#timeouts --index docs/_build/lens/

The lens builder is discovered through Sphinx's builder entry point; no conf.py change is required. It loads the project's formats, extensions, and domains, then writes docs/_build/lens/index.json. Projects can expose this as make lens; sphinx-lens build docs/ is the equivalent convenience command.

Sphinx executes conf.py during every build. Only index projects you trust, and run the command in the project's documentation environment so MyST, autodoc, themes, and project-specific extensions are importable.

Install the bundled agent skill with Library Skills:

uvx library-skills install --skill sphinx-lens --yes

locate is lexical. It finds the right reference so that read and links can do the real work; embedding similarity is out of scope.

Full documentation is at https://mgaitan.github.io/sphinx-lens/. Start with Getting started, or read How it works for why this is a separate artifact rather than a reuse of objects.inv, searchindex.js, or Sphinx doctrees.

Development

  • Install dependencies with uv sync.
  • New dependency releases are delayed by one week via uv cooldown ([tool.uv].exclude-newer = "1 week"), with per-package overrides when required (for example, ty).
  • Make targets and GitHub Actions enable uv's malware check against known malicious-package advisories.
  • Install prek as an external tool:
uv tool install prek
  • Install git hooks with prek:
prek install
  • Run the local QA bundle with prek:
prek run --all-files
  • PRs with documentation changes publish a docs preview at:
https://mgaitan.github.io/sphinx-lens/_preview/pr-<PR_NUMBER>/
  • Build this project's own index with make lens, and the docs with make docs.

Download files

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

Source Distribution

sphinx_lens-0.1.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_lens-0.1.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_lens-0.1.0.tar.gz.

File metadata

  • Download URL: sphinx_lens-0.1.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sphinx_lens-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1ce6e54e05186fc00bdacee3316e7de8f17a496d8b95d4caca8d553f75971132
MD5 f60faad7a88e5d985928661ae1443ca6
BLAKE2b-256 273172b587df9b72dea8cd7fd9e14d479035f814117c1647ba5185083ff2d61f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_lens-0.1.0.tar.gz:

Publisher: cd.yml on mgaitan/sphinx-lens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_lens-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sphinx_lens-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sphinx_lens-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc363ca5f0b2864109471aad445a479e0b8a45f5bc1fa1997673e585db5883b2
MD5 73a0fe1c4d80b4791265ee2b4e59a0ed
BLAKE2b-256 4f1b7e102ea03005d28078bc1271ccc7eb4d427ed142b458f97711e7f028c693

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_lens-0.1.0-py3-none-any.whl:

Publisher: cd.yml on mgaitan/sphinx-lens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

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