Skip to content

Commit ab7041d

Browse files
committed
add pytest-check-links
1 parent 7010aa9 commit ab7041d

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

ci/job.docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ jobs:
3939
inputs:
4040
targetPath: docs/_build
4141
artifactName: Docs $(Build.BuildId)
42+
43+
- script: ${{ platform.activate }} jupyterlab-lsp && python scripts/docs.py --check
44+
displayName: check URLs in docs

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888
"gh": (f"{github_url}/%s", "GitHub: "),
8989
}
9090

91-
html_show_sourcelink = True # True will show link to source
91+
html_show_sourcelink = True
9292

9393
html_context = {
94-
"display_github": True,
94+
"display_github": False,
9595
"github_user": github_repo_org,
9696
"github_repo": github_repo_name,
9797
"github_version": "master",

requirements/docs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-r dev.txt
33
graphviz
44
nbsphinx
5+
pytest-check-links
56
recommonmark
67
sphinx
78
sphinx_autodoc_typehints

requirements/docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ channels:
77
dependencies:
88
- nbsphinx
99
- pandas
10+
- pytest
1011
- python-graphviz
1112
- recommonmark
1213
- sphinx
@@ -15,4 +16,5 @@ dependencies:
1516
- sphinx-autodoc-typehints
1617
- sphinx-copybutton
1718
- pip:
19+
- pytest-check-links
1820
- sphinx-markdown-tables

scripts/docs.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
""" antidisinformationarianism
22
"""
3+
import shutil
34
import sys
45
from pathlib import Path
56
from subprocess import check_call
7+
from tempfile import TemporaryDirectory
68

79
ROOT = Path(__file__).parent.parent
810
DOCS = ROOT / "docs"
911

1012

11-
def docs(watch=False):
13+
def docs(watch=False, check=False):
1214
""" build (and test) docs.
1315
1416
because readthedocs, this gets called twice from inside sphinx
1517
"""
1618
if watch:
1719
check_call(["sphinx-autobuild", ".", "_build"], cwd=DOCS)
18-
else:
19-
check_call(["sphinx-build", "-M", "html", ".", "_build"], cwd=DOCS)
20+
return 0
21+
22+
if check:
23+
# do this in a temporary directory to avoid surprises
24+
with TemporaryDirectory() as td:
25+
tdp = Path(td)
26+
dest = tdp / "a" / "deep" / "path"
27+
dest.parent.mkdir(parents=True)
28+
shutil.copytree(DOCS / "_build", dest)
29+
check_call(["pytest-check-links", "-vv", "-k", "not ipynb"], cwd=dest)
30+
31+
check_call(["sphinx-build", "-M", "html", ".", "_build"], cwd=DOCS)
2032
return 0
2133

2234

2335
if __name__ == "__main__":
24-
sys.exit(docs(watch="--watch" in sys.argv))
36+
sys.exit(docs(watch="--watch" in sys.argv, check="--check" in sys.argv))

0 commit comments

Comments
 (0)