mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-11-02 20:30:30 -06:00
[config] copyright correction logic: handle year-to-year ranges without trailing authorship info (#11914)
This commit is contained in:
1 parent
707bfbd669
commit
8aa5edd585
2 files changed
+26
-2
No files matched your search
@@ -8,7 +8,13 @@ import pytest
|
||||
|
||||
import sphinx
|
||||
from sphinx.builders.gettext import _gettext_compact_validator
|
||||
from sphinx.config import ENUM, Config, _Opt, check_confval_types
|
||||
from sphinx.config import (
|
||||
ENUM,
|
||||
Config,
|
||||
_Opt,
|
||||
check_confval_types,
|
||||
correct_copyright_year,
|
||||
)
|
||||
from sphinx.deprecation import RemovedInSphinx90Warning
|
||||
from sphinx.errors import ConfigError, ExtensionError, VersionRequirementError
|
||||
|
||||
@@ -556,6 +562,24 @@ def test_multi_line_copyright(source_date_year, app, monkeypatch):
|
||||
) in content
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('conf_copyright', 'expected_copyright'), [
|
||||
('1970', '{current_year}'),
|
||||
# https://github.com/sphinx-doc/sphinx/issues/11913
|
||||
('1970-1990', '1970-{current_year}'),
|
||||
('1970-1990 Alice', '1970-{current_year} Alice'),
|
||||
])
|
||||
def test_correct_copyright_year(conf_copyright, expected_copyright, source_date_year):
|
||||
config = Config({}, {'copyright': conf_copyright})
|
||||
correct_copyright_year(_app=None, config=config)
|
||||
actual_copyright = config['copyright']
|
||||
|
||||
if source_date_year is None:
|
||||
expected_copyright = conf_copyright
|
||||
else:
|
||||
expected_copyright = expected_copyright.format(current_year=source_date_year)
|
||||
assert actual_copyright == expected_copyright
|
||||
|
||||
|
||||
def test_gettext_compact_command_line_true():
|
||||
config = Config({}, {'gettext_compact': '1'})
|
||||
config.add('gettext_compact', True, '', {bool, str})
|
||||
|
||||
Reference in new issue
Block a user