Automatically add dates to release notes#8001
Conversation
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
|
Wooo ✨ I was thinking about adding dates there too recently so, thank you! |
|
Thanks for looping me in.
Perfectly fine.
I'd be open to extending rst.linker if that makes sense... or even just exposing some of the functions for customized re-use. No obligation, though.
Minor correction - it creates a new file
I made this choice intentionally in order for the anchors to be predictable (#v69-5-1). With dates in the title, the anchors will include the dates. That's also why I use |
Thanks, I think the end result here is quite compact.
Ah right, it was just my hacky WIP when I first looked at modifying it :)
Thanks for pointing that out. Yeah, that definitely makes sense for https://setuptools.pypa.io/en/stable/history.html#v65-6-1, and doesn't really matter for https://pillow.readthedocs.io/en/stable/releasenotes/9.4.0.html. |
| cmd = ["git", "log", "-1", "--format=%ai", git_version] | ||
| try: | ||
| out = subprocess.check_output( | ||
| cmd, stderr=subprocess.DEVNULL, text=True, encoding="utf-8" |
There was a problem hiding this comment.
Why are both text and encoding used? From testing locally and from the docs, I would think only one is necessary.
https://docs.python.org/3/library/subprocess.html
If encoding or errors are specified, or text is true, file objects for stdin, stdout and stderr are opened in text mode using the specified encoding and errors or the io.TextIOWrapper default.
There was a problem hiding this comment.
Funny story - originally, only text=True was used. Then later, when PEP 597 introduce encoding warnings when the encoding wasn't specified, indicated to include the encoding. Eventually, the need for encoding= will be once again unnecessary (python 3.14 maybe), so we'll want to fall back to text=, but until then, both are there. Maybe text= could be removed in the interim, but I'm kind-of inclined to leave it there as it's the primary signal.
nulano
left a comment
There was a problem hiding this comment.
Looks good, and even works out-of-the-box on Windows (at least on my system)!
Use split instead of datetime
This adds a small Sphinx extension to add the date to the titles of the release notes, both on the page and tables of contents.
I based this on @jaraco's nifty https://github.com/jaraco/rst.linker, and I've added you as co-author on the commit, hope that's okay?
This PR works by getting the title of pages matching
releasenotes/\d+\.\d+\.\d+", then looking up the timestamp from agit logcall, and then adds "(yyyy-mm-dd)" to the title.There's some things in rst.linker which make it not suitable to use here, and I think it might not be worth generalising it further:
filename (files).rstand deletes the originalfilename.rst.rstfiles, rather than the source outputSome notes:
I don't think these are problems? For forks,
git fetch upstream --tagswill grab them all; I added it to Read the Docs for forks builds. For sdist builds, we could return early if a.gitdirectory is absent.