Skip to content

Commit

Permalink
Fix link check (#328) (#329)
Browse files Browse the repository at this point in the history
* Don't report broken vimeo links

* codeformat

(cherry picked from commit 69ca35f)

Co-authored-by: Christoph Fröhlich <[email protected]>
  • Loading branch information
mergify[bot] and christophfroehlich authored Jul 14, 2024
1 parent b5369e8 commit 0705229
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions make_help_scripts/check_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path_to_html_dir>")
Expand All @@ -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)
Expand All @@ -58,5 +63,6 @@ def main():
cleanup()
sys.exit(0)


if __name__ == "__main__":
main()

0 comments on commit 0705229

Please sign in to comment.