pydata-sphinx-theme icon indicating copy to clipboard operation
pydata-sphinx-theme copied to clipboard

ENH: Automatically shorten links for GitHub/GitLab

Open 12rambau opened this issue 3 years ago • 3 comments

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 avatar Sep 28 '22 11:09 12rambau

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

choldgraf avatar Sep 28 '22 14:09 choldgraf

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

12rambau avatar Sep 28 '22 14:09 12rambau

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

12rambau avatar Sep 28 '22 16:09 12rambau