-
Notifications
You must be signed in to change notification settings - Fork 1
add doc:links and docs:links:check #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c55cef1
aa7cf9e
88b4fe8
a77d339
85bed99
1a6ac45
800e2d4
a1989c6
fd521f5
f88e0f0
d0f9602
e22c6cf
ec44ab2
4bb7bb0
9c666d6
1bb5bdb
df63fb8
5cd3532
1ecae4c
f352a07
bb14ca1
b1c0cb1
f91ba0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ At this time, PTB currently does not support setting up SonarQube for a **privat | |
|
||
## ✨ Features | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* #451: Added nox task to execute pysonar & added Sonar to the CI | ||
* #409: Doc link & checks | ||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## ⚒️ Refactorings | ||
* #451: Reduced scope of nox tasks `lint:code` (pylint) and `lint:security` (bandit) to analyze only the package code |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,3 +78,15 @@ | |
"github_url": "https://github.com/exasol/python-toolbox", | ||
"accent_color": "grass", | ||
} | ||
# -- Configure link checking behavior ---------------------------------------- | ||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
linkcheck_rate_limit_timeout = 40 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update |
||
linkcheck_timeout = 5 | ||
linkcheck_delay = 20 | ||
linkcheck_retries = 2 | ||
linkcheck_anchors = False | ||
linkcheck_ignore: list[str] = [] | ||
linkcheck_allowed_redirects = { | ||
# All HTTP redirections from the source URI to | ||
# the canonical URI will be treated as "working". | ||
r"https://github\.com/.*": r"https://github\.com/login*" | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,7 +4,7 @@ sphinx | |||||
sphinx-multiversion | ||||||
+++++++++++++++++++ | ||||||
|
||||||
The `sphinx-multiversion` extension is a modified copy of `Holzhaus/sphinx-multiversion <https://github.com/Holzhaus/sphinx-multiversion>`_. This copy was taken from version :code:`0.24.0`. | ||||||
The `sphinx-multiversion` extension is a modified copy of `Holzhaus/sphinx-multiversion <https://github.com/sphinx-contrib/multiversion>`_. This copy was taken from version :code:`0.24.0`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The repository has moved; thus, the reference text should be updated to reflect that.
Suggested change
|
||||||
|
||||||
It has been adjusted with minor code changes and modified defaults to work seamlessly with Exasol integration projects, which often require a specific project structure and layout. Additionally, it is designed to be used with an HTML theme that supports displaying and selecting multiple versions if the `versions` variable is set in the HTML context of sphinx. As of this writing, the theme used in conjunction with this modified version of `sphinx-multiversion` is `SHIBUYA <https://github.com/lepture/shibuya>`_, version :code:`2024.10.15`. | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _Getting Started: | ||
|
||
Getting Started | ||
=============== | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,11 +1,27 @@ | ||||||||||||||
from __future__ import annotations | ||||||||||||||
|
||||||||||||||
import argparse | ||||||||||||||
import json | ||||||||||||||
import os | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
import re | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
import shutil | ||||||||||||||
import subprocess | ||||||||||||||
import sys | ||||||||||||||
import tempfile | ||||||||||||||
import webbrowser | ||||||||||||||
from collections.abc import ( | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
Container, | ||||||||||||||
Iterable, | ||||||||||||||
) | ||||||||||||||
from itertools import repeat | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
from pathlib import Path | ||||||||||||||
from typing import ( | ||||||||||||||
Optional, | ||||||||||||||
Tuple, | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
import nox | ||||||||||||||
import requests # type: ignore | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused import
Suggested change
|
||||||||||||||
from nox import Session | ||||||||||||||
|
||||||||||||||
from exasol.toolbox.nox._shared import DOCS_OUTPUT_DIR | ||||||||||||||
|
@@ -17,8 +33,6 @@ | |||||||||||||
|
||||||||||||||
def _build_docs(session: nox.Session, config: Config) -> None: | ||||||||||||||
session.run( | ||||||||||||||
"poetry", | ||||||||||||||
"run", | ||||||||||||||
"sphinx-build", | ||||||||||||||
"-W", | ||||||||||||||
"-b", | ||||||||||||||
|
@@ -30,8 +44,6 @@ def _build_docs(session: nox.Session, config: Config) -> None: | |||||||||||||
|
||||||||||||||
def _build_multiversion_docs(session: nox.Session, config: Config) -> None: | ||||||||||||||
session.run( | ||||||||||||||
"poetry", | ||||||||||||||
"run", | ||||||||||||||
"sphinx-multiversion", | ||||||||||||||
f"{config.doc}", | ||||||||||||||
DOCS_OUTPUT_DIR, | ||||||||||||||
|
@@ -88,6 +100,82 @@ def clean_docs(_session: Session) -> None: | |||||||||||||
shutil.rmtree(docs_folder) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
@nox.session(name="docs:links", python=False) | ||||||||||||||
def docs_list_links(session: Session) -> None: | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to create an integration test and/or unit test(s) similar to https://github.com/exasol/python-toolbox/blob/main/test/unit/util/dependencies/poetry_dependencies_test.py. For the integration test:
For unit test(s):
It is true that we should not test everything that sphinx-build linkcheck does, but as we are building a small part of code (line 124-136) around it, it is best to ensure that the given certain input that we get an expected output. In the example test code ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (In the example with poetry, there was no CI indication before that the code was failing. I just happened to see that the output in the GitHub summary wasn't correct. 😬 . Better to do light testing & catch it earlier on. Tests are relatively free. Developers finding issues isn't as much; we cost more per hour 😉 ) |
||||||||||||||
"""List all the links within the documentation.""" | ||||||||||||||
with tempfile.TemporaryDirectory() as path: | ||||||||||||||
tmpdir = Path(path) | ||||||||||||||
sp = subprocess.run( | ||||||||||||||
[ | ||||||||||||||
"sphinx-build", | ||||||||||||||
"-b", | ||||||||||||||
"linkcheck", | ||||||||||||||
"-D", | ||||||||||||||
"linkcheck_ignore=.*", | ||||||||||||||
PROJECT_CONFIG.root / "doc", | ||||||||||||||
tmpdir, | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
print(sp.returncode) | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
if sp.returncode >= 2: | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
print(sp.stderr) | ||||||||||||||
session.error(2) | ||||||||||||||
output = tmpdir / "output.json" | ||||||||||||||
links = output.read_text().split("\n") | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
file_links = [] | ||||||||||||||
for link in links: | ||||||||||||||
if link != "": | ||||||||||||||
line = json.loads(link) | ||||||||||||||
if not line["uri"].startswith("#"): | ||||||||||||||
file_links.append(line) | ||||||||||||||
file_links.sort(key=lambda file: file["filename"]) | ||||||||||||||
print( | ||||||||||||||
"\n".join( | ||||||||||||||
f"filename: {fl['filename']} -> uri: {fl['uri']}" for fl in file_links | ||||||||||||||
) | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
@nox.session(name="docs:links:check", python=False) | ||||||||||||||
def docs_links_check(session: Session) -> None: | ||||||||||||||
"""Checks whether all links in the documentation are accessible.""" | ||||||||||||||
parser = argparse.ArgumentParser( | ||||||||||||||
prog="nox -s release:prepare", | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
usage="nox -s release:prepare -- [-h] [-o |--output]", | ||||||||||||||
Jannis-Mittenzwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||||||||||||||
) | ||||||||||||||
parser.add_argument( | ||||||||||||||
"-o", "--output", type=Path, help="path to output file", default=None | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
) | ||||||||||||||
args = parser.parse_args(session.posargs) | ||||||||||||||
with tempfile.TemporaryDirectory() as path: | ||||||||||||||
tmpdir = Path(path) | ||||||||||||||
sp = subprocess.run( | ||||||||||||||
[ | ||||||||||||||
"sphinx-build", | ||||||||||||||
"-b", | ||||||||||||||
"linkcheck", | ||||||||||||||
PROJECT_CONFIG.root / "doc", | ||||||||||||||
tmpdir, | ||||||||||||||
], | ||||||||||||||
) | ||||||||||||||
print(sp.returncode) | ||||||||||||||
if sp.returncode >= 2: | ||||||||||||||
print(sp.stderr) | ||||||||||||||
session.error(2) | ||||||||||||||
if args.output: | ||||||||||||||
result_json = tmpdir / "output.json" | ||||||||||||||
dst = Path(args.output) / "link-check-output.json" | ||||||||||||||
shutil.copyfile(result_json, dst) | ||||||||||||||
print(f"file generated at path: {result_json.resolve()}") | ||||||||||||||
result_txt = tmpdir / "output.txt" | ||||||||||||||
if sp.returncode == 1 or result_txt.read_text() != "": | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe something like this
Suggested change
|
||||||||||||||
escape_rot = "\033[31m" | ||||||||||||||
print(escape_rot + "errors:") | ||||||||||||||
print(result_txt.read_text()) | ||||||||||||||
session.error(1) | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
@nox.session(name="changelog:updated", python=False) | ||||||||||||||
def updated(_session: Session) -> None: | ||||||||||||||
"""Checks if the change log has been updated""" | ||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poetry run -- nox -s docs:links:check
to run inside of theDocumentation
jobs, either just before or afterpoetry run -- nox -s docs:build
is executed.need
list for theTests
to include theChangelog
job? Please also modify the template workflow file forchecks.yml
with the same changes (+ docs:links:check & Test>need(changelog)).