readthedocs / readthedocs/sphinx-autoapi
Make imported memebrs link to their documentation.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 494
- Forks
- 147
- Avg merge
- 9m
- Merged PRs (30d)
- 1
Description
I am new to sphinx and autoapi so I may be missing something, but I searched the documentation and the internet and couldn't find a solution to my problem. I have a foo package which has a bar module and in it there is a Bar class. The Bar class is central to my library, so I decided to make an import shortcut for it. Inside the __init__.py file of the foo package I have the code:
from foo.bar import Bar
__all__ = ["Bar"]
So the end user can use from foo import Bar instead of the more verbose from foo.bar import Bar. Since I declared Bar in the __all__ variable, it gets picked up by autoapi and documented in the generated page for the foo package. There is also a page for the foo.bar module which contains the full docstring of the class. The problem is that I can't get the Bar class in the foo page to link to the documentation of Bar on the foo.bar page.
If I have the "imported-members" option in conf.py, the docstring of the Bar class is displayed in both the foo and foo.bar pages with no link between them. This is an unnecessary duplication and it makes the user think that there are two Bar symbols without explaining that one is just an alias for the other. If I disable the "imported-members" option, then the docstring only appears in the foo.bar page and on the foo page, Bar is listed in the package's contents, but that's it. It doesn't link to anything. So the user knows that foo.Bar is an alias, but he doesn't know to what. I'd like the Bar in the foo page to link to the full docstring in the foo.bar page, but I couldn't figure out how to accomplish that.
Any ideas?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the imported-members option in conf.py and the init.py alias example, then trace how AutoAPI represents imported symbols on the foo and foo.bar pages. Done means an imported Bar appears once as the alias in foo and links to the full Bar documentation in foo.bar without duplicating its docstring.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100