diff options
Diffstat (limited to 'tests/roots/test-util-copyasset_overwrite')
5 files changed, 31 insertions, 0 deletions
diff --git a/tests/roots/test-util-copyasset_overwrite/conf.py b/tests/roots/test-util-copyasset_overwrite/conf.py new file mode 100644 index 0000000..bb91f31 --- /dev/null +++ b/tests/roots/test-util-copyasset_overwrite/conf.py @@ -0,0 +1,7 @@ +import os +import sys +sys.path.insert(0, os.path.abspath('.')) + +extensions = ['myext'] +html_static_path = ['user_static'] +html_theme = 'basic' diff --git a/tests/roots/test-util-copyasset_overwrite/index.rst b/tests/roots/test-util-copyasset_overwrite/index.rst new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/roots/test-util-copyasset_overwrite/index.rst diff --git a/tests/roots/test-util-copyasset_overwrite/myext.py b/tests/roots/test-util-copyasset_overwrite/myext.py new file mode 100644 index 0000000..544057c --- /dev/null +++ b/tests/roots/test-util-copyasset_overwrite/myext.py @@ -0,0 +1,22 @@ +from pathlib import Path + +from sphinx.util.fileutil import copy_asset + + +def _copy_asset_overwrite_hook(app): + css = app.outdir / '_static' / 'custom-styles.css' + # html_static_path is copied by default + assert css.read_text() == '/* html_static_path */\n', 'invalid default text' + # warning generated by here + copy_asset( + Path(__file__).parent.joinpath('myext_static', 'custom-styles.css'), + app.outdir / '_static', + ) + # This demonstrates the overwriting + assert css.read_text() == '/* extension styles */\n', 'overwriting failed' + return [] + + +def setup(app): + app.connect('html-collect-pages', _copy_asset_overwrite_hook) + app.add_css_file('custom-styles.css') diff --git a/tests/roots/test-util-copyasset_overwrite/myext_static/custom-styles.css b/tests/roots/test-util-copyasset_overwrite/myext_static/custom-styles.css new file mode 100644 index 0000000..9509354 --- /dev/null +++ b/tests/roots/test-util-copyasset_overwrite/myext_static/custom-styles.css @@ -0,0 +1 @@ +/* extension styles */ diff --git a/tests/roots/test-util-copyasset_overwrite/user_static/custom-styles.css b/tests/roots/test-util-copyasset_overwrite/user_static/custom-styles.css new file mode 100644 index 0000000..1b892b9 --- /dev/null +++ b/tests/roots/test-util-copyasset_overwrite/user_static/custom-styles.css @@ -0,0 +1 @@ +/* html_static_path */ |