This issue is a result of a Codex global code scan of deepmodeling/deepmodeling_sphinx at commit 156679f.
Problem
When enable_deepmodeling = False and html_theme = "sphinx_rtd_theme", the extension still registers dark_rtd.css, but copy_custom_files() returns before copying package assets. The generated HTML can reference _static/dark_rtd.css even though the file is absent.
Code references:
|
def copy_custom_files(app): |
|
if not app.config.enable_deepmodeling: |
|
return |
|
if app.builder.format == "html": |
|
staticdir = os.path.join(app.builder.outdir, "_static") |
|
cwd = Path(__file__).parent.absolute() |
|
banner_css = cwd / "banner.css" |
|
banner_js = cwd / "banner.js" |
|
dark_css = cwd / "dark_rtd.css" |
|
os.makedirs(staticdir, exist_ok=True) |
|
staticdir = os.path.join(app.builder.outdir, "_static") |
|
copy_asset_file(str(banner_css), staticdir) |
|
copy_asset_file(str(banner_js), staticdir) |
|
copy_asset_file(str(dark_css), staticdir) |
|
def enable_dark_mode(app, config): |
|
"""Enable dark mode if the theme is sphinx_rtd_theme.""" |
|
if config.html_theme == "sphinx_rtd_theme": |
|
app.add_css_file("dark_rtd.css") |
Reproduction
Use a minimal Sphinx project with:
extensions = ["deepmodeling_sphinx"]
html_theme = "sphinx_rtd_theme"
enable_deepmodeling = False
The generated page includes _static/dark_rtd.css, but _static/dark_rtd.css is not copied to the output directory.
Impact
Projects that disable DeepModeling-specific banner styling can still emit a broken stylesheet reference when using the RTD theme.
Suggested fix
Either skip app.add_css_file("dark_rtd.css") when enable_deepmodeling is false, or copy dark_rtd.css independently from the banner assets.
This issue is a result of a Codex global code scan of deepmodeling/deepmodeling_sphinx at commit 156679f.
Problem
When
enable_deepmodeling = Falseandhtml_theme = "sphinx_rtd_theme", the extension still registersdark_rtd.css, butcopy_custom_files()returns before copying package assets. The generated HTML can reference_static/dark_rtd.csseven though the file is absent.Code references:
deepmodeling_sphinx/deepmodeling_sphinx/inject.py
Lines 38 to 51 in 156679f
deepmodeling_sphinx/deepmodeling_sphinx/inject.py
Lines 174 to 177 in 156679f
Reproduction
Use a minimal Sphinx project with:
The generated page includes
_static/dark_rtd.css, but_static/dark_rtd.cssis not copied to the output directory.Impact
Projects that disable DeepModeling-specific banner styling can still emit a broken stylesheet reference when using the RTD theme.
Suggested fix
Either skip
app.add_css_file("dark_rtd.css")whenenable_deepmodelingis false, or copydark_rtd.cssindependently from the banner assets.