QuantEcon / QuantEcon/quantecon-book-theme
`View Source` toolbar button renders `href="None"` on auto-generated pages (genindex, search, proof index)
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 56
- Forks
- 24
- Avg merge
- 4h 33m
- Merged PRs (30d)
- 4
Description
Summary
On Sphinx auto-generated pages (genindex.html, search.html, and the proof-domain index prf-prf.html), the "View Source" GitHub button in the toolbar renders as <a href="None" ...>, producing broken links. Regular lecture pages render correctly.
Reproducer
Build any project using this theme that has a repository_url configured and at least one prf:proof directive. Inspect the generated _build/html/genindex.html, _build/html/search.html, and _build/html/prf-prf.html — the toolbar's GitHub icon <a> has href="None".
Caught by lychee link-checker on lecture-python.myst:
```
Errors in genindex.html
- [ERROR] file:///.../None | Cannot find file: File not found.
Errors in search.html
- [ERROR] file:///.../None | Cannot find file: File not found.
Errors in prf-prf.html
- [ERROR] file:///.../None | Cannot find file: File not found.
```
Root cause
In `src/quantecon_book_theme/init.py`, `theme_repository_url` is only populated inside the `if doctree and hasattr(app.env, "doc2path"):` branch (lines ~470–472). On auto-generated pages there's no source doctree, so the `else` branches (lines 481 and 487) set `context["theme_repository_url"] = None`.
`src/quantecon_book_theme/theme/quantecon_book_theme/layout.html:399` then interpolates the value unguarded:
```jinja
Jinja stringifies Python `None` to the literal `"None"`, producing `href="None"`.
Suggested fix
Two reasonable options (either or both):
- Guard the template — match the existing `{%- if notebook_path %}` / `{%- if theme_nb_repository_url %}` pattern used a few lines above:
```jinja
{%- if theme_repository_url %} - ... {%- endif %} \`\`\`
- Populate the variable unconditionally in `init.py` — read `repository_url` from `config_theme` regardless of whether a doctree is present, so the global "View Source" link works on auto-generated pages too.
Option 1 alone removes the broken link; option 1 + 2 also keeps the button visible on auto-generated pages.
Version
Reproduced on `main` (v0.20.3); also affects v0.20.2 (deployed on lecture-python.myst).
Contributor guide
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.
Research direction
Read src/quantecon_book_theme/init.py around theme_repository_url and the View Source block in src/quantecon_book_theme/theme/quantecon_book_theme/layout.html. Build a project with repository_url and a prf:proof directive, then inspect genindex.html, search.html, and prf-prf.html. Done means those pages no longer contain href="None" and the intended View Source behavior is preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100