Skip to main content

Add your description here

Project description

pypi-docs-url

Proof of concept for a tool that locates a project’s Intersphinx inventory (objects.inv) by combining PyPI metadata and (if necessary) GitHub actions/workflows analysis.

Most packages use a direct docs/ URL, but many run extra steps—mkdocs, Sphinx, GitHub Pages, multi-step publishing—so the final objects.inv location can be non-trivial. pypi-docs-url tries to guess it automatically.

Basic Overview

  1. Check PyPI (via PyPI JSON) for a doc link (project_urls or home_page).
  2. If missing, parse the GitHub repo from PyPI (if present).
  3. Fetch the .github/workflows/docs-python.yml to see how docs are deployed (e.g. “target-folder: api/python/stable”).
  4. Build a guessed final docs domain (e.g. docs.pola.rs) plus that subfolder + /objects.inv.
  5. Check if that file returns HTTP 200, and if so, print the final URL.

Installation

pip install pypi-docs-url

(Or however you prefer to install from your local copy, e.g. pip install ..)

Usage

CLI

The primary entry point is a CLI tool, pypi-docs-url, which accepts a single argument: the package name you want to inspect. It simply prints the discovered objects.inv URL if successful, or reports failure:

$ pypi-docs-url polars
https://docs.pola.rs/api/python/stable/objects.inv

If it can’t find the objects.inv, it prints:

No objects.inv discovered or parse failed.

**That’s it—**by default, it’s short and sweet.

CLI Help

$ pypi-docs-url --help
Usage: pypi-docs-url [OPTIONS] PACKAGE_NAME

  CLI entry point to get the 'objects.inv' URL for PACKAGE_NAME, if any.

Options:
  --help  Show this message and exit.

Python API

If you want to reuse the logic in your own code (not just the CLI), simply import from the package:

from pypi_docs_url import get_intersphinx_url

def example():
    inv_url = get_intersphinx_url("polars")
    if inv_url:
        print(f"Found objects.inv => {inv_url}")
    else:
        print("No objects.inv discovered.")

(This means you can embed the logic in your library or script, rather than invoking the CLI.)

Walkthrough / Verbose Explanation

If you want to see the internal steps—like how we parse PyPI’s JSON, find docs-python.yml, guess the subfolder, etc.—the package contains commented code illustrating each step in detail. Look in examples/demo_verbose.py for a fully “instrumented” version:

# demo_verbose.py (example, not installed by default)
#
# This script shows a step-by-step chain, printing out partial PyPI JSON,
# partial GitHub workflow lines, how we locate "api/python/stable",
# and the final HEAD request on objects.inv.
#
# EXAMPLE USAGE:
#   python demo_verbose.py polars
#
# (Output lines are commented out to avoid spamming the console by default.)

import re
import requests
import yaml

def main(package_name: str):
    # 1) PyPI JSON fetch
    # print(f"Fetching PyPI JSON at: https://pypi.org/pypi/{package_name}/json")
    # ...
    # print("Relevant fields: { ... }")

    # 2) Doc link in project_urls
    # print(f"Found doc link => https://docs.pola.rs/api/python/stable/reference/index.html")

    # 3) GitHub link => parse org/repo => fetch docs-python.yml
    # print("Key lines from docs-python.yml containing 'deploy' or 'target-folder': ...")

    # 4) Identify 'api/python/stable' => build guess => HEAD request => final URL
    # print("HEAD => 200 => success!")

    pass

if __name__ == "__main__":
    import sys
    pkg = sys.argv[1] if len(sys.argv) > 1 else "polars"
    main(pkg)

You can uncomment lines in that demo to see each step’s output. This is purely an example—the main installed pypi-docs-url script does not do this verbose printing.


Example

Below is how Polars’ doc resolution might look if you were to uncomment the verbose lines:

** Attempting to discover polars's objects.inv via PyPI → GH workflow logic **

[1] Fetching PyPI JSON at: https://pypi.org/pypi/polars/json

[1a] Relevant PyPI fields:
  project_urls: {
    "Changelog": "...",
    "Documentation": "https://docs.pola.rs/api/python/stable/reference/index.html",
    "Repository": "https://github.com/pola-rs/polars"
  }

[1b] Found doc link => https://docs.pola.rs/api/python/stable/reference/index.html

[1c] GitHub => https://github.com/pola-rs/polars
[1d] org=pola-rs, repo=polars

[2] Attempting to fetch workflow at: https://raw.githubusercontent.com/pola-rs/polars/main/.github/workflows/docs-python.yml

[2a] Key lines (containing 'deploy' or 'target-folder'):
  ... "target-folder: api/python/dev"
  ... "target-folder: api/python/stable"

[2c] stable => api/python/stable

[3] Final guess => https://docs.pola.rs/api/python/stable/objects.inv
Performing HEAD => status 200 => success!

(That’s the deeper logic under the hood, while the actual CLI usage is a single line printing out the final URL.)


Testing

When running tests, and adding new packages, we run pytest -s > tests/find_docs_test.log.txt to save the 'trace' (from debugging) to give clues for LLMs, as well as general debugging and interpretation.

Contributing

Feel free to open issues/PRs:

  • Expand to handle multiple subdomains or dev vs stable docs.
  • Add a fallback if the doc link is missing but the project uses Sphinx.
  • Improve logic for mkdocs vs Sphinx detection.

License

MIT.

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

pypi_docs_url-0.1.3.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

pypi_docs_url-0.1.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file pypi_docs_url-0.1.3.tar.gz.

File metadata

  • Download URL: pypi_docs_url-0.1.3.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.3 CPython/3.11.11 Linux/6.8.0-51-generic

File hashes

Hashes for pypi_docs_url-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d8b6cf44f7e9e4e8a42886b08376e2b8c83e5be753cb555d93791ab9cf05d1ca
MD5 f8378b9fcc4b03be1daa96fb6f21b551
BLAKE2b-256 64fd1173c210c6e711d289e40f4449df5de86950d4097dd26cb5cef3cf3cfd9d

See more details on using hashes here.

File details

Details for the file pypi_docs_url-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pypi_docs_url-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.3 CPython/3.11.11 Linux/6.8.0-51-generic

File hashes

Hashes for pypi_docs_url-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3756bbb024b8cdc72c16b5a3cc2468745027fc710708d3b77189341bdc431659
MD5 8d7a20b96fb03d6c402a719b21acb3f9
BLAKE2b-256 932e9be8fe7e845ac47a2e2534aecf1ab0672a3a6211fddd1edc468ae64b65be

See more details on using hashes here.

Supported by

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