mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
23 lines
711 B
Python
23 lines
711 B
Python
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')
|