-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[config] Support more precise build-year copyright substitution #12451
Comments
Although I feel like I want to make adjustments here and may have ideas about how to do that, I'd appreciate input from other maintainers/developers because churn/incorrect fixes here could potentially be more disruptive than simply leaving the code-is. AFAIK we don't currently have a way for downstream projects to entirely disable the dynamic copyright substitution logic when The |
Also: maintainers: please feel free to convert this into a GitHub discussion if that's a more appropriate venue for this thread. |
I'm not convinced that my assertion that only the most-recent/last copyright line should be updated is always true. Although updating every line does seem incorrect in some situations, it seems unclear/intractable how to determine which lines to update. This could be a reason why some projects have chosen to avoid the substitution logic by using en-dash. In terms of ideas for routes towards improvements, though -- and bearing in mind that, as far as possible, we should avoid breaking existing projects: Perhaps we could provide a Projects that do want dynamic copyright notices could then use that variable in either their single-line or multi-line copyright notices, as appropriate for their use case(s). As mentioned in a previous thread I'm not too keen on dynamic copyright notices personally, but we do have practical examples of Sphinx projects that use them, and a way to retrieve the current year could help us support those cases. If I were to implement that, I'd document the substitution variable with a note to indicate that it is available for use, but not necessarily recommended. |
I'd propose a combination of two changes:
I'll attempt to draft a pull request for this soon (within the next week or two). |
Exploratory thoughts: in some ways I think that using the last-modified-time (aka (context: if we are to add Although technically feasible, I don't think that it would make sense to attempt to add code to determine whether the source files are contained in a version control system (in order to detect modification times) -- doing that would mean that we end up maintaining code to handle an arbitrary and incomplete list of version control systems. |
An incomplete, approximated code search for One reason that I checked that is to determine whether a harsher/breaking-change approach of disabling dynamic copyright notices would be acceptable. Initially I feel that it is not -- and also it would simply have the effect of pushing the problem elsewhere rather than solving it. Given that context, the current use of Possible improvements remaining in my mind:
There is also a risk of trying to be too clever and creating unnecessary complexity. |
Based on my understanding of Python: detecting statically-declared strings may be possible --we could locate and parse the
In the general case this seems intractable, because there's very little that we can infer from copyright year ranges in multiline statements. Did contributions stop because of a change of ownership? Or simply because a contributor no longer provides edits to a project? We can't know those during isolated computerized builds from source. However, it's possible that we could improve the substitution heuristics; for example: we could determine the system-clock year and only perform replacement of years in the notice that match that. The only edge case I can think of there is dynamic |
From my mental notes, three ideas remain valid, and here's how I rate them currently:
Edit: update checklist x3 |
An additional fourth idea that also remains valid:
Edit: update x2 |
Quoting from the bugreport description:
I now think that improved example/expected/actual cases -- including a delineation of static and dynamic copyright notice lines -- would be: conf.py from datetime import datetime
copyright = [
'2000-2001 - first copyright holder',
'2002-2003 - second copyright holder',
f"2003-{datetime.utcnow().strftime('%Y')} - third copyright holder",
] Expected
Actual
Or to translate into a description: try only to substitute year values in copyright notices that appear to have been calculated dynamically. |
Describe the bug
Projects can configure multiline copyright notices (ref #4925), a useful feature for projects that have transitions between copyright holders over time.
However, the current config year-substitution logic enabled when
SOURCE_DATE_EPOCH
is configured will attempt to pattern-match and substitute the end-year from the build-year in all of the copyright lines.I'm not sure that's intended; I think that we should only apply the substitution for the most recent (which for an iterable I suppose means the final) line in the notice.
How to Reproduce
conf.py
index.rst
Expected
Actual
Environment Information
Sphinx extensions
Additional context
Discovered while investigating whether multiline copyright config could be a way to reduce risk of rewriting unintended copyright lines re: any interaction between matplotlib/matplotlib#28418 and #12450.
The text was updated successfully, but these errors were encountered: