Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intersphinx catalog to link to the documentation #3354

Open
gaborbernat opened this issue Oct 21, 2024 · 3 comments
Open

Intersphinx catalog to link to the documentation #3354

gaborbernat opened this issue Oct 21, 2024 · 3 comments
Labels
docs Changes to the documentation

Comments

@gaborbernat
Copy link

gaborbernat commented Oct 21, 2024

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 🤔

@tomchristie
Copy link
Member

Discussion at #3091

Yep... does anyone want to look into switching our code docstring support to mkdocstrings?

@tomchristie tomchristie added the docs Changes to the documentation label Oct 22, 2024
@Stealthii
Copy link

Stealthii commented Oct 22, 2024

Odd that I was just about to raise this very issue after stumbling through @gaborbernat's latest docs, as I'm trying to link documentation for a downstream module of httpx.

An example of mkdocstrings own configuration can be seen here:
https://github.com/mkdocstrings/mkdocstrings/blob/0.26.2/mkdocs.yml#L136-L163

WIP changes at feature/mkdocstrings. Some concessions will need to be made between matching in with current mkautodocs format, and the options exposed by mkdocstrings. Some improvements to actual docstrings within the Python code (part tracked by #3355) should be made to improve the generated docs.

@pawamoy
Copy link

pawamoy commented Oct 26, 2024

@Stealthii let me know if you open a PR, I'll have some comments and suggestions 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Changes to the documentation
Projects
None yet
Development

No branches or pull requests

5 participants
@tomchristie @gaborbernat @Stealthii @pawamoy and others