[Code scan] Avoid mutating the global sitemap while rendering the banner
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- documentation
Research direction
Read deepmodeling_sphinx/config.py and deepmodeling_sphinx/inject.py, then run the issue's two-call render_banner reproduction. Ensure active state is isolated to each render so rendering Docs followed by Blog leaves only Blog active, without mutating the module-level sitemap.
Written by the indexing model from the issue text.
Description
This issue is a result of a Codex global code scan of deepmodeling/deepmodeling_sphinx at commit 156679fe55fc61e8ec3b1e9be8a45fde3567b9cb.
Problem
render_banner() writes the active CSS class directly into the module-level sitemap. The mutation persists across subsequent calls, so rendering one site as active and then rendering another can leave multiple navigation items marked active.
Code references:
https://github.com/deepmodeling/deepmodeling_sphinx/blob/156679fe55fc61e8ec3b1e9be8a45fde3567b9cb/deepmodeling_sphinx/config.py#L1-L33
https://github.com/deepmodeling/deepmodeling_sphinx/blob/156679fe55fc61e8ec3b1e9be8a45fde3567b9cb/deepmodeling_sphinx/inject.py#L16-L35
Reproduction
from deepmodeling_sphinx.inject import render_banner
from deepmodeling_sphinx.config import sitemap
render_banner("Docs")
render_banner("Blog")
print([(item["title"], item.get("class")) for item in sitemap if item.get("class")])
The output includes both Docs and Blog with active docs-active.
Impact
Repeated in-process builds, tests, or custom integrations that render the banner with different deepmodeling_current_site values can leak active state between renders.
Suggested fix
Build a per-render copy of the sitemap and assign active state on that copy, or compute the class in the Jinja template without mutating shared module state.
- Dominant language
- CSS
- Stars
- 2
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from deepmodeling/deepmodeling_sphinx
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
All issues in deepmodeling/deepmodeling_sphinx
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·