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

ENH: Automatically shorten links for GitHub/GitLab #957

Merged
merged 24 commits into from Sep 30, 2022

Conversation

12rambau
Copy link
Collaborator

@12rambau 12rambau commented Sep 28, 2022

Fixes #841

I discover that Sphinx is already doing the same kind of operation for kbd Litteral nodes: https://github.com/sphinx-doc/sphinx/blob/5.x/sphinx/builders/html/transforms.py

So I adapted the code to read all the links on the pages (reference nodes). I'm taking the one from GitHub and GitLab at the moment and I'm shortening them using the same structure as the GitHub one i.e. <username>/<repository>#<id>. If some parameters are missing I just drop it.

I added an example here: https://pydata-sphinx-theme--957.org.readthedocs.build/en/957/user_guide/theme-elements.html#link-shortening

let me know what you think!

@12rambau 12rambau marked this pull request as draft September 28, 2022 11:33
@12rambau 12rambau marked this pull request as ready for review September 28, 2022 12:26
@choldgraf choldgraf changed the title Links ENH: Automatically shorten links for GitHub/GitLab Sep 28, 2022
@choldgraf
Copy link
Collaborator

I think this is pretty cool! +1 on the functionality from me but I haven't given the code a deep look.

@12rambau
Copy link
Collaborator Author

I'm trying to fix the codecov tests sorry for the noise

@12rambau
Copy link
Collaborator Author

@choldgraf, it's done the PR is ready for review

Copy link
Collaborator

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

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

A few quick comments but this looks good to me!

docs/user_guide/theme-elements.md Outdated Show resolved Hide resolved
docs/user_guide/theme-elements.md Outdated Show resolved Hide resolved
src/pydata_sphinx_theme/__init__.py Outdated Show resolved Hide resolved
src/pydata_sphinx_theme/__init__.py Show resolved Hide resolved
src/pydata_sphinx_theme/__init__.py Outdated Show resolved Hide resolved
src/pydata_sphinx_theme/assets/styles/base/_base.scss Outdated Show resolved Hide resolved
12rambau and others added 6 commits September 29, 2022 21:17
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
@12rambau 12rambau merged commit 959042d into pydata:main Sep 30, 2022
@12rambau 12rambau deleted the links branch September 30, 2022 09:24
@jarrodmillman jarrodmillman added this to the 0.11 milestone Oct 5, 2022
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.

Replace external links to GitHub and GitLab with shortened links
3 participants