- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add intersphinx role #9062
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
Add intersphinx role #9062
Conversation
def get_role_name(self, name: str) -> Optional[Tuple[str, str]]: | ||
names = name.split(':') | ||
if len(names) == 2: | ||
# :intersphinx:role: |
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 think :external:***:
is also good naming for this.
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 think both are ok, but I lean towards changing to external
as it seems to convey the semantics of what it is in a more direct manner.
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.
given that ref
s are often quite comment, I think there is value in compactness here. For this reason I think external
is better than intersphinx
, but I'd also propose that eref
is used instead of external
(short for "external ref"). What do folks think about that?
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.
See comment below regarding eref
.
To create custom reST dispatcher easily, this adds CustomReSTDispatcher class as a base class of custom dispatchers.
|
||
newnode = missing_reference(self.app, self.env, node, contnode) | ||
if newnode is None: | ||
self.warn_missing_reference(refdoc, node['reftype'], node['reftarget'], |
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 warning will shown twice because ReferencesResolver
will process this again!
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.
Can't we just skip the warning here? I guess missing_reference
will take care of it then?
I made some commits at https://github.com/jakobandersen/sphinx/tree/intersphinx_role to implement the following:
|
location=(self.env.docname, self.lineno)) | ||
return [], [] | ||
|
||
result, messages = self.invoke_role(role_name) |
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.
In a way it seems a bit strange to call the role when it is not supposed to resolve anything. But it is needed for correct formatting, and I guess almost no domain role at the moment performs any real work when it is run, so this works.
We should remember this spot when we at some point overhaul intersphinx.
I am having some problems with intersphinx on the tutorial (see this thread #9424 (comment)) so I would like to know more about this feature, but I'm not sure about the status of @jakobandersen new proposal. I'd be happy to lend a hand documenting it or giving early feedback if you give me three or four examples of how would it look like in practice (is it :intersphinx:sphinx:doc: |
With this PR as it is now it would be Maybe there are too many |
I see. This is of course bikeshedding but, now that you asked, it could be |
I think this is the time to bikeshed, and we should indeed get the syntax right. Therefore, I think we must have some kind of special character in the beginning (which optionally can get escaped) to mark whether an inventory specification is present or not. I find
|
Is this PR primarily trying to resolve the confusion with overloading |
It originates from #8418 where something like |
@jakobandersen that makes sense to me. I guess One other quick thought - maybe this is technically infeasible, but rather than using the content block of the external ref to define the "intersphinx registry" to use, would it be possible to generate a role domain on-the-fly for each intersphinx mapping? e.g., it would be quite intuitive (to me) if you could do: Here's an external ref to a label :external:somedocwebsite:ref`someref`
And one to a doc :external:anotherdocwebsite:doc`somedoc` and so on. |
I wouldn't mind it being
It would indeed be prettier to have it as part of the role. It already dynamically checks for the domain role, so it could check for the inventory name as well. The icky part is that the inventory name is optional, and the domain role may be just the second component if there is a
Not sure what I think about those options yet, but if possible I think we indeed should keep the inventory out of the argument. |
+1 for |
I have made #9822 as a continuation based on the discussion. I think it is basically complete. |
Feature or Bugfix
Purpose
:intersphinx:***:
role to create a reference for external project without looking up local project.:intersphinx:py:class:`int`
Remaining Tasks