forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix links for nested types in generated docs (chapel-lang#24584)
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]
- Loading branch information
Showing
6 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
This test is to make sure that links for nested types are handled correctly. All of these links should resolve correctly | ||
- :type:`nested.A` | ||
- :proc:`nested.A.foo` | ||
- :type:`nested.A.B` | ||
- :proc:`nested.A.B.bar` | ||
- :proc:`nested.A.baz` | ||
- :type:`nested.C` | ||
- :proc:`nested.C.foo` | ||
*/ | ||
module nested { | ||
record A { | ||
proc foo() {} | ||
record B { | ||
proc bar() {} | ||
} | ||
proc baz() {} | ||
} | ||
record C { | ||
proc foo() {} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-o docs |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docs |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Found link for reference '#nested.A' | ||
Found link for reference '#nested.A.foo' | ||
Found link for reference '#nested.A.B' | ||
Found link for reference '#nested.A.B.bar' | ||
Found link for reference '#nested.A.baz' | ||
Found link for reference '#nested.C' | ||
Found link for reference '#nested.C.foo' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import os | ||
import re | ||
|
||
testname = sys.argv[1] | ||
testout = sys.argv[2] | ||
|
||
html_file = f"docs/modules/nested.html" | ||
if not os.path.exists(html_file): | ||
with open(testout, "w") as f: | ||
print(f"Could not find '{html_file}'", file=f) | ||
exit() | ||
|
||
html_output = "" | ||
with open(html_file, "r") as f: | ||
html_output = f.read() | ||
|
||
output = [] | ||
|
||
# find all the references from the docstring with the following regex | ||
reference_pat = re.compile('<a class="reference internal" href="#(.+?)" title="\\1">') | ||
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): | ||
output.append(f"Could not find link for reference '#{link}'") | ||
else: | ||
output.append(f"Found link for reference '#{link}'") | ||
|
||
with open(testout, "w") as f: | ||
print("\n".join(output), file=f) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Split into 3 files to work around problems with CHPL_PIP_FROM_SOURCE | ||
sphinx-rtd-theme==2.0.0 | ||
sphinxcontrib-chapeldomain==0.0.30 | ||
sphinxcontrib-chapeldomain==0.0.31 | ||
breathe==4.35.0 |