Repository navigation
fix: check documentation links on pull requests #363
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
Changes from 1 commit
26a3baa
63da7e1
36fb938
ac23eae
e57a48d
de3dfd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,36 @@ | ||
| """Build docs, failing on MkDocs diagnostics except known API warnings.""" | ||
| """Build docs, failing on logged MkDocs diagnostics except nine known warnings. | ||
|
|
||
| Python warnings (such as DeprecationWarning) are not routed into this gate. | ||
| """ | ||
|
|
||
| import argparse | ||
| import logging | ||
| import re | ||
| from pathlib import Path | ||
|
|
||
| from mkdocs.commands.build import build | ||
| from mkdocs.config import load_config | ||
| from mkdocs.exceptions import Abort | ||
| from mkdocs.exceptions import MkDocsException | ||
|
|
||
| # Issue #355's existing annotation warnings. Keep messages and source locations | ||
| # explicit: a changed diagnostic needs review, not a blanket plugin exemption. | ||
| _GRIFFE_WARNINGS = { | ||
| "griffe: src/stickler/structured_object_evaluator/" + warning | ||
| for warning in ( | ||
| "bulk_structured_model_evaluator.py:965: No type or annotation for parameter 'df'", | ||
| "models/structured_model.py:1842: No type or annotation for parameter '**kwargs'", | ||
| "models/structured_model.py:1845: No type or annotation for returned value 1", | ||
| "models/comparable_field.py:102: No type or annotation for parameter '**field_kwargs'", | ||
| "models/comparable_field.py:105: No type or annotation for returned value 1", | ||
| "models/field.py:51: No type or annotation for parameter '**kwargs'", | ||
| ) | ||
| } | ||
| _AUTOREFS_WARNING = re.compile( | ||
| r"mkdocs_autorefs: API-Reference/models\.md: from (?:.*?/)?" | ||
| r"src/stickler/structured_object_evaluator/models/structured_model\.py:262: " | ||
| r"\(stickler\.structured_object_evaluator\.models\.structured_model\.StructuredModel\) " | ||
| r"Could not find cross-reference target ''(?:tp|fd|derived)''" | ||
| ) | ||
|
Contributor
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. Should fix. The Suggestion, keeping your "explicit, not a blanket exemption" intent:
Separately, and optional: the three autorefs warnings come from the unfenced |
||
|
|
||
|
|
||
| class _LinkWarnings(logging.Handler): | ||
|
|
@@ -15,16 +39,22 @@ def __init__(self): | |
| self.count = 0 | ||
|
|
||
| def emit(self, record): | ||
| # These sources emit the site's existing API annotation/cross-reference | ||
| # warnings. Errors remain fatal, including errors from these plugins. | ||
| if record.levelno == logging.WARNING and any( | ||
| record.name == name or record.name.startswith(name + ".") | ||
| for name in ( | ||
| "mkdocs.plugins.griffe", | ||
| "mkdocs.plugins.mkdocs_autorefs", | ||
| ) | ||
| ): | ||
| return | ||
| message = record.getMessage().replace("\\", "/") | ||
| if record.levelno == logging.WARNING: | ||
| if record.name == "mkdocs.plugins.griffe": | ||
| # griffe uses absolute paths when invoked from docs/ (make check). | ||
| message = re.sub( | ||
| r"^griffe: (?:.*?/)?src/stickler/", | ||
| "griffe: src/stickler/", | ||
| message, | ||
| ) | ||
| if message in _GRIFFE_WARNINGS: | ||
| return | ||
| if ( | ||
| record.name == "mkdocs.plugins.mkdocs_autorefs._internal.plugin" | ||
| and _AUTOREFS_WARNING.fullmatch(message) | ||
| ): | ||
| return | ||
| self.count += 1 | ||
|
|
||
|
|
||
|
|
@@ -64,7 +94,7 @@ def main() -> int: | |
| logging.basicConfig(level=logging.INFO, format="%(levelname)s - %(message)s") | ||
| try: | ||
| return check_links(args.config_file, args.site_dir) | ||
| except Abort as error: | ||
| except MkDocsException as error: | ||
| logging.getLogger("mkdocs").error("%s", error) | ||
| return 1 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ nav: | |
| - Comparators/ | ||
| - Evaluation/ | ||
| - Use-Cases/ | ||
| - Document_Packet_Splitting.md | ||
| - Best-Practices/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ repo_name: awslabs/stickler | |
| validation: | ||
| nav: | ||
| not_found: warn | ||
|
Comment on lines
+7
to
+9
Contributor
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. Should fix. Adding |
||
| omitted_files: warn | ||
| links: | ||
| not_found: warn | ||
| anchors: warn | ||
|
|
||
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.
Nit: once the line numbers are gone, "identified by logger, message and source location" should read something like "identified by logger, file and message", and "changed messages/locations" on the next line becomes "changed messages".