[Code scan] Avoid mutating the global sitemap while rendering the banner

Open Beginner friendly
#86 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from deepmodeling/deepmodeling_sphinx

All issues in deepmodeling/deepmodeling_sphinx

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.