-
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
display names relative to the package's namespace #4065
Comments
Does it help if your from .module import Class
__all__ = ('Class') I found this was needed when the module was private (leading underscore in filename), meaning Sphinx by default would ignore my module file. |
@peterjc Thank you, that does indeed help. With an
This is a lot better than Thanks to your suggestion, I have realized that my original feature request was (in part) based on a misunderstanding - it's not Sphinx's fault that the class was listed as |
I have the same setup and the same issue, and found out that you can use However, I still have a remaining issue. I'm using type annotations in my code, and autodoc renders those correctly, but it uses |
If anyone else is stuck on the same issue of having the internal (private) package.module.Class shown, I worked around it by catching
As written this only works one level deep, as that's all I needed. You'll want to tweak some I'm sure. |
The core problem with base class documentation seems to be that I'm reluctant to use a post-processing string hack as I've got a lot of classes in many modules across many repositories, and getting such hacks right would be a lot of work. I'm also reluctant to alter the If there was a, say, |
@dkfellows I'm planning to define the "canonical" name to the class definition like the following:
After that, other documents can refer to the class via both names. At present, the |
Now I merged #9026 that generates :canonical: option for the imported classes. I believe this issue is resolved now. |
Consider a project structured like this:
__init__.py
contains:module.py
contains:The docs generated by autodoc look like this:
This is very different from what the user is supposed to see. A user would import
Class
withfrom package import Class
, not withfrom package.module import Class
. The user doesn't need to know in which fileClass
was defined. From the user's perspective,Class
is located inpackage
, andmodule
doesn't even exist. The docs would be a lot more helpful if they looked like this:The relevant changes I made are the following:
Class
is listed directly inpackage
rather than inpackage.module
module
isn't listed as a submodule, because it doesn't contain anything relevantThis accurately displays
package
's public interface; there is no useless non-information in this documentation. If autodoc could produce output like this, it would be a massive improvement.The text was updated successfully, but these errors were encountered: