Skip to content

Commit

Permalink
Add future to lock in the bug I found with chpldoc linking behavior (c…
Browse files Browse the repository at this point in the history
…hapel-lang#24641)

[new test, not reviewed]

The documentation for a nested record can't link to symbols defined at
the same level as it. This should be something it can do (and is
something it can do for functions defined at the same level)

Verified a fresh checkout of the test behaved as expected
  • Loading branch information
lydia-duncan authored Mar 19, 2024
2 parents 741f1c8 + 5aece2f commit 1787388
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/chpldoc/links/linkToPrev.doc.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Could not find link for reference '#linkToPrev.func1'
10 changes: 10 additions & 0 deletions test/chpldoc/links/linkToPrev.doc.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module linkToPrev {
record foo {
proc func1() { }

// Seems to only be a problem for record's referring to functions at the
// same level and when they are both in another type
/* Returned by :proc:`func1` */
record innerFoo { }
}
}
1 change: 1 addition & 0 deletions test/chpldoc/links/linkToPrev.doc.chpldocopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-o docs
1 change: 1 addition & 0 deletions test/chpldoc/links/linkToPrev.doc.cleanfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs
2 changes: 2 additions & 0 deletions test/chpldoc/links/linkToPrev.doc.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bug: can't link from nested type to sibling symbols
#24625
1 change: 1 addition & 0 deletions test/chpldoc/links/linkToPrev.doc.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Found link for reference '#linkToPrev.func1'
28 changes: 28 additions & 0 deletions test/chpldoc/links/linkToPrev.doc.prediff
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3

import sys
import os
import re

testname = sys.argv[1]
testout = sys.argv[2]

html_file = f"docs/modules/linkToPrev.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 = []

if not re.search(f'<a class="reference internal" href="#linkToPrev.func1" title="linkToPrev2.func1">', html_output):
output.append(f"Could not find link for reference '#linkToPrev.func1'")
else:
output.append(f"Found link for reference '#linkToPrev.func1'")

with open(testout, "w") as f:
print("\n".join(output), file=f)

0 comments on commit 1787388

Please sign in to comment.