POC: Add a simple Sphinx extension to support autolink issues (i.e., #123) in Sphinx
#3410
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.
GitHub can automatically convert shorthand references like
#1234into clickable links like #1234. It's very convenient that we don't have to write long Markdown links likeUnfortunately, Sphinx doesn't support shorthand references like
#1234. In Sphinx, we can use the extlinks extension to define custom roles and reference issues using such ReST syntax:issue:`1234`or MyST Markdown syntax{issue}`1234`, but it's not recognized by GitHub.Due to the above reasons, we have to configure the
change-templateof the release-drafter action to:pygmt/.github/release-drafter.yml
Line 28 in 991cafb
And in our release notes, we have full Markdown links like:
which generates long changelog entries like:
This PR adds a simple Sphinx extension (completely written by ChatGPT) to make Sphinx support shorthand references
#1234. The extension generally scans the source files, finds the shorthand references (using a regex like#(\d+), and then converts them to full Markdown links. With this extension, shorthand references will work on GitHub and in Sphinx, which can make the changelog entries much shorter and also make it easier to merge multiple entries when we manually polish the release notes.There are one related StackOverflow question and two unmaintained Sphinx extensions, which motivates me to ask ChatGPT for help:
The
doc/changes.mdare converted from full Markdown links into shorthand references, using the following Linux command:Preview: https://pygmt-dev--3410.org.readthedocs.build/en/3410/changes.html
If agreed, we still need to do:
change-templateto'* $TITLE (#$NUMBER)'