From 9d40f9eb1618507bd893ea439e4d676e08326a09 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Mon, 11 Mar 2024 17:42:27 -0700 Subject: [PATCH 1/3] bump chapeldomain version Signed-off-by: Jade Abraham --- third-party/chpl-venv/chpldoc-requirements3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/chpl-venv/chpldoc-requirements3.txt b/third-party/chpl-venv/chpldoc-requirements3.txt index 850c46616cb2..3b6843c0c5dc 100644 --- a/third-party/chpl-venv/chpldoc-requirements3.txt +++ b/third-party/chpl-venv/chpldoc-requirements3.txt @@ -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 From 641c1dc0b554744818882053615897909868d4fd Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Mon, 11 Mar 2024 17:42:49 -0700 Subject: [PATCH 2/3] add chpldoc test of nested links Signed-off-by: Jade Abraham --- test/chpldoc/links/nested.doc.chpl | 25 ++++++++++++ test/chpldoc/links/nested.doc.chpldocopts | 1 + test/chpldoc/links/nested.doc.cleanfiles | 1 + test/chpldoc/links/nested.doc.good | 7 ++++ test/chpldoc/links/nested.doc.prediff | 50 +++++++++++++++++++++++ 5 files changed, 84 insertions(+) create mode 100644 test/chpldoc/links/nested.doc.chpl create mode 100644 test/chpldoc/links/nested.doc.chpldocopts create mode 100644 test/chpldoc/links/nested.doc.cleanfiles create mode 100644 test/chpldoc/links/nested.doc.good create mode 100755 test/chpldoc/links/nested.doc.prediff diff --git a/test/chpldoc/links/nested.doc.chpl b/test/chpldoc/links/nested.doc.chpl new file mode 100644 index 000000000000..eb04d66a78c0 --- /dev/null +++ b/test/chpldoc/links/nested.doc.chpl @@ -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() {} + } +} diff --git a/test/chpldoc/links/nested.doc.chpldocopts b/test/chpldoc/links/nested.doc.chpldocopts new file mode 100644 index 000000000000..acea7b6a8e44 --- /dev/null +++ b/test/chpldoc/links/nested.doc.chpldocopts @@ -0,0 +1 @@ +-o docs --no-html --save-sphinx docs diff --git a/test/chpldoc/links/nested.doc.cleanfiles b/test/chpldoc/links/nested.doc.cleanfiles new file mode 100644 index 000000000000..d8f8d46921aa --- /dev/null +++ b/test/chpldoc/links/nested.doc.cleanfiles @@ -0,0 +1 @@ +docs diff --git a/test/chpldoc/links/nested.doc.good b/test/chpldoc/links/nested.doc.good new file mode 100644 index 000000000000..289cbd78ef49 --- /dev/null +++ b/test/chpldoc/links/nested.doc.good @@ -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' diff --git a/test/chpldoc/links/nested.doc.prediff b/test/chpldoc/links/nested.doc.prediff new file mode 100755 index 000000000000..a994deb9e444 --- /dev/null +++ b/test/chpldoc/links/nested.doc.prediff @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 + +import sys +import subprocess as sp +import os +import re + +testname = sys.argv[1] +testout = sys.argv[2] + +chpl_home = os.environ.get("CHPL_HOME", "") + +sphinx_build = f"{chpl_home}/third-party/chpl-venv/install/chpldeps/bin/sphinx-build" + +os.chdir("docs") +p = sp.run( + f"{sphinx_build} -b html -d build/doctrees source build/html".split(" "), + stdout=sp.PIPE, stderr=sp.STDOUT) +make_output = p.stdout.decode() +if p.returncode != 0: + with open("../" + testout, "w") as f: + print("Failed to build chpldoc html", file=f) + print(make_output, file=f) + exit() +os.chdir("..") + +html_file = f"docs/build/html/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('') +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'', 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) From 0efb6ff31841fb6ceb48b61989569a0e3158564d Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Tue, 12 Mar 2024 08:23:47 -0700 Subject: [PATCH 3/3] simplify prediff Signed-off-by: Jade Abraham --- test/chpldoc/links/nested.doc.chpldocopts | 2 +- test/chpldoc/links/nested.doc.prediff | 19 +------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/test/chpldoc/links/nested.doc.chpldocopts b/test/chpldoc/links/nested.doc.chpldocopts index acea7b6a8e44..02dbf6292e13 100644 --- a/test/chpldoc/links/nested.doc.chpldocopts +++ b/test/chpldoc/links/nested.doc.chpldocopts @@ -1 +1 @@ --o docs --no-html --save-sphinx docs +-o docs diff --git a/test/chpldoc/links/nested.doc.prediff b/test/chpldoc/links/nested.doc.prediff index a994deb9e444..003e24301777 100755 --- a/test/chpldoc/links/nested.doc.prediff +++ b/test/chpldoc/links/nested.doc.prediff @@ -1,30 +1,13 @@ #!/usr/bin/env python3 import sys -import subprocess as sp import os import re testname = sys.argv[1] testout = sys.argv[2] -chpl_home = os.environ.get("CHPL_HOME", "") - -sphinx_build = f"{chpl_home}/third-party/chpl-venv/install/chpldeps/bin/sphinx-build" - -os.chdir("docs") -p = sp.run( - f"{sphinx_build} -b html -d build/doctrees source build/html".split(" "), - stdout=sp.PIPE, stderr=sp.STDOUT) -make_output = p.stdout.decode() -if p.returncode != 0: - with open("../" + testout, "w") as f: - print("Failed to build chpldoc html", file=f) - print(make_output, file=f) - exit() -os.chdir("..") - -html_file = f"docs/build/html/modules/nested.html" +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)