Markdown-Checker 1.0.0__tar.gz → 1.0.1__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.0.0/src/markdown_checker.egg-info → markdown_checker-1.0.1}/PKG-INFO +1 -1
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/pyproject.toml +2 -2
- markdown_checker-1.0.1/src/markdown_checker/__init__.py +10 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/checker.py +4 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/cli.py +30 -15
- {markdown_checker-1.0.0 → markdown_checker-1.0.1/src/markdown_checker.egg-info}/PKG-INFO +1 -1
- markdown_checker-1.0.1/src/markdown_checker.egg-info/entry_points.txt +2 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_checker.py +1 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_cli.py +64 -1
- markdown_checker-1.0.0/src/markdown_checker/__init__.py +0 -10
- markdown_checker-1.0.0/src/markdown_checker.egg-info/entry_points.txt +0 -2
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/LICENSE +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/README.md +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/setup.cfg +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/checks/__init__.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/checks/base.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/checks/broken_paths.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/checks/broken_urls.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/checks/locale.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/checks/tracking.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/models/__init__.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/models/base.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/models/config.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/models/path.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/models/url.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/py.typed +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/__init__.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/base.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/format_output.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/markdown.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/templates/paths/broken.md +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/templates/paths/tracking.md +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/templates/urls/broken.md +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/templates/urls/locale.md +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/templates/urls/tracking.md +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/utils/__init__.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/utils/extract_links.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/utils/list_files.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/utils/spinner.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker.egg-info/SOURCES.txt +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker.egg-info/dependency_links.txt +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker.egg-info/requires.txt +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker.egg-info/top_level.txt +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_checks_broken_paths.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_checks_broken_urls.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_checks_locale.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_checks_registry.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_checks_tracking.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_models_base.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_models_path.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_models_url.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_reports.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_utils_extract_links.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_utils_format_output.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_utils_list_files.py +0 -0
- {markdown_checker-1.0.0 → markdown_checker-1.0.1}/tests/test_utils_spinner.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "markdown-checker"
|
|
3
3
|
description= "A markdown link validation reporting tool."
|
|
4
|
-
version = "1.0.
|
|
4
|
+
version = "1.0.1"
|
|
5
5
|
authors = [{ name = "John Aziz", email = "johnaziz269@gmail.com" }]
|
|
6
6
|
maintainers = [{ name = "John Aziz", email = "johnaziz269@gmail.com" }]
|
|
7
7
|
license = {file = "LICENSE"}
|
|
@@ -86,7 +86,7 @@ filterwarnings = ["ignore::DeprecationWarning"]
|
|
|
86
86
|
show_missing = true
|
|
87
87
|
|
|
88
88
|
[project.scripts]
|
|
89
|
-
markdown-checker = "markdown_checker:
|
|
89
|
+
markdown-checker = "markdown_checker:main"
|
|
90
90
|
|
|
91
91
|
[build-system]
|
|
92
92
|
requires = ["setuptools", "wheel"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""
|
|
2
|
+
markdown-checker — a markdown link validation reporting tool.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__version__ = "1.0.1"
|
|
6
|
+
|
|
7
|
+
from markdown_checker.cli import main
|
|
8
|
+
from markdown_checker.models import Config, MarkdownLinkBase, MarkdownPath, MarkdownURL
|
|
9
|
+
|
|
10
|
+
__all__ = ["Config", "main", "MarkdownLinkBase", "MarkdownPath", "MarkdownURL", "__version__"]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
1
2
|
from dataclasses import dataclass, field
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
|
|
@@ -51,6 +52,7 @@ def run_check_on_files(
|
|
|
51
52
|
func: str,
|
|
52
53
|
files_paths: list[Path],
|
|
53
54
|
config: Config,
|
|
55
|
+
progress_callback: Callable[[], None],
|
|
54
56
|
) -> CheckResult:
|
|
55
57
|
"""
|
|
56
58
|
Run a named check across multiple files.
|
|
@@ -59,6 +61,7 @@ def run_check_on_files(
|
|
|
59
61
|
func: Name of the check to run (must be a key in REGISTRY).
|
|
60
62
|
files_paths: List of markdown file paths to check.
|
|
61
63
|
config: Runtime configuration for the check.
|
|
64
|
+
progress_callback: Callback invoked after each file is checked.
|
|
62
65
|
|
|
63
66
|
Returns:
|
|
64
67
|
A CheckResult with per-file issues and total links checked.
|
|
@@ -74,5 +77,6 @@ def run_check_on_files(
|
|
|
74
77
|
result.links_checked += links_count
|
|
75
78
|
if detected_issues:
|
|
76
79
|
result.issues.append((file_path, detected_issues))
|
|
80
|
+
progress_callback()
|
|
77
81
|
|
|
78
82
|
return result
|
|
@@ -9,7 +9,6 @@ from markdown_checker.models.config import Config
|
|
|
9
9
|
from markdown_checker.reports.format_output import format_issues_table
|
|
10
10
|
from markdown_checker.reports.markdown import MarkdownGenerator
|
|
11
11
|
from markdown_checker.utils.list_files import get_files_paths_list
|
|
12
|
-
from markdown_checker.utils.spinner import spinner
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class ListOfStrings(click.Option):
|
|
@@ -32,12 +31,19 @@ class ListOfStrings(click.Option):
|
|
|
32
31
|
|
|
33
32
|
|
|
34
33
|
@click.command()
|
|
34
|
+
@click.argument(
|
|
35
|
+
"src",
|
|
36
|
+
nargs=-1,
|
|
37
|
+
type=click.Path(path_type=Path, exists=True, file_okay=True, dir_okay=True, readable=True),
|
|
38
|
+
metavar="SRC ...",
|
|
39
|
+
required=False,
|
|
40
|
+
)
|
|
35
41
|
@click.option(
|
|
36
42
|
"-d",
|
|
37
43
|
"--dir",
|
|
38
44
|
type=click.Path(path_type=Path, exists=True, file_okay=False, dir_okay=True, readable=True),
|
|
39
45
|
help="Path to the root directory to check.",
|
|
40
|
-
required=
|
|
46
|
+
required=False,
|
|
41
47
|
)
|
|
42
48
|
@click.option(
|
|
43
49
|
"-f",
|
|
@@ -113,7 +119,7 @@ class ListOfStrings(click.Option):
|
|
|
113
119
|
"-to",
|
|
114
120
|
"--timeout",
|
|
115
121
|
type=click.IntRange(0, 50),
|
|
116
|
-
default=
|
|
122
|
+
default=20,
|
|
117
123
|
help="Timeout in seconds for the requests.",
|
|
118
124
|
required=False,
|
|
119
125
|
)
|
|
@@ -139,7 +145,8 @@ class ListOfStrings(click.Option):
|
|
|
139
145
|
@click.pass_context
|
|
140
146
|
def main(
|
|
141
147
|
ctx: click.Context,
|
|
142
|
-
|
|
148
|
+
src: tuple[Path, ...],
|
|
149
|
+
dir: Path | None,
|
|
143
150
|
func: str,
|
|
144
151
|
guide_url: str | None,
|
|
145
152
|
extensions: list[str],
|
|
@@ -152,7 +159,18 @@ def main(
|
|
|
152
159
|
output_file_name: str,
|
|
153
160
|
) -> None:
|
|
154
161
|
"""A markdown link validation reporting tool."""
|
|
155
|
-
|
|
162
|
+
if src:
|
|
163
|
+
files_paths = []
|
|
164
|
+
for p in src:
|
|
165
|
+
if p.is_dir():
|
|
166
|
+
_, dir_files = get_files_paths_list(p, extensions)
|
|
167
|
+
files_paths.extend(dir_files)
|
|
168
|
+
elif p.suffix.lower() in extensions:
|
|
169
|
+
files_paths.append(p)
|
|
170
|
+
elif dir is not None:
|
|
171
|
+
_, files_paths = get_files_paths_list(dir, extensions)
|
|
172
|
+
else:
|
|
173
|
+
raise click.UsageError("Either SRC or --dir must be provided.")
|
|
156
174
|
|
|
157
175
|
# remove files from skip_files list
|
|
158
176
|
files_paths = [file_path for file_path in files_paths if file_path.name not in skip_files]
|
|
@@ -166,11 +184,13 @@ def main(
|
|
|
166
184
|
output_mode="ci" if os.getenv("CI", "false") == "true" else "local",
|
|
167
185
|
)
|
|
168
186
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
with click.progressbar(length=len(files_paths), label="Checking", hidden=config.output_mode == "ci") as bar:
|
|
188
|
+
check_result = run_check_on_files(
|
|
189
|
+
func=func,
|
|
190
|
+
files_paths=files_paths,
|
|
191
|
+
config=config,
|
|
192
|
+
progress_callback=lambda: bar.update(1),
|
|
193
|
+
)
|
|
174
194
|
|
|
175
195
|
click.echo(
|
|
176
196
|
click.style(f"\n🔍 Checked {check_result.links_checked} links in {len(files_paths)} files.", fg="blue"),
|
|
@@ -209,8 +229,3 @@ def main(
|
|
|
209
229
|
|
|
210
230
|
click.echo(click.style("All files are compliant with the guidelines. 🎉", fg="green"), err=False)
|
|
211
231
|
ctx.exit(0)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
def main_with_spinner() -> None:
|
|
215
|
-
with spinner():
|
|
216
|
-
main()
|
|
@@ -140,7 +140,7 @@ def test_cli_version(runner):
|
|
|
140
140
|
"""Displays version information."""
|
|
141
141
|
result = runner.invoke(main, ["--version"])
|
|
142
142
|
assert result.exit_code == 0
|
|
143
|
-
assert "1.0.
|
|
143
|
+
assert "1.0.1" in result.output
|
|
144
144
|
|
|
145
145
|
|
|
146
146
|
def test_cli_ci_mode(runner, resources_dir, monkeypatch, tmp_path):
|
|
@@ -152,3 +152,66 @@ def test_cli_ci_mode(runner, resources_dir, monkeypatch, tmp_path):
|
|
|
152
152
|
["-d", str(resources_dir), "-f", "check_broken_paths", "-o", str(tmp_path / "ci_output")],
|
|
153
153
|
)
|
|
154
154
|
assert result.exit_code == 0
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# --- SRC positional argument ---
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def test_cli_src_single_file(runner, resources_dir):
|
|
161
|
+
"""Runs check on a single file passed as SRC."""
|
|
162
|
+
sample = resources_dir / "sample1.md"
|
|
163
|
+
result = runner.invoke(main, [str(sample), "-f", "check_broken_paths"])
|
|
164
|
+
assert result.exit_code == 0
|
|
165
|
+
assert "Checked" in result.output
|
|
166
|
+
assert "1 files" in result.output
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_cli_src_multiple_files(runner, resources_dir):
|
|
170
|
+
"""Runs check on multiple files passed as SRC."""
|
|
171
|
+
s1 = resources_dir / "sample1.md"
|
|
172
|
+
s2 = resources_dir / "sample2.md"
|
|
173
|
+
result = runner.invoke(main, [str(s1), str(s2), "-f", "check_broken_paths"])
|
|
174
|
+
assert result.exit_code == 0
|
|
175
|
+
assert "Checked" in result.output
|
|
176
|
+
assert "2 files" in result.output
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def test_cli_src_directory(runner, resources_dir):
|
|
180
|
+
"""Passing a directory as SRC recursively discovers files."""
|
|
181
|
+
result = runner.invoke(main, [str(resources_dir), "-f", "check_broken_paths"])
|
|
182
|
+
assert result.exit_code == 0
|
|
183
|
+
assert "Checked" in result.output
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def test_cli_src_mixed_file_and_dir(runner, resources_dir, tmp_path):
|
|
187
|
+
"""Passing both a file and a directory as SRC combines results."""
|
|
188
|
+
extra = tmp_path / "extra.md"
|
|
189
|
+
extra.write_text("# Extra\n[link](https://example.com)\n")
|
|
190
|
+
result = runner.invoke(main, [str(extra), str(resources_dir), "-f", "check_broken_paths"])
|
|
191
|
+
assert result.exit_code == 0
|
|
192
|
+
assert "Checked" in result.output
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def test_cli_src_filters_by_extension(runner, tmp_path):
|
|
196
|
+
"""SRC files not matching --extensions are ignored."""
|
|
197
|
+
md_file = tmp_path / "valid.md"
|
|
198
|
+
md_file.write_text("# Hello\n")
|
|
199
|
+
txt_file = tmp_path / "ignored.txt"
|
|
200
|
+
txt_file.write_text("# Not checked\n")
|
|
201
|
+
result = runner.invoke(main, [str(md_file), str(txt_file), "-f", "check_broken_paths", "-ext", ".md"])
|
|
202
|
+
assert result.exit_code == 0
|
|
203
|
+
assert "1 files" in result.output
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def test_cli_src_takes_precedence_over_dir(runner, resources_dir, tmp_path):
|
|
207
|
+
"""When SRC is provided, --dir is ignored."""
|
|
208
|
+
sample = resources_dir / "sample1.md"
|
|
209
|
+
result = runner.invoke(main, [str(sample), "-d", str(resources_dir), "-f", "check_broken_paths"])
|
|
210
|
+
assert result.exit_code == 0
|
|
211
|
+
assert "1 files" in result.output
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def test_cli_no_src_no_dir_fails(runner):
|
|
215
|
+
"""Fails when neither SRC nor --dir is provided."""
|
|
216
|
+
result = runner.invoke(main, ["-f", "check_broken_paths"])
|
|
217
|
+
assert result.exit_code != 0
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
markdown-checker — a markdown link validation reporting tool.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
__version__ = "1.0.0"
|
|
6
|
-
|
|
7
|
-
from markdown_checker.cli import main, main_with_spinner
|
|
8
|
-
from markdown_checker.models import Config, MarkdownLinkBase, MarkdownPath, MarkdownURL
|
|
9
|
-
|
|
10
|
-
__all__ = ["Config", "main", "main_with_spinner", "MarkdownLinkBase", "MarkdownPath", "MarkdownURL", "__version__"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/checks/broken_paths.py
RENAMED
|
File without changes
|
{markdown_checker-1.0.0 → markdown_checker-1.0.1}/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
|
{markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker/reports/format_output.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.0.0 → markdown_checker-1.0.1}/src/markdown_checker/utils/extract_links.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker.egg-info/requires.txt
RENAMED
|
File without changes
|
{markdown_checker-1.0.0 → markdown_checker-1.0.1}/src/markdown_checker.egg-info/top_level.txt
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
|