Skip to content

Normalize the changelog style and introduce sphinx extlink roles #2202

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

Merged
merged 4 commits into from
Jul 15, 2025

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Jul 13, 2025

This is an early preparatory move for using towncrier.
Configuring it well (e.g., as in cheroot) will probably involve integrating these link styles into our templates, which we can only do if we have these link styles available.


This change is broken into two commits.

The first is the addition of sphinx.ext.extlinks + config + an automated rewrite of the changelog to normalize a lot of
stylistic elements and use {issue}123 style and similar.

The second is a "manual fixup" (mostly done with editor commands and a bit of manual review) and is separated out to make the changes more visible in review.
The goal here is just to get some stylistic uniformity, especially for the really old changelog entries, so that editor highlighting won't be confused and we'll have a clearer claim to a consistent style.

In this phase, I'm more interested in having a consistent style than in exactly what that style is.
I can make small adjustments if anything is objectionable, but I'd rather save further rewrites (e.g., "should we replace those Thanks $USER lines with an AUTHORS file?") for future discussion and debate.


For review of how this renders, here's the result before and after on two different chunks of the changelog:

description before after
latest versions image image
very old versions image image
Contributor checklist
  • Included tests for the changes. N/A
  • PR title is short, clear, and ready to be included in the user-facing changelog.
Maintainer checklist
  • Verified one of these labels is present: backwards incompatible, feature, enhancement, deprecation, bug, dependency, docs or skip-changelog as they determine changelog listing.
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

sirosen added 2 commits July 12, 2025 20:19
This changes the link format and does some regex-based rewriting of
the changelog to try to normalize the format a bit.

The conversion script was:

```python
import re

with open("CHANGELOG.md") as f:
    content = f.read()

issue_link_pattern = re.compile(
    r"\[#(\d+)]\(https://github.com/jazzband/pip-tools/issues/(\d+)\)"
)
pr_link_pattern = re.compile(
    r"\[#(\d+)]\(https://github.com/jazzband/pip-tools/pull/(\d+)\)"
)
user_thanks_pattern = re.compile(r"Thanks(\s+)@([\w-]+)")
user_ref_pattern = re.compile(r"(\s+)@([\w-]+)")
date_pattern = re.compile(
    r"^(\d{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4})$",
    flags=re.MULTILINE,
)

redent_user_thanks_pattern = re.compile(r"([^\s]) Thanks {user}")
trim_newline_link_pattern = re.compile("\n\\s+(\\({(pr|issue)}`\\d+`\\)\\.?)\n")

content = issue_link_pattern.sub(r"{issue}`\1`", content)
content = pr_link_pattern.sub(r"{pr}`\1`", content)
content = user_thanks_pattern.sub(r"Thanks {user}`\2`", content)
content = user_ref_pattern.sub(r"\1{user}`\2`", content)
content = redent_user_thanks_pattern.sub("\\1\n  Thanks {user}", content)
content = trim_newline_link_pattern.sub(" \\1\n", content)
content = date_pattern.sub(r"*\1*", content)

with open("NEW_CHANGELOG.md", "w") as f:
    f.write(content)
```
- put backticks around commands, flags, and command fragments (e.g.,
  filenames)
- fix PR and issue links not previously captured
- normalize the "Thanks" line style -- no trailing period, no extra
  words
@sirosen sirosen added this to the 7.5.0 milestone Jul 13, 2025
@sirosen sirosen added the skip-changelog Avoid listing in changelog label Jul 13, 2025
@webknjaz
Copy link
Member

@sirosen could you integrate sphinx-issues instead? I'm replacing the extlinks copy-paste everywhere but sometimes, there's leftovers.

@sirosen
Copy link
Member Author

sirosen commented Jul 13, 2025

Yep, happily done! I like sphinx-issues but I saw you had done the same with extlinks and was just trying to keep things in sync. 😄

Looks like the linkcheck lint is bothered by routing through the sponsors redirects, but that should be easy to handle with linkcheck_allowed_redirects. I'm doing that right now.

@sirosen
Copy link
Member Author

sirosen commented Jul 14, 2025

Ah, I tried fixing the redirects and now I get rate limited by GitHub (which is fair!); I see other projects are just skipping validation of the GitHub links and I'll configure the same for us.

@webknjaz
Copy link
Member

Yeah, I've actually put sphinx-issues into the towncrier issue, but it's the last item in there 😂

sirosen and others added 2 commits July 14, 2025 10:23
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
These links are too numerous in the changelog and result in rate
limiting when `linkcheck` is run.

Also, several users have changed their usernames in the years since
their contributions, so checking those links fails. (And although we
could update old changelog items, it's not clear that we should.)
@sirosen sirosen force-pushed the use-sphinx-issue-roles branch from 14c8c91 to e072fb9 Compare July 14, 2025 15:23
@sirosen sirosen added this pull request to the merge queue Jul 15, 2025
Merged via the queue into jazzband:main with commit 6a12714 Jul 15, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Avoid listing in changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants