Skip to content
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

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

jabraham17
Copy link
Member

@jabraham17 jabraham17 commented Mar 12, 2024

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]

@jabraham17 jabraham17 requested a review from lydia-duncan March 12, 2024 00:45
Copy link
Member

@lydia-duncan lydia-duncan left a 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
Copy link
Member

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?

Copy link
Member Author

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):
Copy link
Member

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?

Copy link
Member Author

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]>
Copy link
Member

@lydia-duncan lydia-duncan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it :)

@jabraham17 jabraham17 merged commit c362c75 into chapel-lang:main Mar 12, 2024
7 checks passed
@jabraham17 jabraham17 deleted the fix-nested-links branch March 12, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants