This issue is a result of a Codex global code scan of deepmodeling/deepmodeling_sphinx at commit 156679f.
Problem
The extension advertises that it adds the ICP number to the footer, but the generic injection path only searches for a literal </footer> tag. Themes such as Alabaster render the footer as a <div class="footer">...</div> instead, so no ICP number is inserted.
Code references:
|
## Features |
|
|
|
- Add the DeepModeling banner |
|
- Add the ICP number to the footer |
|
- Minify HTML, Javascript, and CSS files |
|
- Supports dark mode for both the banner and the RTD theme |
|
def insert_icp(app, pagename, templatename, context, doctree): |
|
if not app.config.enable_deepmodeling: |
|
return |
|
if app.config.html_theme == "sphinx_book_theme": |
|
# sphinx_book_theme has provided the option, so there is no need to hack |
|
return |
|
if not hasattr(app.builder.templates.render, "_deepmodeling_icp_patched"): |
|
old_render = app.builder.templates.render |
|
|
|
def render(self, template, render_context): |
|
content = old_render(template, render_context) |
|
comment_begin = r"<!--deepmodeling icp begin-->" |
|
comment_end = r"<!--deepmodeling icp end-->" |
|
if comment_begin in content: |
|
return content |
|
footer = content.lower().rfind("</footer>") |
|
icp_footer = ( |
|
'<p><a href="https://beian.miit.gov.cn" target="_blank">%s</a></p>' |
|
% icp_no |
|
) |
|
if footer != -1: |
|
content = ( |
|
content[:footer] |
|
+ comment_begin |
|
+ icp_footer |
|
+ comment_end |
|
+ content[footer:] |
|
) |
|
return content |
|
def sphinx_book_theme(app, config): |
|
"""Set configurations for sphinx_book_theme.""" |
|
if not config.enable_deepmodeling: |
|
return |
|
if config.html_theme != "sphinx_book_theme": |
|
return |
|
icp_footer = ( |
|
'<p><a href="https://beian.miit.gov.cn" target="_blank">%s</a></p>' % icp_no |
|
) |
|
config.html_theme_options["extra_footer"] = ( |
|
config.html_theme_options.get("extra_footer", "") + icp_footer |
|
) |
Reproduction
Build a minimal Sphinx project with html_theme = "alabaster" and extensions = ["deepmodeling_sphinx"]. The generated HTML has <div class=footer>..., but no 京ICP备20010051号-8 text is inserted.
Impact
Projects using supported Sphinx themes that do not emit a semantic <footer> element miss a documented compliance/footer feature.
Suggested fix
Prefer theme-supported footer APIs where available, or support common footer containers in addition to the literal </footer> tag. A parser-based insertion path would also avoid relying on brittle string matching.
This issue is a result of a Codex global code scan of deepmodeling/deepmodeling_sphinx at commit 156679f.
Problem
The extension advertises that it adds the ICP number to the footer, but the generic injection path only searches for a literal
</footer>tag. Themes such as Alabaster render the footer as a<div class="footer">...</div>instead, so no ICP number is inserted.Code references:
deepmodeling_sphinx/README.md
Lines 8 to 13 in 156679f
deepmodeling_sphinx/deepmodeling_sphinx/inject.py
Lines 85 to 113 in 156679f
deepmodeling_sphinx/deepmodeling_sphinx/inject.py
Lines 194 to 205 in 156679f
Reproduction
Build a minimal Sphinx project with
html_theme = "alabaster"andextensions = ["deepmodeling_sphinx"]. The generated HTML has<div class=footer>..., but no京ICP备20010051号-8text is inserted.Impact
Projects using supported Sphinx themes that do not emit a semantic
<footer>element miss a documented compliance/footer feature.Suggested fix
Prefer theme-supported footer APIs where available, or support common footer containers in addition to the literal
</footer>tag. A parser-based insertion path would also avoid relying on brittle string matching.