Skip to content

Commit 9526c3f

Browse files
chore: add link-checking command (#551)
* chore: add link-checking command * config changes --------- Co-authored-by: Tetsuo Koyama <[email protected]>
1 parent 7939028 commit 9526c3f

File tree

13 files changed

+54
-15
lines changed

13 files changed

+54
-15
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ There are different sessions in nox related to building the docs: `docs`, `docs-
188188
```
189189
To see the guide built locally, open the file `_build/html/index.html` in your browser.
190190

191+
- `docs-linkcheck`: this session checks that links in documentation work
192+
```bash
193+
nox -e docs-linkcheck
194+
```
195+
If the tests fail, you will see logs in the terminal and in `_build/linkcheck_output/output.txt`.
196+
191197
- `docs-test`: this session runs the tests for the guide.
192198
```bash
193199
nox -e docs-test

conf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@
206206
# myst complains about bibtex footnotes because of render order
207207
suppress_warnings = ["myst.footnote"]
208208

209+
# -- Options for linkcheck -------------------------------------------------
210+
211+
# config reference: https://www.sphinx-doc.org/en/master/usage/configuration.html
212+
linkcheck_anchors_ignore_for_url = [
213+
# GitHub code links with line-number anchors are reported as "not found"
214+
r"https:\/\/.*github\.com.*\/blob\/.*",
215+
]
216+
217+
linkcheck_ignore = [
218+
# gnu.org is so strictly rate-limited that retries to it really slow down link-checking... just assume they're fine
219+
r"https:\/\/.*gnu\.org.*",
220+
]
209221

210222
def _post_build(app: "Sphinx", exception: Exception | None) -> None:
211223
rss.generate_tutorials_feed(app)

documentation/repository-files/readme-file-best-practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Example: [![PyPI version shields.io](https://img.shields.io/pypi/v/pandera.svg)]
8484
```{tip}
8585
Once you package is accepted to pyOpenSci, we will provide you with
8686
a badge to add to your repository that shows that it has been reviewed.
87-
[![pyOpenSci](https://pyopensci.org/badges/peer-reviewed.svg)](https://github.com/pyOpenSci/software-review/issues/12)
87+
[![pyOpenSci](https://pyopensci.org/badges/peer-reviewed.svg)](https://github.com/pyOpenSci/software-submission/issues/12)
8888
8989
```
9090

locales/es/LC_MESSAGES/documentation.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ msgid ""
19411941
"Once you package is accepted to pyOpenSci, we will provide you with a "
19421942
"badge to add to your repository that shows that it has been reviewed. "
19431943
"[![pyOpenSci](https://pyopensci.org/badges/peer-"
1944-
"reviewed.svg)](https://github.com/pyOpenSci/software-review/issues/12)"
1944+
"reviewed.svg)](https://github.com/pyOpenSci/software-submission/issues/12)"
19451945
msgstr ""
19461946

19471947
#: ../../documentation/repository-files/readme-file-best-practices.md:85

locales/es/LC_MESSAGES/package-structure-code.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7199,13 +7199,13 @@ msgstr "Herramienta 3: versionado de setuptools-scm usando etiquetas git"
71997199

72007200
#: ../../package-structure-code/python-package-versions.md:226
72017201
msgid ""
7202-
"[`Setuptools_scm`](https://github.com/pypa/setuptools_scm/) is an "
7202+
"[`Setuptools_scm`](https://github.com/pypa/setuptools-scm/) is an "
72037203
"extension that you can use with setuptools to manage package versions. "
72047204
"**Setuptools_scm** operates the same way that **hatch_vcs** (discussed "
72057205
"above) does. It stores a version in a **\\_version.py** file and relies "
72067206
"on (**git**) tags to determine the package's current version."
72077207
msgstr ""
7208-
"[`Setuptools_scm`](https://github.com/pypa/setuptools_scm/) es una "
7208+
"[`Setuptools_scm`](https://github.com/pypa/setuptools-scm/) es una "
72097209
"extensión que puede usar con setuptools para gestionar las versiones de "
72107210
"los paquetes. **Setuptools_scm** opera de la misma manera que "
72117211
"**hatch_vcs** (discutido anteriormente). Almacena una versión en un "

locales/es/LC_MESSAGES/tests.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,14 @@ msgstr ""
654654

655655
#: ../../tests/run-tests.md:127
656656
msgid ""
657-
"**[Hatch](https://github.com/ofek/hatch)** is a modern end-to-end "
657+
"**[Hatch](https://github.com/pypa/hatch)** is a modern end-to-end "
658658
"packaging tool that works with the popular build backend called "
659659
"hatchling. `hatch` offers a `tox`-like setup where you can run tests "
660660
"locally using different Python versions. If you are using `hatch` to "
661661
"support your packaging workflow, you may want to also use its testing "
662662
"capabilities rather than using `nox`."
663663
msgstr ""
664-
"**[Hatch](https://github.com/ofek/hatch)** es una herramienta de "
664+
"**[Hatch](https://github.com/pypa/hatch)** es una herramienta de "
665665
"empaquetado moderna de extremo a extremo que funciona con el popular "
666666
"backend de construcción llamado hatchling. `hatch` ofrece una "
667667
"configuración similar a `tox` donde puedes ejecutar pruebas localmente "

locales/ja/LC_MESSAGES/documentation.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,11 +2122,11 @@ msgid ""
21222122
"Once you package is accepted to pyOpenSci, we will provide you with a "
21232123
"badge to add to your repository that shows that it has been reviewed. "
21242124
"[![pyOpenSci](https://pyopensci.org/badges/peer-"
2125-
"reviewed.svg)](https://github.com/pyOpenSci/software-review/issues/12)"
2125+
"reviewed.svg)](https://github.com/pyOpenSci/software-submission/issues/12)"
21262126
msgstr ""
21272127
"あなたのパッケージがpyOpenSciに受理されると、あなたのリポジトリにレビュー済みであることを示すバッジを提供します。 "
21282128
"[![pyOpenSci](https://pyopensci.org/badges/peer-"
2129-
"reviewed.svg)](https://github.com/pyOpenSci/software-review/issues/12)"
2129+
"reviewed.svg)](https://github.com/pyOpenSci/software-submission/issues/12)"
21302130

21312131
#: ../../documentation/repository-files/readme-file-best-practices.md:85
21322132
msgid "pyOpenSci"

locales/ja/LC_MESSAGES/package-structure-code.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6146,13 +6146,13 @@ msgstr "ツール3: gitタグを使ったsetuptools-scmのバージョン管理"
61466146

61476147
#: ../../package-structure-code/python-package-versions.md:226
61486148
msgid ""
6149-
"[`Setuptools_scm`](https://github.com/pypa/setuptools_scm/) is an "
6149+
"[`Setuptools_scm`](https://github.com/pypa/setuptools-scm/) is an "
61506150
"extension that you can use with setuptools to manage package versions. "
61516151
"**Setuptools_scm** operates the same way that **hatch_vcs** (discussed "
61526152
"above) does. It stores a version in a **\\_version.py** file and relies "
61536153
"on (**git**) tags to determine the package's current version."
61546154
msgstr ""
6155-
"[`Setuptools_scm`](https://github.com/pypa/setuptools_scm/) "
6155+
"[`Setuptools_scm`](https://github.com/pypa/setuptools-scm/) "
61566156
"は、パッケージのバージョンを管理するために setuptools と一緒に使うことができる拡張機能です。 "
61576157
"**Setuptools_scm**は、**hatch_vcs**(前述)と同じように動作します。 バージョンを **_version.py** "
61586158
"ファイルに保存し、パッケージの現在のバージョンを決定するために (**git**) タグに依存します。"

locales/ja/LC_MESSAGES/tests.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,14 @@ msgstr ""
619619

620620
#: ../../tests/run-tests.md:127
621621
msgid ""
622-
"**[Hatch](https://github.com/ofek/hatch)** is a modern end-to-end "
622+
"**[Hatch](https://github.com/pypa/hatch)** is a modern end-to-end "
623623
"packaging tool that works with the popular build backend called "
624624
"hatchling. `hatch` offers a `tox`-like setup where you can run tests "
625625
"locally using different Python versions. If you are using `hatch` to "
626626
"support your packaging workflow, you may want to also use its testing "
627627
"capabilities rather than using `nox`."
628628
msgstr ""
629-
"**[Hatch](https://github.com/ofek/hatch)** "
629+
"**[Hatch](https://github.com/pypa/hatch)** "
630630
"は、hatchlingと呼ばれる人気のあるビルドバックエンドで動作する最新のエンドツーエンドパッケージングツールです。 `hatch` は "
631631
"`tox` のようなセットアップを提供し、異なる Python バージョンを使ってローカルでテストを実行することができます。 "
632632
"パッケージングのワークフローをサポートするために `hatch` を使っているのであれば、 `nox` を使うよりも `hatch` "

noxfile.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
# Sphinx parameters used to build the guide
3232
BUILD_PARAMETERS = ["-b", "html"]
3333

34+
# Sphinx parameters used when checking that links work
35+
# ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder
36+
LINKCHECK_PARAMETERS = ["-b", "linkcheck", "-Dlinkcheck_timeout=5", "-Dlinkcheck_rate_limit_timeout=30", "--fail-on-warning"]
37+
LINKCHECK_OUTPUT_DIR = pathlib.Path(BUILD_DIR, "linkcheck_output")
38+
3439
# Sphinx parameters used to test the build of the guide
3540
TEST_PARAMETERS = ["--keep-going", "-E", "-a"]
3641

@@ -70,6 +75,22 @@ def docs(session):
7075
session.notify("build-release-languages", session.posargs)
7176

7277

78+
@nox.session(name="docs-linkcheck")
79+
def docs_linkcheck(session):
80+
"""
81+
Check that links are well-formed and point to something that exists.
82+
"""
83+
session.install("-e", ".")
84+
session.run(
85+
SPHINX_BUILD,
86+
*LINKCHECK_PARAMETERS,
87+
SOURCE_DIR,
88+
LINKCHECK_OUTPUT_DIR,
89+
*session.posargs,
90+
env={"SPHINX_ENV": "development"},
91+
)
92+
93+
7394
@nox.session(name="docs-test")
7495
def docs_test(session):
7596
"""

0 commit comments

Comments
 (0)