-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Resolve intersphinx to own project as current build #9169
Comments
It's a tough question. To share the docstring having special mark-up causes troubles sometimes. For example, sharing First of all, let's start the case the owner of the A and B projects are the same. I think it's not impossible. |
Those are good points. Perhaps the best solution would be a setting / configuration parameter / something in So for project A it it might look like. intersphinx_mapping["A"] = ("std", None) # (I think "std" is the local link name? correct me if I'm wrong) Now project A can do in its docs class SomeClass:
```Read more in :doc:A:`my-docs` ``` and it will resolve as if the docstring was When project B makes its intersphinx mapping intersphinx_mapping["A"] = ('https://A.readthedocs.io/en/stable/', None) and subclasses SomeClass class SubSomeClass(SomeClass):
# inherit the docstring The doscstring will "just" work. |
Now we introduces Could you try it please? |
Thanks for the update, @tk0miya ! @nstarman , do we have to undo a bunch of astropy/astropy#11690 to take advantage of this new upstream feature? |
Thanks @tk0miya! With the new |
Hmm, I think the new :external+astropy:ref:`astropy-constants-prior` and then But as pointed out in #9169 (comment), this would not help for all cases of docstrings, and the parent package needs to have these external roles explicitly. |
A quick proposal: #10127 .. py:function:: sum()
- :py:func:`sum`, resolves to the local version
- :external:py:func:`sum`, resolves to the Python docs
- :external+python:py:func:`sum`, same as above
- :external+testInv:py:func:`sum`, resolves to the local version and then extensions = [
'sphinx.ext.intersphinx',
]
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}
intersphinx_self_mapping = "testInv" |
Thank you! Looks like we might be able to simplify our |
Yes, your I did realise whilst testing this that implicit references weren't covered, so I've opened #13322 to fix this. A |
Thank you! |
For completeness, I opened downstream issue as a follow-up. Thanks again for all your help, @AA-Turner ! |
Is your feature request related to a problem? Please describe.
Motivated from astropy/astropy#11690
Take packages A and B, with package A as the core package and package B as an affiliate package.
When B subclasses a class from package A, docstrings can be inherited from the A class. If the docstring contains a reference, e.g.
:doc:`/path/to`
, then this link will incorrectly point to the documentation in the B package, not in the A package.One option is to make the links intersphinx links, e.g.
:doc:`A:/path/to`
. While this is useful for the B package, now the link is broken for the A package, or at best refers to an old version of the docs: whatever is specified in the intersphinx mapping.Describe the solution you'd like
Allow intersphinx references to the package being built to be "stripped" of the intersphinx portion and be resolved as local links. In the example above,
:doc:`A:/path/to`
->:doc:`/path/to`
when in package A. Now both packages A and B can use the same links. B gets an intersphinx link, A gets a link to the current build.Describe alternatives you've considered
In astropy/astropy#11690 we implemented a bit of a hack by setting a function with higher priority than intersphinx to change the link types. While this works, a built-in solution would be better.
Additional context
The text was updated successfully, but these errors were encountered: