Skip to content

Comments

Make icon links and link shortening optional#2109

Merged
drammock merged 9 commits intopydata:mainfrom
westurner:make_icon_links_optional
Sep 28, 2025
Merged

Make icon links and link shortening optional#2109
drammock merged 9 commits intopydata:mainfrom
westurner:make_icon_links_optional

Conversation

@westurner
Copy link
Contributor

@westurner westurner commented Jan 27, 2025

Backwards compatible:

Not backwards compatible:

@westurner westurner changed the title Make icon links optional Make icon links and link shortening optional Jan 27, 2025
f"type {type(theme_options.get('icon_links'))}."
)
if theme_options.get("icon_links") is not None:
if not isinstance(theme_options.get("icon_links", []), list):
Copy link
Member

@drammock drammock Jan 27, 2025

Choose a reason for hiding this comment

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

I can see why on current main, setting icon_links = None in your conf.py would cause an error here. But if you don't want icon links, why not just leave icon_links undefined? Genuinely curious if there's a reason you need this.

},
)
if icon_links is not None:
for url, icon, name in shortcuts:
Copy link
Member

Choose a reason for hiding this comment

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

same question as above: the code on main is fine if icon_links is not defined, it only errors if you explicitly set icon_links=None in the html_theme_options dictionary of conf.py. So why do that?

@trallard
Copy link
Collaborator

Hey @westurner. This PR has been open for a while. I was wondering if you could get it over the finish line or if we should see if someone in the PST team can help get this wrapped up?

Thanks for your contribution 🌻

@trallard trallard added the kind: enhancement New feature or request label Mar 27, 2025
@trallard trallard added this to the 0.17.0 milestone Mar 27, 2025
@westurner
Copy link
Contributor Author

Sorry, I don't mean to block. Anyone is welcome to take this

@trallard
Copy link
Collaborator

Not a problem at all. I only wanted to check if you were planning to keep on working on this or if you needed some help.
Thanks for getting back to us.

@gabalafou
Copy link
Collaborator

Hey @drammock, I pushed some commits to this PR to address your previous review.

I poked around a bit at this PR, played with it against a personal Sphinx project, and like you, I couldn't find a good use case for handling icon_links = None, so I reverted that commit and made the exception message a bit more detailed.

@gabalafou gabalafou requested a review from drammock June 17, 2025 18:52
drammock
drammock previously approved these changes Jun 18, 2025
Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

looks reasonable. Would be good to have a test that disables link shortening, and confirm that the link is untouched.

Co-authored-by: Daniel McCloy <dan@mccloy.info>
@gabalafou
Copy link
Collaborator

Good idea, I'll add a test

Copy link
Collaborator

@gabalafou gabalafou left a comment

Choose a reason for hiding this comment

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

Tests are passing, this should be ready for review now

"""Regression test for "edit on <provider>" link shortening."""
sphinx_build = sphinx_build_factory("base").build()
confoverrides = {
"html_theme_options": {"shorten_urls": True},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not 100% sure why the default value in theme.conf isn't picked up by the test build process, but being forced to set shorten_urls to true also makes the setting more explicity.

@drammock drammock merged commit 469e908 into pydata:main Sep 28, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants