-
Notifications
You must be signed in to change notification settings - Fork 428
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
Fix links for nested types in generated docs #24584
Conversation
Signed-off-by: Jade Abraham <[email protected]>
Signed-off-by: Jade Abraham <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of nits, looking forward to seeing this merged :)
@@ -0,0 +1 @@ | |||
-o docs --no-html --save-sphinx docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use --no-html
if you're going to call sphinx-build
with the html flag later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting errors from sphinx when not using --no-html
, which I think are related to using --save-sphinx
to the same directory as -o
. Since for this test the sphinx output is not needed, I can simplify this (and the prediff)
for m in re.finditer(reference_pat, html_output): | ||
# for each reference, check if the link exists | ||
link = m.group(1) | ||
if not re.search(f'<a class="headerlink" href="#{link}" title="Permalink to this definition">', html_output): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know enough about html and css formatting, are "headerlink" and the field names something that can be relied on? Or could they change in newer versions of Sphinx/Read the Docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a possibility it could change in a future version. Parsing html with a regex like this is fragile, as there is no guarantee on the order of the fields. And "headerlink" and "title=..." could change (although I doubt they would). But within our version of sphinx I am more confident that we can rely on this order and the contents.
Signed-off-by: Jade Abraham <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it :)
This PR pulls in a fix from sphinxcontrib-chapeldomain that fixes how links for nested types are rendered. This PR also adds a test for chpldoc to lock in the correct behavior.
See chapel-lang/sphinxcontrib-chapeldomain#90 for details of the fix
[Reviewed by @lydia-duncan]