Skip to content

Intersphinx catalog to link to the documentation #3354

Open
@gaborbernat

Description

Any way we can generate an Intersphinx catalog one can use to automatically link to the documentation?

Something like this would work to patch it:

def setup(app: Sphinx) -> None:  # noqa: D103
    class PatchedPythonDomain(PythonDomain):
        def resolve_xref(  # noqa: PLR0913, PLR0917
            self,
            env: BuildEnvironment,
            fromdocname: str,
            builder: Builder,
            type: str,  # noqa: A002
            target: str,
            node: pending_xref,
            contnode: Element,
        ) -> Element:
            if target in fixup:
                return reference("", text=target.split(".")[-1], refuri=fixup[target], internal=False)
            return super().resolve_xref(env, fromdocname, builder, type, target, node, contnode)

    fixup = {
        "httpx.AsyncClient": "https://www.python-httpx.org/api/#asyncclient",
        "starlette.applications.Starlette": "https://www.starlette.io/applications/#instantiating-the-application",
        "starlette.datastructures.Secret": "https://www.starlette.io/config/#secrets",
        "starlette.testclient.TestClient": "https://www.starlette.io/testclient/",
    }
    app.add_domain(PatchedPythonDomain, override=True)

though unsure how to emphasize the URI 🤔

Metadata

Assignees

No one assigned

    Labels

    docsChanges to the documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions