Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
New Sphinx tutorial (intersphinx, postponed) #9424
New Sphinx tutorial (intersphinx, postponed) #9424
Changes from 5 commits
0bea92d
06824e2
9dade12
8511726
89aa4f9
87c3650
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of the Intersphinx extension is referring to remote objects transparently like referring to local objects. We've usually found local objects via reading source documents, I believe. So I think the way to find the remote objects is also reading source documents, first. Is searching
objects.inv
really better way to do that? I don't think so...This tutorial does not describe the relationship between the
std:doc
and:doc:
role. Where they came from? I'm worried this explanation makes beginners confused.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was only to explain what the file is. Perhaps it is too technical? I find myself using this quite often lately, perhaps because I'm still learning the intricacies of intersphinx. @webknjaz has https://webknjaz.github.io/intersphinx-untangled/ and I think it's quite useful too.
In any case, I can clarify that this is optional and that it works in the same way as your own docs (except for custom roles, like Sphinx own
:confval:
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't because I need to learn it myself...!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had no luck on the Sphinx docs but I found this somewhere else:
Now I understand your point. I will think if I can clarify this earlier, otherwise rephrase this part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to see this table in the official docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never had to do this by reading the source — it's hard to locate such things when you don't know where they are defined and how. Besides, the source is not always linked or available.
This is why I came up with intersphinx-untangled — it helps me discover things that are actually available. I sometimes even search by URL to see what roles link there.
I think there should be some sort of a reference explorer (I mentioned this somewhere on the tracker earlier).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep: #8211
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Some kinds of objects (including labels and documents) belong to the std domain. It behaves like a system domain. So users do not need to give the domain name on referencing objects like
:std:doc
or:std:ref:
.https://github.com/sphinx-doc/sphinx/blob/4.x/sphinx/domains/std.py#L562-L570
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never thought referencing remote document via intersphinx. So I did not know such a behavior. Indeed, it would be a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for chiming in @tk0miya ! I opened a discussion on https://groups.google.com/g/sphinx-dev/c/ZfslSpDGNUs/m/RjfzzFzUCgAJ about it, I think it's somewhat addressed by #9459
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prefixing is a bit of an icky issue. It doesn't work in general for all roles (and fundamentally can't), so in the end this should illustrate the feature with the role introduced by #9062.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not aware of that pull request. Do we want to introduce it even if it's not merged yet? Also, out of curiosity, can you expand a bit (or give an example) that doesn't work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tutorial should definitely be in sync with the implementation, so it's more that we should be aware of updating this part when relevant. Though, I guess this part will be merged after 4.1 (going out this weekend I believe), so there is a chance of the PR being ready in the same release as this.
As concrete examples, the roles in the C and C++ domains do not support this prefix. There are more details in #8418 (comment), but the fundamental issue is that when you call a role, e.g.,
:py:class:
you ask the Python domain extension to do whatever it likes. This is most likely to insert apending_xref
node with meta-information, which that same extension is being asked to resolve at a later stage. When you suddenly add the prefix, you explicitly don't want that domain to handle it, but hope it understands and fails to resolve the xref, such that intersphinx can get a chance to resolve according to the prefix. Hence, fundamentally the syntax should be with a role that directly calls intersphinx directly, without other extensions involved (until a later stage, see also #8929).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I commented above, one of the goal of intersphinx is transparency. So I prefer not to use prefix for cross references. As you explained, it is "optional" feature. So it would be better to explain the extension by non-prefixed example at first, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, it looked more clar to me that way, but I'm +1 on explaning the fully consistent and transparent way instead. Will rephrase this part.