Skip to content

Instantly share code, notes, and snippets.

@agoose77
Created January 5, 2023 22:08

Revisions

  1. agoose77 created this gist Jan 5, 2023.
    21 changes: 21 additions & 0 deletions gha-sphinx-link-check.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import pathlib
    import json

    docs_path = pathlib.Path("docs")
    output_path = docs_path / "_build" / "linkcheck" / "output.json"

    with output_path.open() as f:
    data = [json.loads(l) for l in f]

    for record in data:
    if record['status'] != "broken":
    continue

    record['path'] = (docs_path / record['filename'])

    print(
    "::error file={path},line={lineno}::{uri} URI was {status} (code: {code}): {info}".format_map(record)
    )
    print(
    "??file={path},line={lineno}??{uri} URI was {status} (code: {code}): {info}".format_map(record)
    )