Mention dynamically-evaluated templates whilst copying static files (#12726)

This commit is contained in:
James Addison
2024-08-11 16:37:41 +01:00
committed by GitHub
parent 4cf8f7a093
commit 999baca135
4 changed files with 17 additions and 2 deletions

View File

@@ -16,6 +16,9 @@ Deprecated
Features added
--------------
* #11328: Mention evaluation of templated content during production of static
output files.
Bugs fixed
----------

View File

@@ -908,7 +908,7 @@ class StandaloneHTMLBuilder(Builder):
def copy_static_files(self) -> None:
try:
with progress_message(__('copying static files')):
with progress_message(__('copying static files'), nonl=False):
ensuredir(self.outdir / '_static')
# prepare context for templates
@@ -929,7 +929,7 @@ class StandaloneHTMLBuilder(Builder):
def copy_extra_files(self) -> None:
"""Copy html_extra_path files."""
try:
with progress_message(__('copying extra files')):
with progress_message(__('copying extra files'), nonl=False):
excluded = Matcher(self.config.exclude_patterns)
for extra_path in self.config.html_extra_path:
copy_asset(

View File

@@ -81,6 +81,9 @@ def copy_asset_file(source: str | os.PathLike[str], destination: str | os.PathLi
destination = _template_basename(destination) or destination
with open(destination, 'w', encoding='utf-8') as fdst:
msg = __('Writing evaluated template result to %s')
logger.info(msg, os.fsdecode(destination), type='misc',
subtype='template_evaluation')
fdst.write(rendered_template)
else:
copyfile(source, destination, force=force)

View File

@@ -1,5 +1,6 @@
"""Tests sphinx.util.fileutil functions."""
import re
from unittest import mock
import pytest
@@ -119,6 +120,14 @@ def test_copy_asset(tmp_path):
assert not (destdir / '_templates' / 'sidebar.html').exists()
@pytest.mark.sphinx('html', testroot='html_assets')
def test_copy_asset_template(app):
app.build(force_all=True)
expected_msg = r"^Writing evaluated template result to [^\n]*\bAPI.html$"
assert re.findall(expected_msg, strip_colors(app.status.getvalue()), flags=re.MULTILINE)
@pytest.mark.sphinx('html', testroot='util-copyasset_overwrite')
def test_copy_asset_overwrite(app):
app.build()