From c4521f256e5aba6783811a60c6a12da4fbb2e68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Fr=C3=B6hlich?= Date: Mon, 15 Jul 2024 00:09:03 +0200 Subject: [PATCH] Fix link check (#328) * Don't report broken vimeo links * codeformat (cherry picked from commit 69ca35fc1df40fb5314c5850a4507012f24bc6bf) --- make_help_scripts/check_links.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/make_help_scripts/check_links.py b/make_help_scripts/check_links.py index 0182e19ba86..0fbe18d6008 100755 --- a/make_help_scripts/check_links.py +++ b/make_help_scripts/check_links.py @@ -25,10 +25,12 @@ LOGFILE = "linkcheck.log" + def cleanup(): os.remove(LOGFILE) shutil.rmtree("doc/api/", ignore_errors=True) + def main(): if len(sys.argv) != 2: print("Usage: python check_links.py ") @@ -37,15 +39,18 @@ def main(): html_dir = sys.argv[1] # Copy API documentation to local directory - shutil.copytree(os.path.join(html_dir, "doc", "api"), "doc/api/", dirs_exist_ok=True) + shutil.copytree(os.path.join(html_dir, "doc", "api"), + "doc/api/", dirs_exist_ok=True) # Run linkcheck with open(LOGFILE, "w") as logfile: - subprocess.run(["make", "linkcheck"], stdout=logfile, stderr=subprocess.PIPE) + subprocess.run(["make", "linkcheck"], stdout=logfile, + stderr=subprocess.PIPE) # Check for broken links with open(LOGFILE, "r") as logfile: - broken_links = [line for line in logfile if "broken" in line and "github" not in line] + broken_links = [ + line for line in logfile if "broken" in line and "github" not in line and "vimeo" not in line] if broken_links: num_broken = len(broken_links) @@ -58,5 +63,6 @@ def main(): cleanup() sys.exit(0) + if __name__ == "__main__": main()