Fix empty index in PDF docs for both developer and scripting manuals#317
Merged
Fix empty index in PDF docs for both developer and scripting manuals#317
Conversation
…tex section to scripting/scrpt-indices.rst, suppress auto printindex in conf.py Co-authored-by: briantoby <9433704+briantoby@users.noreply.github.com> Agent-Logs-Url: https://github.com/AdvancedPhotonSource/GSAS-II/sessions/1c45d811-b476-4c2b-9e8c-deba32cb152d
Copilot
AI
changed the title
[WIP] Fix Read the Docs PDF output to include non-empty index
Fix empty index in PDF docs for both developer and scripting manuals
Mar 23, 2026
briantoby
approved these changes
Mar 23, 2026
Collaborator
briantoby
left a comment
There was a problem hiding this comment.
this looks fine. Advancing to Python 3.13 while making changes
Copilot stopped work on behalf of
briantoby due to an error
March 23, 2026 21:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PDF builds on Read the Docs produced an empty index. In
docs/source/indices.rst, a\renewcommand{\printindex}block redefined\printindexto call itself recursively, causing LaTeX to produce nothing when Sphinx invoked it at document end. The scripting docs had no LaTeX index section at all.Changes
docs/source/indices.rst: Replace broken recursive\renewcommand{\printindex}{...}with a direct\printindexcall inside a.. only:: latexblock.docs/scripting/scrpt-indices.rst: Add a.. only:: latexblock with an "Index" heading and\printindex(was missing entirely).docs/source/conf.pyanddocs/scripting/conf.py: Add'printindex': ''tolatex_elementsto suppress Sphinx's auto-appended\printindex, avoiding a duplicate index.The
.. only:: latexblocks are invisible to HTML builds, so HTML output is unchanged.Original prompt
Create a pull request in
AdvancedPhotonSource/GSAS-IIthat fixes the Read the Docs PDF output so the generated PDF includes a non-empty index.Context:
dfeda4e77597363ddc5de2f425dedf4d86f96e45):docs/source/conf.pydocs/source/index.rstdocs/scripting/conf.pydocs/scripting/index.rstWhat to do:
genindex) in the PDF output.docs/source/*) and the scripting docs (docs/scripting/*) if both are built on RTD.genindexonly inside.. only:: htmlblocks; it must be included for LaTeX output.genindexprintindexis not suppressed bylatex_elementsgenindex.rstwrapper page (if needed for consistent inclusion)Deliverables:
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: The sphinx docs generated on Readthedocs have an index as html pages (https://gsas-ii.readthedocs.io/en/latest/) but in the .pdf version of the docs (https://gsas-ii.readthedocs.io/_/downloads/en/latest/pdf/) the index is empty. How do I get an index in the.pdf as well?
Assistant: To get an index in the PDF, you need to (1) ensure Sphinx generates a LaTeX index and (2) ensure the “Index” page is actually included in the LaTeX/PDF build.
On Read the Docs, the HTML “Index” you see is the
genindexpage. The PDF won’t automatically include that unless your LaTeX build is configured to generate/print it.1) Add
genindexto your master toctree (so it’s included in LaTeX/PDF)In your Sphinx root document (often
index.rst, sometimescontents.rstdepending onroot_doc/master_doc), addgenindexto a toctree that’s included in the build:This works because
genindexis a built-in Sphinx “special document” you can reference from atoctree. (sphinx-doc.org)If you don’t want it in the HTML sidebar, you can put it in a hidden toctree:
2) Make sure LaTeX index generation is enabled
In
docs/conf.py, ensure these are not disabling the index:latex_domain_indices(controls additional domain indices; general index generation still matters forgenindex) (sphinx-doc.org)Usually the default is fine, but if your config customizes LaTeX heavily, confirm you haven’t removed the index print step. Sphinx exposes LaTeX hooks for
makeindexandprintindexvialatex_elements. (sphinx-doc.org)For example, you can explicitly force printing the index at the end (only if needed):
(Only do this if your project overrides
latex_elementsalready and accidentally removed it.)3) Rebuild on Read the Docs and confirm the PDF build log
After pushing the change, re-build the RTD project and check the PDF build output. If the index is still empty, the next most common cause is: your docs don’t contain any index entries (no
.. index::directives, and few/no domains that add index entries). Sphinx will still create an Index section, but it can be effectively empty.If you want, paste:
docs/conf.pyLaTeX-related settings (latex_elements,latex_documents,latex_engine,latex_use_xindy,latex_domain_indices)index.rst(or whatever file contains the top-level toctree)…and I’ll tell you exactly what to change in GSAS-II’s doc setup.
User: can you review the files @AdvancedPhotonSource/GSAS-II/files/docs/source/conf.py and @AdvancedPhotonSource/GSAS-II/files/docs/source/index.rst as well as @AdvancedPhotonSource/GSAS-II/files/docs/scripting/conf.py and @AdvancedPhotonSource/GSAS-II/files/docs/scripting/index.rst and create a PR with changes?
Assistant: I’ve queued up the pull request creation, but I can’t proceed until you respond to the pending confirmation prompt (accept/rejec...
This pull request was created from Copilot chat.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.