Markdown-Checker 1.2.0__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/PKG-INFO +3 -4
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/README.md +2 -3
- markdown_checker-1.2.2/docs/api/index.rst +20 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/howto/github-actions.rst +4 -33
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/index.rst +1 -2
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/reference/report-formats.rst +1 -1
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/pyproject.toml +1 -1
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/__init__.py +1 -1
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/cli.py +24 -9
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/models/url.py +2 -2
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/annotations.py +3 -2
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/markdown.py +3 -3
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/conftest.py +1 -1
- markdown_checker-1.2.2/tests/reports/renderers/test_annotations.py +35 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/renderers/test_json.py +1 -1
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/renderers/test_markdown.py +23 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/test_cli.py +1 -1
- markdown_checker-1.2.0/tests/reports/renderers/test_annotations.py +0 -15
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/LICENSE +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/CODE_OF_CONDUCT.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/CONTRIBUTING.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/api/checker.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/api/checks.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/api/cli.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/api/main.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/api/models.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/api/patterns.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/api/reports.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/api/utils.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/changes.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/conf.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/explanation/index.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/explanation/link-detection.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/explanation/url-checking.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/howto/index.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/howto/pyproject-config.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/howto/rate-limits.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/howto/report-formats.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/howto/select-files.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/howto/shell-completions.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/howto/skip-links.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/license.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/reference/checks.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/reference/cli.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/reference/configuration.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/reference/exit-codes.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/reference/index.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/docs/tutorial.rst +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checker.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checks/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checks/base.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checks/broken_paths.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checks/broken_urls.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checks/locale.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checks/tracking.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/models/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/models/base.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/models/config.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/models/path.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/patterns.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/py.typed +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/base.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/model.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/registry.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/console.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/json.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/templates/paths/broken.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/templates/paths/tracking.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/templates/urls/broken.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/templates/urls/locale.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/templates/urls/tracking.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/writer.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/extract_links.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/github_env.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/list_files.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/pyproject_config.py +1 -1
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/spinner.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/url_pipeline.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/checks/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/checks/test_base.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/checks/test_broken_paths.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/checks/test_broken_urls.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/checks/test_checks.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/checks/test_locale.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/checks/test_tracking.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/conftest.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/models/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/models/test_base.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/models/test_config.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/models/test_models.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/models/test_path.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/models/test_url.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/renderers/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/renderers/test_console.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/renderers/test_renderers.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/test_base.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/test_model.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/test_registry.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/test_reports.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/reports/test_writer.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/resources/sample1.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/resources/sample2.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/resources/sample3.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/resources/sample4.md +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/smoke/test_cli_smoke.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/test_checker.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/test_markdown_checker.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/test_patterns.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/utils/__init__.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/utils/test_extract_links.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/utils/test_github_env.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/utils/test_list_files.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/utils/test_pyproject_config.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/utils/test_spinner.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/utils/test_url_pipeline.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/tests/utils/test_utils.py +0 -0
- {markdown_checker-1.2.0 → markdown_checker-1.2.2}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown-checker
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: A markdown link validation reporting tool.
|
|
5
5
|
Author-email: John Aziz <johnaziz269@gmail.com>
|
|
6
6
|
Maintainer-email: John Aziz <johnaziz269@gmail.com>
|
|
@@ -87,7 +87,7 @@ Run this tool within a GitHub workflow using the
|
|
|
87
87
|
GitHub Action, which posts the report as a pull request comment:
|
|
88
88
|
|
|
89
89
|
```yaml
|
|
90
|
-
- uses: john0isaac/action-check-markdown@v1.
|
|
90
|
+
- uses: john0isaac/action-check-markdown@v1.3.0
|
|
91
91
|
with:
|
|
92
92
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
93
93
|
command: check_broken_paths
|
|
@@ -96,8 +96,7 @@ GitHub Action, which posts the report as a pull request comment:
|
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
See the [GitHub Actions how-to](https://markdown-checker.readthedocs.io/en/latest/howto/github-actions/)
|
|
99
|
-
for the full workflow
|
|
100
|
-
supported by the wrapper action) directly as a step.
|
|
99
|
+
for the full workflow.
|
|
101
100
|
|
|
102
101
|
## Documentation
|
|
103
102
|
|
|
@@ -58,7 +58,7 @@ Run this tool within a GitHub workflow using the
|
|
|
58
58
|
GitHub Action, which posts the report as a pull request comment:
|
|
59
59
|
|
|
60
60
|
```yaml
|
|
61
|
-
- uses: john0isaac/action-check-markdown@v1.
|
|
61
|
+
- uses: john0isaac/action-check-markdown@v1.3.0
|
|
62
62
|
with:
|
|
63
63
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
64
64
|
command: check_broken_paths
|
|
@@ -67,8 +67,7 @@ GitHub Action, which posts the report as a pull request comment:
|
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
See the [GitHub Actions how-to](https://markdown-checker.readthedocs.io/en/latest/howto/github-actions/)
|
|
70
|
-
for the full workflow
|
|
71
|
-
supported by the wrapper action) directly as a step.
|
|
70
|
+
for the full workflow.
|
|
72
71
|
|
|
73
72
|
## Documentation
|
|
74
73
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
API Reference
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
If you are looking for information on a specific function, class or
|
|
5
|
+
method, this part of the documentation is for you. These pages are
|
|
6
|
+
generated from the docstrings in ``markdown_checker`` and are meant for
|
|
7
|
+
programmatic/library use. For the command-line interface, see
|
|
8
|
+
:doc:`../reference/cli` instead.
|
|
9
|
+
|
|
10
|
+
.. toctree::
|
|
11
|
+
:maxdepth: 1
|
|
12
|
+
|
|
13
|
+
main
|
|
14
|
+
checker
|
|
15
|
+
cli
|
|
16
|
+
models
|
|
17
|
+
checks
|
|
18
|
+
patterns
|
|
19
|
+
reports
|
|
20
|
+
utils
|
|
@@ -34,49 +34,20 @@ replacing ``guide-url`` with the URL of your own contribution guide:
|
|
|
34
34
|
pull-requests: write
|
|
35
35
|
contents: read
|
|
36
36
|
steps:
|
|
37
|
-
- uses: actions/checkout@
|
|
38
|
-
- uses: john0isaac/action-check-markdown@v1.
|
|
37
|
+
- uses: actions/checkout@v7
|
|
38
|
+
- uses: john0isaac/action-check-markdown@v1.3.0
|
|
39
39
|
with:
|
|
40
40
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
41
41
|
command: check_broken_paths
|
|
42
42
|
directory: ./
|
|
43
43
|
guide-url: "https://github.com/<owner>/<repo>/blob/main/CONTRIBUTING.md"
|
|
44
44
|
|
|
45
|
-
The ``command`` input selects which check to run
|
|
45
|
+
The ``command`` input selects which check to run it
|
|
46
46
|
supports ``check_broken_paths``, ``check_paths_tracking``,
|
|
47
|
-
``check_urls_tracking``, and ``check_urls_locale``
|
|
47
|
+
``check_urls_tracking``, and ``check_urls_locale``
|
|
48
48
|
``check_broken_urls``. Add a separate job (or step) per command if you want
|
|
49
49
|
to run more than one check in the same workflow.
|
|
50
50
|
|
|
51
|
-
Run ``check_broken_urls`` directly (no wrapper action)
|
|
52
|
-
------------------------------------------------------------
|
|
53
|
-
|
|
54
|
-
Since the wrapper action doesn't support URL checking yet, install and
|
|
55
|
-
invoke markdown-checker directly as a workflow step instead. Use
|
|
56
|
-
``--report-format github-annotations`` so failures show up as inline
|
|
57
|
-
annotations on the PR diff, the same way the action's output does:
|
|
58
|
-
|
|
59
|
-
.. code-block:: yaml
|
|
60
|
-
|
|
61
|
-
jobs:
|
|
62
|
-
check-broken-urls:
|
|
63
|
-
runs-on: ubuntu-latest
|
|
64
|
-
permissions:
|
|
65
|
-
contents: read
|
|
66
|
-
steps:
|
|
67
|
-
- uses: actions/checkout@v4
|
|
68
|
-
- uses: actions/setup-python@v5
|
|
69
|
-
with:
|
|
70
|
-
python-version: "3.11"
|
|
71
|
-
- run: pip install markdown-checker
|
|
72
|
-
- run: >
|
|
73
|
-
markdown-checker . -f check_broken_urls
|
|
74
|
-
-rf github-annotations -o -
|
|
75
|
-
|
|
76
|
-
Because ``$CI=true`` is set automatically in GitHub Actions, warnings
|
|
77
|
-
(rate-limited/unverifiable links) are emitted as ``::warning`` annotations
|
|
78
|
-
rather than failing the job; only broken links (an error-level issue) fail it.
|
|
79
|
-
|
|
80
51
|
Verify it worked
|
|
81
52
|
------------------
|
|
82
53
|
|
|
@@ -46,7 +46,7 @@ A structured document including both errors and warnings:
|
|
|
46
46
|
.. code-block:: json
|
|
47
47
|
|
|
48
48
|
{
|
|
49
|
-
"tool": {"name": "markdown-checker", "version": "1.2.
|
|
49
|
+
"tool": {"name": "markdown-checker", "version": "1.2.2"},
|
|
50
50
|
"check": "check_broken_urls",
|
|
51
51
|
"summary": {
|
|
52
52
|
"files_checked": 10,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
import platform
|
|
5
|
+
import sys
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
from typing import Any
|
|
7
8
|
|
|
@@ -38,6 +39,23 @@ class PyprojectCommand(click.Command):
|
|
|
38
39
|
return super().make_context(info_name, args, parent, **extra)
|
|
39
40
|
|
|
40
41
|
|
|
42
|
+
def _echo_safe(message: str, *, fg: str | None = None, err: bool = False) -> None:
|
|
43
|
+
"""Echo a (optionally styled) message, dropping characters the output stream can't encode.
|
|
44
|
+
|
|
45
|
+
On Windows, piping stdout/stderr to another process (e.g. ``| grep``) can make Python
|
|
46
|
+
fall back to a legacy code page (e.g. cp1252) that can't represent emoji. Retry without
|
|
47
|
+
those characters instead of crashing the whole command.
|
|
48
|
+
"""
|
|
49
|
+
styled = click.style(message, fg=fg) if fg else message
|
|
50
|
+
try:
|
|
51
|
+
click.echo(styled, err=err)
|
|
52
|
+
except UnicodeEncodeError:
|
|
53
|
+
stream = sys.stderr if err else sys.stdout
|
|
54
|
+
encoding = getattr(stream, "encoding", None) or "ascii"
|
|
55
|
+
safe_message = styled.encode(encoding, errors="ignore").decode(encoding)
|
|
56
|
+
click.echo(safe_message, err=err)
|
|
57
|
+
|
|
58
|
+
|
|
41
59
|
class ListOfStrings(click.Option):
|
|
42
60
|
"""
|
|
43
61
|
Helper class to parse a comma-separated list of strings from the command line.
|
|
@@ -309,9 +327,9 @@ def main(
|
|
|
309
327
|
progress_callback=lambda: bar.update(1),
|
|
310
328
|
)
|
|
311
329
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
330
|
+
_echo_safe(
|
|
331
|
+
f"\n🔍 Checked {check_result.links_checked} links in {len(files_paths)} files.",
|
|
332
|
+
fg="blue",
|
|
315
333
|
)
|
|
316
334
|
|
|
317
335
|
if check_result.issues:
|
|
@@ -328,13 +346,10 @@ def main(
|
|
|
328
346
|
renderer = get_renderer(report_format)
|
|
329
347
|
out_path = None if output_file_name == "-" else Path(f"{output_file_name}{renderer.file_extension}")
|
|
330
348
|
write_report(renderer.render(report), output_path=out_path)
|
|
331
|
-
|
|
349
|
+
_echo_safe(f"😭 Found {report.error_count} issues in the following files:", fg="red", err=True)
|
|
332
350
|
|
|
333
351
|
if report.has_warnings:
|
|
334
|
-
|
|
335
|
-
click.style(f"⚠ {report.warning_count} links had warnings:", fg="yellow"),
|
|
336
|
-
err=True,
|
|
337
|
-
)
|
|
352
|
+
_echo_safe(f"⚠ {report.warning_count} links had warnings:", fg="yellow", err=True)
|
|
338
353
|
|
|
339
354
|
terminal_renderer = GitHubAnnotationsRenderer() if config.output_mode == "ci" else ConsoleRenderer()
|
|
340
355
|
for message, level in terminal_renderer.render_lines(report):
|
|
@@ -342,5 +357,5 @@ def main(
|
|
|
342
357
|
|
|
343
358
|
ctx.exit(1 if report.has_errors else 0)
|
|
344
359
|
|
|
345
|
-
|
|
360
|
+
_echo_safe("All files are compliant with the guidelines. 🎉", fg="green")
|
|
346
361
|
ctx.exit(0)
|
|
@@ -2,7 +2,7 @@ import email.utils
|
|
|
2
2
|
import time
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from datetime import datetime
|
|
5
|
-
from datetime import
|
|
5
|
+
from datetime import UTC
|
|
6
6
|
from typing import Literal
|
|
7
7
|
from urllib.parse import ParseResult
|
|
8
8
|
from urllib.parse import urlparse
|
|
@@ -65,7 +65,7 @@ def _retry_after_delay(response: httpx2.Response, fallback: int) -> float | None
|
|
|
65
65
|
# Try HTTP-date format (e.g. "Wed, 21 Oct 2015 07:28:00 GMT").
|
|
66
66
|
try:
|
|
67
67
|
dt: datetime = email.utils.parsedate_to_datetime(header)
|
|
68
|
-
now: datetime = datetime.now(
|
|
68
|
+
now: datetime = datetime.now(UTC)
|
|
69
69
|
delay: float = (dt - now).total_seconds()
|
|
70
70
|
return max(0.0, delay)
|
|
71
71
|
except Exception:
|
|
@@ -12,9 +12,10 @@ from markdown_checker.reports.model import ReportIssue
|
|
|
12
12
|
|
|
13
13
|
def _annotation_line(issue: ReportIssue) -> str:
|
|
14
14
|
level = "warning" if issue.level == "warning" else "error"
|
|
15
|
+
file_path = issue.file_path.as_posix()
|
|
15
16
|
return (
|
|
16
|
-
f"::{level} file={
|
|
17
|
-
f"File {
|
|
17
|
+
f"::{level} file={file_path},line={issue.line_number}::"
|
|
18
|
+
f"File {file_path}, line {issue.line_number}, "
|
|
18
19
|
f"Link {issue.link} {issue.message}."
|
|
19
20
|
)
|
|
20
21
|
|
{markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/markdown.py
RENAMED
|
@@ -69,7 +69,7 @@ class MarkdownRenderer(ReportRenderer):
|
|
|
69
69
|
def _file_link(self, file_path: Path, context: ReportContext) -> str | None:
|
|
70
70
|
if context.output_mode == "ci":
|
|
71
71
|
return _repo_file_link(context.repo_url, file_path) if context.repo_url else None
|
|
72
|
-
return
|
|
72
|
+
return file_path.as_posix()
|
|
73
73
|
|
|
74
74
|
def _format_issue_rows(self, issues: tuple[ReportIssue, ...], context: ReportContext) -> str:
|
|
75
75
|
parts: list[str] = ["<table><thead><tr><th>#</th><th>Link</th><th>Line Number</th></tr></thead><tbody>"]
|
|
@@ -94,9 +94,9 @@ class MarkdownRenderer(ReportRenderer):
|
|
|
94
94
|
file_link = self._file_link(file_report.file_path, context)
|
|
95
95
|
issue_rows = self._format_issue_rows(file_report.errors, context)
|
|
96
96
|
if file_link is None:
|
|
97
|
-
rows.append(f"| `{file_report.file_path}` |" + issue_rows)
|
|
97
|
+
rows.append(f"| `{file_report.file_path.as_posix()}` |" + issue_rows)
|
|
98
98
|
else:
|
|
99
|
-
rows.append(f"| [`{file_report.file_path}`]({file_link}) |" + issue_rows)
|
|
99
|
+
rows.append(f"| [`{file_report.file_path.as_posix()}`]({file_link}) |" + issue_rows)
|
|
100
100
|
return "| File Full Path | Issues |\n|--------|--------|\n" + "".join(rows)
|
|
101
101
|
|
|
102
102
|
def render(self, report: Report) -> str:
|
|
@@ -32,5 +32,5 @@ def sample_report():
|
|
|
32
32
|
),
|
|
33
33
|
),
|
|
34
34
|
)
|
|
35
|
-
context = ReportContext(check_name="check_broken_urls", tool_version="1.2.
|
|
35
|
+
context = ReportContext(check_name="check_broken_urls", tool_version="1.2.2")
|
|
36
36
|
return Report(context=context, files=(file_report,), links_checked=2, files_checked=1)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from pathlib import PureWindowsPath
|
|
2
|
+
|
|
3
|
+
from markdown_checker.reports.model import FileReport
|
|
4
|
+
from markdown_checker.reports.model import Report
|
|
5
|
+
from markdown_checker.reports.model import ReportContext
|
|
6
|
+
from markdown_checker.reports.model import ReportIssue
|
|
7
|
+
from markdown_checker.reports.renderers.annotations import GitHubAnnotationsRenderer
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_github_annotations_renderer_formats_errors_and_warnings(sample_report):
|
|
11
|
+
"""GitHubAnnotationsRenderer emits one ::error/::warning line per issue."""
|
|
12
|
+
result = GitHubAnnotationsRenderer().render(sample_report)
|
|
13
|
+
assert "::error file=docs/usage.rst,line=42::" in result
|
|
14
|
+
assert "::warning file=docs/usage.rst,line=7::" in result
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_github_annotations_renderer_render_lines_levels(sample_report):
|
|
18
|
+
"""render_lines returns (text, level) pairs matching issue levels."""
|
|
19
|
+
lines = GitHubAnnotationsRenderer().render_lines(sample_report)
|
|
20
|
+
levels = {level for _, level in lines}
|
|
21
|
+
assert levels == {"error", "warning"}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_github_annotations_renderer_windows_path_uses_forward_slashes():
|
|
25
|
+
"""A Windows-style file path is rendered with forward slashes in the `file=` annotation
|
|
26
|
+
field, so GitHub can correctly link the annotation back to the file."""
|
|
27
|
+
file_path = PureWindowsPath(r"content\6502_Assembly_Code\README.md")
|
|
28
|
+
issue = ReportIssue(link="./missing.md", line_number=3, file_path=file_path, message="is broken", level="error")
|
|
29
|
+
report = Report(
|
|
30
|
+
context=ReportContext(check_name="check_broken_paths", output_mode="ci"),
|
|
31
|
+
files=(FileReport(file_path=file_path, errors=(issue,)),),
|
|
32
|
+
)
|
|
33
|
+
result = GitHubAnnotationsRenderer().render(report)
|
|
34
|
+
assert "file=content/6502_Assembly_Code/README.md,line=3" in result
|
|
35
|
+
assert "\\" not in result
|
|
@@ -16,7 +16,7 @@ def test_json_renderer_produces_valid_json(sample_report):
|
|
|
16
16
|
def test_json_renderer_includes_tool_version(sample_report):
|
|
17
17
|
"""JsonRenderer includes tool metadata from the report context."""
|
|
18
18
|
data = json.loads(JsonRenderer().render(sample_report))
|
|
19
|
-
assert data["tool"]["version"] == "1.2.
|
|
19
|
+
assert data["tool"]["version"] == "1.2.2"
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def test_json_renderer_respects_custom_indent(sample_report):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
+
from pathlib import PureWindowsPath
|
|
2
3
|
|
|
3
4
|
import pytest
|
|
4
5
|
|
|
@@ -190,6 +191,28 @@ def test_issues_table_ci_mode_with_repo_url_has_clickable_links(two_errors):
|
|
|
190
191
|
assert "[`file.md`](https://github.com/owner/repo/blob/sha/file.md)" in result
|
|
191
192
|
|
|
192
193
|
|
|
194
|
+
def test_issues_table_local_mode_windows_path_uses_forward_slashes():
|
|
195
|
+
"""A Windows-style file path is rendered with forward slashes, not backslashes, so the
|
|
196
|
+
link resolves correctly when viewed on GitHub (backslashes get percent-encoded there)."""
|
|
197
|
+
file_path = PureWindowsPath(r"content\6502_Assembly_Code\README.md")
|
|
198
|
+
issue = ReportIssue(link="./missing.md", line_number=1, file_path=file_path, message="is broken", level="error")
|
|
199
|
+
context = ReportContext(check_name="check_broken_paths", output_mode="local")
|
|
200
|
+
files = (_errors_file_report(file_path, (issue,)),)
|
|
201
|
+
result = MarkdownRenderer()._format_issues_table(files, context)
|
|
202
|
+
assert "[`content/6502_Assembly_Code/README.md`](content/6502_Assembly_Code/README.md)" in result
|
|
203
|
+
assert "\\" not in result
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def test_issue_rows_local_mode_windows_path_uses_forward_slashes():
|
|
207
|
+
"""The per-issue line-number link also uses forward slashes for a Windows-style path."""
|
|
208
|
+
file_path = PureWindowsPath(r"content\6502_Assembly_Code\README.md")
|
|
209
|
+
issue = ReportIssue(link="./missing.md", line_number=5, file_path=file_path, message="is broken", level="error")
|
|
210
|
+
context = ReportContext(check_name="check_broken_paths", output_mode="local")
|
|
211
|
+
result = MarkdownRenderer()._format_issue_rows((issue,), context)
|
|
212
|
+
assert "content/6502_Assembly_Code/README.md#L5" in result
|
|
213
|
+
assert "\\" not in result
|
|
214
|
+
|
|
215
|
+
|
|
193
216
|
def test_issues_table_skips_files_without_errors(two_errors):
|
|
194
217
|
"""Files with only warnings (no errors) are omitted from the table."""
|
|
195
218
|
context = ReportContext(check_name="check_broken_urls")
|
|
@@ -138,7 +138,7 @@ def test_cli_version(runner):
|
|
|
138
138
|
"""Displays version information."""
|
|
139
139
|
result = runner.invoke(main, ["--version"])
|
|
140
140
|
assert result.exit_code == 0
|
|
141
|
-
assert "1.2.
|
|
141
|
+
assert "1.2.2" in result.output
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
def test_cli_ci_mode(runner, resources_dir, monkeypatch, tmp_path):
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
from markdown_checker.reports.renderers.annotations import GitHubAnnotationsRenderer
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def test_github_annotations_renderer_formats_errors_and_warnings(sample_report):
|
|
5
|
-
"""GitHubAnnotationsRenderer emits one ::error/::warning line per issue."""
|
|
6
|
-
result = GitHubAnnotationsRenderer().render(sample_report)
|
|
7
|
-
assert "::error file=docs/usage.rst,line=42::" in result
|
|
8
|
-
assert "::warning file=docs/usage.rst,line=7::" in result
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_github_annotations_renderer_render_lines_levels(sample_report):
|
|
12
|
-
"""render_lines returns (text, level) pairs matching issue levels."""
|
|
13
|
-
lines = GitHubAnnotationsRenderer().render_lines(sample_report)
|
|
14
|
-
levels = {level for _, level in lines}
|
|
15
|
-
assert levels == {"error", "warning"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checks/broken_paths.py
RENAMED
|
File without changes
|
{markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/checks/broken_urls.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/__init__.py
RENAMED
|
File without changes
|
{markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/console.py
RENAMED
|
File without changes
|
{markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/reports/renderers/json.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/extract_links.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{markdown_checker-1.2.0 → markdown_checker-1.2.2}/src/markdown_checker/utils/url_pipeline.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|