Skip to content

Commit 559a3f9

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
pull
2 parents 324d52f + 8a257fc commit 559a3f9

File tree

4 files changed

+245
-80
lines changed

4 files changed

+245
-80
lines changed

doc/usage/restructuredtext/roles.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ different style:
240240
:rst:role:`code` role instead.
241241

242242
.. versionchanged:: 1.8
243-
Allowed to escape curly braces with backslash
243+
Allowed to escape curly braces with double backslash. For example, in
244+
``:samp:`print(f"answer=\\{1+{variable}*2\\}")```, the part ``variable``
245+
would be emphasized and the escaped curly braces would be displayed:
246+
:samp:`print(f"answer=\\{1+{variable}*2\\}")`
244247

245248
There is also an :rst:role:`index` role to generate index entries.
246249

@@ -273,7 +276,7 @@ the standard reST markup for that purpose.
273276
Substitutions
274277
-------------
275278

276-
The documentation system provides three substitutions that are defined by
279+
The documentation system provides some substitutions that are defined by
277280
default. They are set in the build configuration file.
278281

279282
.. describe:: |release|

sphinx/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def _substitute_copyright_year(copyright_line: str, replace_year: str) -> str:
610610
if copyright_line[4] != '-':
611611
return copyright_line
612612

613-
if copyright_line[5:9].isdigit() and copyright_line[9] in ' ,':
613+
if copyright_line[5:9].isdigit() and copyright_line[9:10] in {'', ' ', ','}:
614614
return copyright_line[:5] + replace_year + copyright_line[9:]
615615

616616
return copyright_line

tests/test_config/test_config.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
import sphinx
1010
from sphinx.builders.gettext import _gettext_compact_validator
11-
from sphinx.config import ENUM, Config, _Opt, check_confval_types
11+
from sphinx.config import (
12+
ENUM,
13+
Config,
14+
_Opt,
15+
check_confval_types,
16+
correct_copyright_year,
17+
)
1218
from sphinx.deprecation import RemovedInSphinx90Warning
1319
from sphinx.errors import ConfigError, ExtensionError, VersionRequirementError
1420

@@ -556,6 +562,24 @@ def test_multi_line_copyright(source_date_year, app, monkeypatch):
556562
) in content
557563

558564

565+
@pytest.mark.parametrize(('conf_copyright', 'expected_copyright'), [
566+
('1970', '{current_year}'),
567+
# https://github.com/sphinx-doc/sphinx/issues/11913
568+
('1970-1990', '1970-{current_year}'),
569+
('1970-1990 Alice', '1970-{current_year} Alice'),
570+
])
571+
def test_correct_copyright_year(conf_copyright, expected_copyright, source_date_year):
572+
config = Config({}, {'copyright': conf_copyright})
573+
correct_copyright_year(_app=None, config=config)
574+
actual_copyright = config['copyright']
575+
576+
if source_date_year is None:
577+
expected_copyright = conf_copyright
578+
else:
579+
expected_copyright = expected_copyright.format(current_year=source_date_year)
580+
assert actual_copyright == expected_copyright
581+
582+
559583
def test_gettext_compact_command_line_true():
560584
config = Config({}, {'gettext_compact': '1'})
561585
config.add('gettext_compact', True, '', {bool, str})

0 commit comments

Comments
 (0)