Skip to content

Commit 999baca

Browse files
authored
Mention dynamically-evaluated templates whilst copying static files (#12726)
1 parent 4cf8f7a commit 999baca

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Deprecated
1616
Features added
1717
--------------
1818

19+
* #11328: Mention evaluation of templated content during production of static
20+
output files.
21+
1922
Bugs fixed
2023
----------
2124

sphinx/builders/html/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ def copy_html_favicon(self) -> None:
908908

909909
def copy_static_files(self) -> None:
910910
try:
911-
with progress_message(__('copying static files')):
911+
with progress_message(__('copying static files'), nonl=False):
912912
ensuredir(self.outdir / '_static')
913913

914914
# prepare context for templates
@@ -929,7 +929,7 @@ def copy_static_files(self) -> None:
929929
def copy_extra_files(self) -> None:
930930
"""Copy html_extra_path files."""
931931
try:
932-
with progress_message(__('copying extra files')):
932+
with progress_message(__('copying extra files'), nonl=False):
933933
excluded = Matcher(self.config.exclude_patterns)
934934
for extra_path in self.config.html_extra_path:
935935
copy_asset(

sphinx/util/fileutil.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def copy_asset_file(source: str | os.PathLike[str], destination: str | os.PathLi
8181

8282
destination = _template_basename(destination) or destination
8383
with open(destination, 'w', encoding='utf-8') as fdst:
84+
msg = __('Writing evaluated template result to %s')
85+
logger.info(msg, os.fsdecode(destination), type='misc',
86+
subtype='template_evaluation')
8487
fdst.write(rendered_template)
8588
else:
8689
copyfile(source, destination, force=force)

tests/test_util/test_util_fileutil.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests sphinx.util.fileutil functions."""
22

3+
import re
34
from unittest import mock
45

56
import pytest
@@ -119,6 +120,14 @@ def excluded(path):
119120
assert not (destdir / '_templates' / 'sidebar.html').exists()
120121

121122

123+
@pytest.mark.sphinx('html', testroot='html_assets')
124+
def test_copy_asset_template(app):
125+
app.build(force_all=True)
126+
127+
expected_msg = r"^Writing evaluated template result to [^\n]*\bAPI.html$"
128+
assert re.findall(expected_msg, strip_colors(app.status.getvalue()), flags=re.MULTILINE)
129+
130+
122131
@pytest.mark.sphinx('html', testroot='util-copyasset_overwrite')
123132
def test_copy_asset_overwrite(app):
124133
app.build()

0 commit comments

Comments
 (0)