-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Help people using Intersphinx against objects imported from a package __init__.py #5603
Comments
I think this should be fixed on host side, not on referrer side. So I consider this is an issue of autodoc. The intersphinx extension allows to refer remote objects like they're defined in local. I know aliases can conceal the problem, but it is not perfect. |
I am not sure if relevant, but in both of the following cases:
Intersphinx will always look for |
@tk0miya so what would be the solution for this? Adding built-in support for intersphinx_aliases, autogenerate it from autodoc? The interesting code is at https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/autodoc/__init__.py#L785, here the real_modname is defined, the module that actually contains the object; while |
@tk0miya If you would provide some preference on the solution, as asked by @gaborbernat , I might try and submit a PR |
Oh, sorry. I've overlooked his comment. My answer is the latter one, generating aliases by autodoc. This is not a problem only in intersphinx. As a first step, I added |
@tk0miya Thank you for this information I drafted an implementation which broke a few (3) tests. These few edge cases definitely require a closer look. I'll submit the PR, probably this week, and work with your feedback. |
…ng canonical name This generates `:canonical:` option for `:py:class:` directive if the target class is imported from other module. It allows users to refer it using both the new name (imported name) and the original name (canonical name). It helps a library that implements some class in private module (like `_io.StringIO`), and publish it as public module (like `io.StringIO`).
…ng canonical name This generates `:canonical:` option for `:py:class:` directive if the target class is imported from other module. It allows users to refer it using both the new name (imported name) and the original name (canonical name). It helps a library that implements some class in private module (like `_io.StringIO`), and publish it as public module (like `io.StringIO`).
…ng canonical name This generates `:canonical:` option for `:py:class:` directive if the target class is imported from other module. It allows users to refer it using both the new name (imported name) and the original name (canonical name). It helps a library that implements some class in private module (like `_io.StringIO`), and publish it as public module (like `io.StringIO`).
…ng canonical name This generates `:canonical:` option for `:py:class:` directive if the target class is imported from other module. It allows users to refer it using both the new name (imported name) and the original name (canonical name). It helps a library that implements some class in private module (like `_io.StringIO`), and publish it as public module (like `io.StringIO`).
…ng canonical name This generates `:canonical:` option for `:py:class:` directive if the target class is imported from other module. It allows users to refer it using both the new name (imported name) and the original name (canonical name). It helps a library that implements some class in private module (like `_io.StringIO`), and publish it as public module (like `io.StringIO`).
…ng canonical name This generates `:canonical:` option for `:py:class:` directive if the target class is imported from other module. It allows users to refer it using both the new name (imported name) and the original name (canonical name). It helps a library that implements some class in private module (like `_io.StringIO`), and publish it as public module (like `io.StringIO`).
…ng canonical name This generates `:canonical:` option for `:py:class:` directive if the target class is imported from other module. It allows users to refer it using both the new name (imported name) and the original name (canonical name). It helps a library that implements some class in private module (like `_io.StringIO`), and publish it as public module (like `io.StringIO`).
Close #5603: autodoc: Allow to refer to a python object using canonical name
Subject: Intersphinx references to objects imported at package level can't be mapped.
Problem
References to objects that are imported in their package's
__init__.py
can't be referenced using the default objects inventory generation.The issue here is inconsistent default behavior of sphinx-apidoc and intersphinx.
Procedure to reproduce the problem
Here is an example involving
marshmallow
Build the apidoc then HTML docs using intersphinx:
No matter how I import the class,
marshmallow.Schema
is inobjects.inv
but intersphinx will always look formarshmallow.schema.Schema
.Work around
One could add aliased entries in the inventory in
conf.py
:This workaround is IMO cleaner than using https://github.com/bskinn/sphobjinv to play with objects.inv files.
Varia
I don't know how things could be improved to help users get coherent results by default, but I do hope that this issue expose a behavior issue and this workaround help someone
The text was updated successfully, but these errors were encountered: