Skip to content
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

👌 IMPROVE: allow to specify a custom reference role for link-button #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jorisvandenbossche
Copy link

@jorisvandenbossche jorisvandenbossche commented Apr 8, 2021

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-button directive 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 the reftype without 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).

@welcome
Copy link

welcome bot commented Apr 8, 2021

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out EBP's Code of Conduct and our Contributing Guide, as this will greatly help the review process.

Welcome to the EBP community! 🎉

@@ -48,7 +57,7 @@ class LinkButton(SphinxDirective):
required_arguments = 1
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")),
Copy link
Author

@jorisvandenbossche jorisvandenbossche Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chrisjsewell
Copy link
Member

Thanks @jorisvandenbossche yes sounds reasonable 👍
I'll have a think about the issues you mention and get back to you (feel free to ping me if I forget lol)

@keewis keewis mentioned this pull request May 26, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants