👌 IMPROVE: allow to specify a custom reference role for link-button#58
Open
jorisvandenbossche wants to merge 1 commit intoexecutablebooks:masterfrom
Open
Conversation
|
Thanks for submitting your first pull request! You are awesome! 🤗 |
| final_argument_whitespace = True | ||
| option_spec = { | ||
| "type": lambda arg: directives.choice(arg, ("url", "ref")), | ||
| "type": lambda arg: directives.choice(arg, ("url", "ref", "any", "doc", "std:ref")), |
Author
There was a problem hiding this comment.
This is of course not robust to list all options when going this way (as it could also be "py:func", etc), but was just for trying it out.
Member
|
Thanks @jorisvandenbossche yes sounds reasonable 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
While trying to use sphinx-panels for the pandas docs (finally .. ;)), I ran into an issue with the link-button: because it's hardcoded to use an "any" role, this can give ambiguous targets ("WARNING: more than one target found for 'any' cross-reference ...").
While in actual rst, you could use
:ref:`target`or:doc:`target`or:func:`target`, .. to be more specific.So I think it would be nice if it would be possible for
link-buttondirective to support this as well. There is already a:type:keyword (which now takes "url" or "ref"), which could be used for this. The only problem is that for backwards compatibility, "ref" should keep meaning "any", and not actually "ref". It also seems that sphinx automatically changes "ref" into "std:ref" (or this might depend on your settings, though?), and specifying "ref" as thereftypewithout a domain gives errors in sphinx. So you have to use "std:ref" as a user, unfortunately (unless there is a sphinx function we can use to resolve those).I directly made a PR instead of an issue because I was trying it out anyway if it could work, and the diff might make my question/suggestion more concrete.
If there is interest in this, I can further clean-up the PR (and add tests, etc).