New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External references are not resolved in TOC tree sidebar #4448
Labels
Milestone
Comments
mwoehlke
added a commit
to mwoehlke/sphinx
that referenced
this issue
Jan 21, 2018
Implement a new node that converts its contents to text (via astext()), but delays doing so until the post-transform stage. Modify TOC collection to use this. Modify TOC extraction to perform post-transforms (specifically, reference resolution and resolution of the aforementioned new nodes). This fixes an annoying behavior where the use of an external reference in a section name would use the raw reference text rather than the resolved reference text in the sidebar table of contents, resulting in a mismatch between the section title as it appears in said table of contents and how it appears in the document body. Fixes sphinx-doc#4448.
mwoehlke
added a commit
to mwoehlke/sphinx
that referenced
this issue
Jan 21, 2018
Implement a new node that converts its contents to text (via astext()), but delays doing so until the post-transform stage. Modify TOC collection to use this. Modify TOC extraction to perform post-transforms (specifically, reference resolution and resolution of the aforementioned new nodes). This fixes an annoying behavior where the use of an external reference in a section name would use the raw reference text rather than the resolved reference text in the sidebar table of contents, resulting in a mismatch between the section title as it appears in said table of contents and how it appears in the document body. Fixes sphinx-doc#4448.
mwoehlke
added a commit
to mwoehlke/sphinx
that referenced
this issue
Jan 22, 2018
Implement a new node that converts its contents to text (via astext()), but delays doing so until the post-transform stage. Modify TOC collection to use this. Modify TOC extraction to perform post-transforms (specifically, reference resolution and resolution of the aforementioned new nodes). This fixes an annoying behavior where the use of an external reference in a section name would use the raw reference text rather than the resolved reference text in the sidebar table of contents, resulting in a mismatch between the section title as it appears in said table of contents and how it appears in the document body. Fixes sphinx-doc#4448.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let's say I have a document like:
In the body of the document, the reference title is resolved as expected. (Let's say for example that the document title is "Describe Some Page Here". Then, in the body, the heading appears as "Describe Some Page Here".) However, in the sidebar TOC, the heading appears as "some-page". That is, the TOC uses the raw text of the reference, rather than the resolved text. Besides looking ugly, this is confusing and almost certainly not intended, as it means that the heading text in the TOC and the document body are different.
On consideration, I suspect the problem is that the TOC is using
astext
onXRefRole
nodes, which drops the external reference bits before they can be resolved. This may be a tricky fix, as I suspect that, besides tweaking the TOC to allowed delayed text resolution (which in itself may be non-trivial), all ofStandardDomain.resolve_xref
may need to sprout a mode to resolve text but not actually emit a reference (since in the TOC case, the reference we want is to the section that used the external reference in its title, and not what the external reference actually references).This should be reproducible with the following
index.rst
::(Verified by making a comparable change to the
index.rst
of a sphinx-quickstart project.)The text was updated successfully, but these errors were encountered: