From 93242edc86889435049b66159ba99c932ff59d37 Mon Sep 17 00:00:00 2001 From: Craig Schardt Date: Sat, 16 Nov 2024 20:24:27 -0600 Subject: [PATCH] Fix rate limiting in sphinx link checker (#1579) Fixes rate-limit errors in the sphinx linkchecker on GitHub links caused by a missing token. ``` -rate limited- https://github.com/PhotonVision/photonvision/commits/master/ | sleeping... -rate limited- https://github.com/PhotonVision/photonvision/commits/master/ | sleeping... (docs/advanced-installation/prerelease-software: line 9) broken https://github.com/PhotonVision/photonvision/commits/master/ - 429 Client Error: Too Many Requests for url: https://github.com/PhotonVision/photonvision/commits/master/ ``` --- .github/workflows/photonvision-docs.yml | 3 +++ docs/source/conf.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/photonvision-docs.yml b/.github/workflows/photonvision-docs.yml index 16c9faac1..fd520c10b 100644 --- a/.github/workflows/photonvision-docs.yml +++ b/.github/workflows/photonvision-docs.yml @@ -12,6 +12,9 @@ on: - 'docs/**' - '.github/**' +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: build: runs-on: ubuntu-22.04 diff --git a/docs/source/conf.py b/docs/source/conf.py index b7b45f42f..8de2d4414 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -10,7 +10,8 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os +import os + # import sys # sys.path.insert(0, os.path.abspath('.')) @@ -138,9 +139,15 @@ suppress_warnings = ["epub.unknown_project_files"] sphinx_tabs_valid_builders = ["epub", "linkcheck"] +# -- Options for linkcheck ------------------------------------------------- + # Excluded links for linkcheck # These should be periodically checked by hand to ensure that they are still functional -linkcheck_ignore = ["https://www.raspberrypi.com/software/"] +linkcheck_ignore = [R"https://www.raspberrypi.com/software/", R"http://10\..+"] + +token = os.environ.get("GITHUB_TOKEN", None) +if token: + linkcheck_auth = [(R"https://github.com/.+", token)] # MyST configuration (https://myst-parser.readthedocs.io/en/latest/configuration.html) myst_enable_extensions = ["colon_fence"]