mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Restore support for YYYY copyright lines
This commit is contained in:
parent
2730cc3353
commit
2a631f97ef
2
CHANGES
2
CHANGES
@ -32,6 +32,8 @@ Bugs fixed
|
||||
the :dudir:`include` directive.
|
||||
* 11620: Add a new :event:`include-read` for observing and transforming
|
||||
the content of included files via the :dudir:`include` directive.
|
||||
* #11627: Restore support for copyright lines of the form ``YYYY``
|
||||
when ``SOURCE_DATE_EPOCH`` is set.
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
@ -446,6 +446,7 @@ def _substitute_copyright_year(copyright_line: str, replace_year: str) -> str:
|
||||
|
||||
Legal formats are:
|
||||
|
||||
* ``YYYY``
|
||||
* ``YYYY,``
|
||||
* ``YYYY ``
|
||||
* ``YYYY-YYYY,``
|
||||
@ -453,10 +454,10 @@ def _substitute_copyright_year(copyright_line: str, replace_year: str) -> str:
|
||||
|
||||
The final year in the string is replaced with ``replace_year``.
|
||||
"""
|
||||
if not copyright_line[:4].isdigit():
|
||||
if len(copyright_line) < 4 or not copyright_line[:4].isdigit():
|
||||
return copyright_line
|
||||
|
||||
if copyright_line[4] in ' ,':
|
||||
if copyright_line[4:5] in {'', ' ', ','}:
|
||||
return replace_year + copyright_line[4:]
|
||||
|
||||
if copyright_line[4] != '-':
|
||||
|
@ -1,4 +1,5 @@
|
||||
copyright = (
|
||||
'2006',
|
||||
'2006-2009, Alice',
|
||||
'2010-2013, Bob',
|
||||
'2014-2017, Charlie',
|
||||
|
@ -471,6 +471,7 @@ def test_multi_line_copyright(source_date_year, app, monkeypatch):
|
||||
|
||||
if source_date_year is None:
|
||||
# check the copyright footer line by line (empty lines ignored)
|
||||
assert ' © Copyright 2006.<br/>\n' in content
|
||||
assert ' © Copyright 2006-2009, Alice.<br/>\n' in content
|
||||
assert ' © Copyright 2010-2013, Bob.<br/>\n' in content
|
||||
assert ' © Copyright 2014-2017, Charlie.<br/>\n' in content
|
||||
@ -479,6 +480,8 @@ def test_multi_line_copyright(source_date_year, app, monkeypatch):
|
||||
|
||||
# check the raw copyright footer block (empty lines included)
|
||||
assert (
|
||||
' © Copyright 2006.<br/>\n'
|
||||
' \n'
|
||||
' © Copyright 2006-2009, Alice.<br/>\n'
|
||||
' \n'
|
||||
' © Copyright 2010-2013, Bob.<br/>\n'
|
||||
@ -491,6 +494,7 @@ def test_multi_line_copyright(source_date_year, app, monkeypatch):
|
||||
) in content
|
||||
else:
|
||||
# check the copyright footer line by line (empty lines ignored)
|
||||
assert f' © Copyright {source_date_year}.<br/>\n' in content
|
||||
assert f' © Copyright 2006-{source_date_year}, Alice.<br/>\n' in content
|
||||
assert f' © Copyright 2010-{source_date_year}, Bob.<br/>\n' in content
|
||||
assert f' © Copyright 2014-{source_date_year}, Charlie.<br/>\n' in content
|
||||
@ -499,6 +503,8 @@ def test_multi_line_copyright(source_date_year, app, monkeypatch):
|
||||
|
||||
# check the raw copyright footer block (empty lines included)
|
||||
assert (
|
||||
f' © Copyright {source_date_year}.<br/>\n'
|
||||
f' \n'
|
||||
f' © Copyright 2006-{source_date_year}, Alice.<br/>\n'
|
||||
f' \n'
|
||||
f' © Copyright 2010-{source_date_year}, Bob.<br/>\n'
|
||||
|
Loading…
Reference in New Issue
Block a user