mkdocs-htmlproofer-plugin 1.3.0__tar.gz → 1.4.0__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.
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/PKG-INFO +18 -2
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/htmlproofer/plugin.py +28 -6
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/mkdocs_htmlproofer_plugin.egg-info/PKG-INFO +18 -2
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/setup.py +1 -1
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/LICENSE.md +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/README.md +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/htmlproofer/__init__.py +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/mkdocs_htmlproofer_plugin.egg-info/SOURCES.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/mkdocs_htmlproofer_plugin.egg-info/dependency_links.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/mkdocs_htmlproofer_plugin.egg-info/entry_points.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/mkdocs_htmlproofer_plugin.egg-info/requires.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/mkdocs_htmlproofer_plugin.egg-info/top_level.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/pyproject.toml +0 -0
- {mkdocs-htmlproofer-plugin-1.3.0 → mkdocs_htmlproofer_plugin-1.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-htmlproofer-plugin
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A MkDocs plugin that validates URL in rendered HTML files
|
|
5
5
|
Home-page: https://github.com/manuzhang/mkdocs-htmlproofer-plugin
|
|
6
6
|
Author: Manu Zhang
|
|
@@ -20,6 +20,22 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Requires-Python: >=3.8
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE.md
|
|
23
|
+
Requires-Dist: mkdocs>=1.4.0
|
|
24
|
+
Requires-Dist: Markdown
|
|
25
|
+
Requires-Dist: requests
|
|
26
|
+
Requires-Dist: beautifulsoup4
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: classifier
|
|
30
|
+
Dynamic: description
|
|
31
|
+
Dynamic: description-content-type
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: keywords
|
|
34
|
+
Dynamic: license
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: requires-python
|
|
38
|
+
Dynamic: summary
|
|
23
39
|
|
|
24
40
|
# mkdocs-htmlproofer-plugin [](https://pypi.org/project/mkdocs-htmlproofer-plugin)
|
|
25
41
|
|
|
@@ -3,6 +3,7 @@ from functools import lru_cache, partial
|
|
|
3
3
|
import os.path
|
|
4
4
|
import pathlib
|
|
5
5
|
import re
|
|
6
|
+
import time
|
|
6
7
|
from typing import Dict, List, Optional, Set
|
|
7
8
|
import urllib.parse
|
|
8
9
|
import uuid
|
|
@@ -71,6 +72,7 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
71
72
|
('ignore_urls', config_options.Type(list, default=[])),
|
|
72
73
|
('warn_on_ignored_urls', config_options.Type(bool, default=False)),
|
|
73
74
|
('ignore_pages', config_options.Type(list, default=[])),
|
|
75
|
+
('retry_max_times', config_options.Type(int, default=0)),
|
|
74
76
|
)
|
|
75
77
|
|
|
76
78
|
def __init__(self):
|
|
@@ -113,12 +115,13 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
113
115
|
strainer = SoupStrainer(('a', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'sup', 'img'))
|
|
114
116
|
|
|
115
117
|
content = output_content if self.config['validate_rendered_template'] else page.content
|
|
116
|
-
soup = BeautifulSoup(content, 'html.parser', parse_only=strainer)
|
|
118
|
+
soup = BeautifulSoup(str(content), 'html.parser', parse_only=strainer)
|
|
117
119
|
|
|
118
|
-
all_element_ids = set(tag['id'] for tag in soup.select('[id]'))
|
|
120
|
+
all_element_ids = set(str(tag['id']) for tag in soup.select('[id]'))
|
|
119
121
|
all_element_ids.add('') # Empty anchor is commonly used, but not real
|
|
120
122
|
|
|
121
|
-
urls = set(a['href'] for a in soup.find_all('a', href=True)) |
|
|
123
|
+
urls = (set(str(a['href']) for a in soup.find_all('a', href=True)) |
|
|
124
|
+
set(str(img['src']) for img in soup.find_all('img')))
|
|
122
125
|
|
|
123
126
|
for url in urls:
|
|
124
127
|
if any(fnmatch.fnmatch(url, ignore_url) for ignore_url in self.config['ignore_urls']):
|
|
@@ -131,9 +134,7 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
131
134
|
if self.config['warn_on_ignored_urls']:
|
|
132
135
|
log_warning(f"ignoring URL {url} from {page.file.src_path}")
|
|
133
136
|
else:
|
|
134
|
-
|
|
135
|
-
if self.bad_url(url_status) and self.is_error(self.config, url, url_status):
|
|
136
|
-
self.report_invalid_url(url, url_status, page.file.src_path)
|
|
137
|
+
self.check_url(url, page.file.src_path, all_element_ids, opt_files)
|
|
137
138
|
|
|
138
139
|
def report_invalid_url(self, url, url_status, src_path):
|
|
139
140
|
error = f'invalid url - {url} [{url_status}] [{src_path}]'
|
|
@@ -170,6 +171,27 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
170
171
|
except requests.exceptions.ConnectionError:
|
|
171
172
|
return -1
|
|
172
173
|
|
|
174
|
+
def check_url(
|
|
175
|
+
self,
|
|
176
|
+
url: str,
|
|
177
|
+
src_path: str,
|
|
178
|
+
all_element_ids: Set[str],
|
|
179
|
+
files: Dict[str, File],
|
|
180
|
+
) -> None:
|
|
181
|
+
retry_times = 0
|
|
182
|
+
retry_max_times = self.config['retry_max_times']
|
|
183
|
+
retry_duration = 2
|
|
184
|
+
while retry_times <= retry_max_times:
|
|
185
|
+
url_status = self.get_url_status(url, src_path, all_element_ids, files)
|
|
186
|
+
retry_times += 1
|
|
187
|
+
if self.bad_url(url_status) and self.is_error(self.config, url, url_status):
|
|
188
|
+
if retry_times > retry_max_times:
|
|
189
|
+
self.report_invalid_url(url, url_status, src_path)
|
|
190
|
+
else:
|
|
191
|
+
log_info(f"Retrying URL {url} from {src_path} after {retry_duration} seconds...")
|
|
192
|
+
time.sleep(retry_duration)
|
|
193
|
+
retry_duration *= 2
|
|
194
|
+
|
|
173
195
|
def get_url_status(
|
|
174
196
|
self,
|
|
175
197
|
url: str,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-htmlproofer-plugin
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A MkDocs plugin that validates URL in rendered HTML files
|
|
5
5
|
Home-page: https://github.com/manuzhang/mkdocs-htmlproofer-plugin
|
|
6
6
|
Author: Manu Zhang
|
|
@@ -20,6 +20,22 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Requires-Python: >=3.8
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE.md
|
|
23
|
+
Requires-Dist: mkdocs>=1.4.0
|
|
24
|
+
Requires-Dist: Markdown
|
|
25
|
+
Requires-Dist: requests
|
|
26
|
+
Requires-Dist: beautifulsoup4
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: author-email
|
|
29
|
+
Dynamic: classifier
|
|
30
|
+
Dynamic: description
|
|
31
|
+
Dynamic: description-content-type
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: keywords
|
|
34
|
+
Dynamic: license
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: requires-python
|
|
38
|
+
Dynamic: summary
|
|
23
39
|
|
|
24
40
|
# mkdocs-htmlproofer-plugin [](https://pypi.org/project/mkdocs-htmlproofer-plugin)
|
|
25
41
|
|
|
@@ -9,7 +9,7 @@ def read(fname: str):
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name='mkdocs-htmlproofer-plugin',
|
|
12
|
-
version='1.
|
|
12
|
+
version='1.4.0',
|
|
13
13
|
description='A MkDocs plugin that validates URL in rendered HTML files',
|
|
14
14
|
long_description=read('README.md'),
|
|
15
15
|
long_description_content_type='text/markdown',
|
|
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
|