Markdown-Checker 0.0.7__tar.gz → 0.0.8__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-0.0.8/MANIFEST.in +6 -0
- {markdown-checker-0.0.7/markdown_checker.egg-info → markdown-checker-0.0.8}/PKG-INFO +5 -3
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/README.md +4 -2
- markdown-checker-0.0.8/markdown_checker/check_markdown.py +52 -0
- markdown-checker-0.0.8/markdown_checker/generators/md_generator.py +51 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker/inputs/input_arguments.py +4 -1
- markdown-checker-0.0.8/markdown_checker/links/__init__.py +0 -0
- markdown-checker-0.0.7/markdown_checker/markdown_checker.py → markdown-checker-0.0.8/markdown_checker/links/link_operations.py +1 -46
- markdown-checker-0.0.8/markdown_checker/paths/__init__.py +0 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker/validate_markdown.py +3 -1
- {markdown-checker-0.0.7 → markdown-checker-0.0.8/markdown_checker.egg-info}/PKG-INFO +5 -3
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker.egg-info/SOURCES.txt +7 -2
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/setup.cfg +1 -1
- markdown-checker-0.0.8/tests/test_markdown_checker.py +46 -0
- markdown-checker-0.0.7/MANIFEST.in +0 -4
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/LICENSE +0 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker/__init__.py +0 -0
- {markdown-checker-0.0.7/markdown_checker/inputs → markdown-checker-0.0.8/markdown_checker/generators}/__init__.py +0 -0
- {markdown-checker-0.0.7/markdown_checker/paths → markdown-checker-0.0.8/markdown_checker/inputs}/__init__.py +0 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker/paths/files_paths_reader.py +0 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker.egg-info/dependency_links.txt +0 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker.egg-info/entry_points.txt +0 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker.egg-info/top_level.txt +0 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/pyproject.toml +0 -0
- {markdown-checker-0.0.7 → markdown-checker-0.0.8}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: markdown-checker
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: A markdown validation reporting tool
|
|
5
5
|
Home-page: https://github.com/john0isaac/markdown-checker
|
|
6
6
|
Author: John Aziz
|
|
@@ -30,9 +30,11 @@ License-File: LICENSE
|
|
|
30
30
|
markdown-checker is a markdown validation reporting tool.
|
|
31
31
|
|
|
32
32
|
# How To
|
|
33
|
+
|
|
33
34
|
1. Run `pip install markdown-checker`.
|
|
34
|
-
2. Run `markdown-checker -d {src} -f {func}`. Replace `{src}` with the directory you want to
|
|
35
|
-
3. The output will be displayed in the terminal.
|
|
35
|
+
2. Run `markdown-checker -d {src} -f {func} -gu {url}`. Replace `{src}` with the directory you want to analyze, {func} with the available functions like check_broken_paths, {gu} with your contribution guidance full URL.
|
|
36
|
+
3. The output will be displayed in the terminal and in a `comments.md` file.
|
|
36
37
|
|
|
37
38
|
# Using markdown-checker in GitHub Actions
|
|
39
|
+
|
|
38
40
|
The tool has been designed to be run within a GitHub workflow using the [action-check-markdown](https://github.com/marketplace/actions/check-markdown) GitHub action. The action will automatically post the output of the tool to your GitHub pull request as a comment.
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
markdown-checker is a markdown validation reporting tool.
|
|
8
8
|
|
|
9
9
|
# How To
|
|
10
|
+
|
|
10
11
|
1. Run `pip install markdown-checker`.
|
|
11
|
-
2. Run `markdown-checker -d {src} -f {func}`. Replace `{src}` with the directory you want to
|
|
12
|
-
3. The output will be displayed in the terminal.
|
|
12
|
+
2. Run `markdown-checker -d {src} -f {func} -gu {url}`. Replace `{src}` with the directory you want to analyze, {func} with the available functions like check_broken_paths, {gu} with your contribution guidance full URL.
|
|
13
|
+
3. The output will be displayed in the terminal and in a `comments.md` file.
|
|
13
14
|
|
|
14
15
|
# Using markdown-checker in GitHub Actions
|
|
16
|
+
|
|
15
17
|
The tool has been designed to be run within a GitHub workflow using the [action-check-markdown](https://github.com/marketplace/actions/check-markdown) GitHub action. The action will automatically post the output of the tool to your GitHub pull request as a comment.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module providing automatic checks functionality to markdown files
|
|
3
|
+
following some Guidelines
|
|
4
|
+
"""
|
|
5
|
+
from markdown_checker.links.link_operations import (
|
|
6
|
+
get_links_from_file,
|
|
7
|
+
get_paths_from_links,
|
|
8
|
+
get_urls_from_links,
|
|
9
|
+
check_paths_exists,
|
|
10
|
+
check_url_locale,
|
|
11
|
+
check_url_tracking
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def check_broken_links(file_path : str, link_type : str , check_type: str) -> str:
|
|
16
|
+
"""function that checks if urls and hyperlinks are broken
|
|
17
|
+
|
|
18
|
+
Keyword arguments:
|
|
19
|
+
file_path -- a path to text file to check
|
|
20
|
+
link_type -- path or url
|
|
21
|
+
check_type -- broken or tracking or locale
|
|
22
|
+
Return: broken links and associated file path
|
|
23
|
+
"""
|
|
24
|
+
all_links = get_links_from_file(file_path)
|
|
25
|
+
|
|
26
|
+
# check if file has links
|
|
27
|
+
if len(all_links) > 0:
|
|
28
|
+
formatted_output = f"|<code>{file_path}</code>|"
|
|
29
|
+
if link_type == "path":
|
|
30
|
+
paths = get_paths_from_links(all_links)
|
|
31
|
+
if check_type == "broken" and len(paths) > 0:
|
|
32
|
+
broken_path = check_paths_exists(file_path, paths)
|
|
33
|
+
if len (broken_path) > 0:
|
|
34
|
+
formatted_output += f'<code>{broken_path}</code>|\n'
|
|
35
|
+
return formatted_output
|
|
36
|
+
elif check_type == "tracking" and len(paths) > 0:
|
|
37
|
+
tracking_id_paths = check_url_tracking(paths)
|
|
38
|
+
if len(tracking_id_paths) > 0:
|
|
39
|
+
formatted_output += f'<code>{tracking_id_paths}</code>|\n'
|
|
40
|
+
return formatted_output
|
|
41
|
+
elif link_type == "url":
|
|
42
|
+
urls = get_urls_from_links(all_links)
|
|
43
|
+
if check_type == "tracking" and len(urls) > 0:
|
|
44
|
+
tracking_id_urls = check_url_tracking(urls)
|
|
45
|
+
if len(tracking_id_urls) > 0:
|
|
46
|
+
formatted_output += f'<code>{tracking_id_urls}</code>|\n'
|
|
47
|
+
return formatted_output
|
|
48
|
+
elif check_type == "locale" and len(urls) > 0:
|
|
49
|
+
country_locale_urls = check_url_locale(urls)
|
|
50
|
+
if len(country_locale_urls) > 0:
|
|
51
|
+
formatted_output += f'<code>{country_locale_urls}</code>|\n'
|
|
52
|
+
return formatted_output
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
CHECK_BROKEN_PATHS = """# Check Broken Paths
|
|
2
|
+
|
|
3
|
+
We have automatically detected the following broken relative paths in your lessons. Review and fix the paths to resolve this issue.
|
|
4
|
+
|
|
5
|
+
Check the file paths and associated broken paths inside them."""
|
|
6
|
+
CHECK_PATHS_TRACKING = """# Check Missing Tracking from Paths
|
|
7
|
+
|
|
8
|
+
We have automatically detected missing tracking id from the following relative paths in your lessons. Review and add tracking to paths to resolve this issue.
|
|
9
|
+
|
|
10
|
+
Check the file paths and associated paths inside them."""
|
|
11
|
+
CHECK_URLS_TRACKING = """# Check Missing Tracking from URLs
|
|
12
|
+
|
|
13
|
+
We have automatically detected missing tracking id from the following URLs in your lessons. Review and add tracking to URLs to resolve this issue.
|
|
14
|
+
|
|
15
|
+
Check the file paths and associated URLs inside them."""
|
|
16
|
+
CHECK_URLS_LOCALE = """# Check Country Locale in URLs
|
|
17
|
+
|
|
18
|
+
We have automatically detected added country locale to URLs in your lessons. Review and remove country specific locale from URLs to resolve this issue.
|
|
19
|
+
|
|
20
|
+
Check the file paths and associated URLs inside them."""
|
|
21
|
+
|
|
22
|
+
def write_md_file(generated_md: str) -> None:
|
|
23
|
+
"""Write the formatted output to a markdown file"""
|
|
24
|
+
with open("comment.md", "w", encoding="utf-8") as file:
|
|
25
|
+
file.write(generated_md)
|
|
26
|
+
|
|
27
|
+
def generate_md(formatted_output: str, function_name: str, contributing_guide_url: str) -> None:
|
|
28
|
+
"""Generate markdown file based on the formatted output, function name, and contributing guide URL.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
formatted_output (str): The formatted output to be written to the markdown file.
|
|
32
|
+
function_name (str): The name of the function to determine the header for the markdown file.
|
|
33
|
+
contributing_guide_url (str): The URL of the contributing guide to be included in the markdown file.
|
|
34
|
+
|
|
35
|
+
Raises:
|
|
36
|
+
ValueError: If an invalid function name is provided.
|
|
37
|
+
|
|
38
|
+
"""
|
|
39
|
+
contributing_guide_line = f" For more details, check our [Contributing Guide]({contributing_guide_url}).\n\n"
|
|
40
|
+
if function_name == "check_broken_paths":
|
|
41
|
+
formatted_output = CHECK_BROKEN_PATHS + contributing_guide_line + formatted_output
|
|
42
|
+
elif function_name == "check_paths_tracking":
|
|
43
|
+
formatted_output = CHECK_PATHS_TRACKING + contributing_guide_line + formatted_output
|
|
44
|
+
elif function_name == "check_urls_tracking":
|
|
45
|
+
formatted_output = CHECK_URLS_TRACKING + contributing_guide_line + formatted_output
|
|
46
|
+
elif function_name == "check_urls_locale":
|
|
47
|
+
formatted_output = CHECK_URLS_LOCALE + contributing_guide_line + formatted_output
|
|
48
|
+
else:
|
|
49
|
+
raise ValueError("Invalid function name")
|
|
50
|
+
|
|
51
|
+
write_md_file(formatted_output)
|
{markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker/inputs/input_arguments.py
RENAMED
|
@@ -33,4 +33,7 @@ def get_input_args() -> None:
|
|
|
33
33
|
'check_urls_tracking',
|
|
34
34
|
'check_urls_locale'])
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
parser.add_argument('-gu', '--guide-url', type = str, default = 'https://github.com/john0isaac/markdown-checker/blob/main/CONTRIBUTING.md',
|
|
37
|
+
help = 'full url of your contributing guide', required=True)
|
|
38
|
+
|
|
39
|
+
return parser.parse_args()
|
|
File without changes
|
|
@@ -1,50 +1,5 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Module providing automatic checks functionality to markdown files
|
|
3
|
-
following some Guidelines
|
|
4
|
-
"""
|
|
5
|
-
import os
|
|
6
1
|
import re
|
|
7
|
-
|
|
8
|
-
# Helper Functions
|
|
9
|
-
|
|
10
|
-
def check_broken_links(file_path : str, link_type : str , check_type: str) -> str:
|
|
11
|
-
"""function that checks if urls and hyperlinks are broken
|
|
12
|
-
|
|
13
|
-
Keyword arguments:
|
|
14
|
-
file_path -- a path to text file to check
|
|
15
|
-
link_type -- path or url
|
|
16
|
-
check_type -- broken or tracking or locale
|
|
17
|
-
Return: broken links and associated file path
|
|
18
|
-
"""
|
|
19
|
-
all_links = get_links_from_file(file_path)
|
|
20
|
-
|
|
21
|
-
# check if file has links
|
|
22
|
-
if len(all_links) > 0:
|
|
23
|
-
formatted_output = f"|<code>{file_path}</code>|"
|
|
24
|
-
if link_type == "path":
|
|
25
|
-
paths = get_paths_from_links(all_links)
|
|
26
|
-
if check_type == "broken" and len(paths) > 0:
|
|
27
|
-
broken_path = check_paths_exists(file_path, paths)
|
|
28
|
-
if len (broken_path) > 0:
|
|
29
|
-
formatted_output += f'<code>{broken_path}</code>|\n'
|
|
30
|
-
return formatted_output
|
|
31
|
-
elif check_type == "tracking" and len(paths) > 0:
|
|
32
|
-
tracking_id_paths = check_url_tracking(paths)
|
|
33
|
-
if len(tracking_id_paths) > 0:
|
|
34
|
-
formatted_output += f'<code>{tracking_id_paths}</code>|\n'
|
|
35
|
-
return formatted_output
|
|
36
|
-
elif link_type == "url":
|
|
37
|
-
urls = get_urls_from_links(all_links)
|
|
38
|
-
if check_type == "tracking" and len(urls) > 0:
|
|
39
|
-
tracking_id_urls = check_url_tracking(urls)
|
|
40
|
-
if len(tracking_id_urls) > 0:
|
|
41
|
-
formatted_output += f'<code>{tracking_id_urls}</code>|\n'
|
|
42
|
-
return formatted_output
|
|
43
|
-
elif check_type == "locale" and len(urls) > 0:
|
|
44
|
-
country_locale_urls = check_url_locale(urls)
|
|
45
|
-
if len(country_locale_urls) > 0:
|
|
46
|
-
formatted_output += f'<code>{country_locale_urls}</code>|\n'
|
|
47
|
-
return formatted_output
|
|
2
|
+
import os
|
|
48
3
|
|
|
49
4
|
def get_links_from_file(file_path: str) -> list:
|
|
50
5
|
"""function to get an array of markdown links from a file
|
|
File without changes
|
|
@@ -4,8 +4,9 @@ Module providing automatic checks functionality to markdown files
|
|
|
4
4
|
following some Guidelines
|
|
5
5
|
"""
|
|
6
6
|
from markdown_checker.inputs.input_arguments import get_input_args
|
|
7
|
-
from markdown_checker.
|
|
7
|
+
from markdown_checker.check_markdown import check_broken_links
|
|
8
8
|
from markdown_checker.paths.files_paths_reader import get_files_paths_list
|
|
9
|
+
from markdown_checker.generators.md_generator import generate_md
|
|
9
10
|
|
|
10
11
|
def main() -> None:
|
|
11
12
|
"""Main program get inputs and run checks"""
|
|
@@ -41,6 +42,7 @@ def main() -> None:
|
|
|
41
42
|
if formatted_output != "":
|
|
42
43
|
formatted_output = "| File Full Path | Issues |\n|--------|--------|\n" + formatted_output
|
|
43
44
|
print(formatted_output)
|
|
45
|
+
generate_md(formatted_output, in_arg.func, in_arg.guide_url)
|
|
44
46
|
|
|
45
47
|
if __name__ == "__main__":
|
|
46
48
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: markdown-checker
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: A markdown validation reporting tool
|
|
5
5
|
Home-page: https://github.com/john0isaac/markdown-checker
|
|
6
6
|
Author: John Aziz
|
|
@@ -30,9 +30,11 @@ License-File: LICENSE
|
|
|
30
30
|
markdown-checker is a markdown validation reporting tool.
|
|
31
31
|
|
|
32
32
|
# How To
|
|
33
|
+
|
|
33
34
|
1. Run `pip install markdown-checker`.
|
|
34
|
-
2. Run `markdown-checker -d {src} -f {func}`. Replace `{src}` with the directory you want to
|
|
35
|
-
3. The output will be displayed in the terminal.
|
|
35
|
+
2. Run `markdown-checker -d {src} -f {func} -gu {url}`. Replace `{src}` with the directory you want to analyze, {func} with the available functions like check_broken_paths, {gu} with your contribution guidance full URL.
|
|
36
|
+
3. The output will be displayed in the terminal and in a `comments.md` file.
|
|
36
37
|
|
|
37
38
|
# Using markdown-checker in GitHub Actions
|
|
39
|
+
|
|
38
40
|
The tool has been designed to be run within a GitHub workflow using the [action-check-markdown](https://github.com/marketplace/actions/check-markdown) GitHub action. The action will automatically post the output of the tool to your GitHub pull request as a comment.
|
|
@@ -5,14 +5,19 @@ pyproject.toml
|
|
|
5
5
|
setup.cfg
|
|
6
6
|
setup.py
|
|
7
7
|
markdown_checker/__init__.py
|
|
8
|
-
markdown_checker/
|
|
8
|
+
markdown_checker/check_markdown.py
|
|
9
9
|
markdown_checker/validate_markdown.py
|
|
10
10
|
markdown_checker.egg-info/PKG-INFO
|
|
11
11
|
markdown_checker.egg-info/SOURCES.txt
|
|
12
12
|
markdown_checker.egg-info/dependency_links.txt
|
|
13
13
|
markdown_checker.egg-info/entry_points.txt
|
|
14
14
|
markdown_checker.egg-info/top_level.txt
|
|
15
|
+
markdown_checker/generators/__init__.py
|
|
16
|
+
markdown_checker/generators/md_generator.py
|
|
15
17
|
markdown_checker/inputs/__init__.py
|
|
16
18
|
markdown_checker/inputs/input_arguments.py
|
|
19
|
+
markdown_checker/links/__init__.py
|
|
20
|
+
markdown_checker/links/link_operations.py
|
|
17
21
|
markdown_checker/paths/__init__.py
|
|
18
|
-
markdown_checker/paths/files_paths_reader.py
|
|
22
|
+
markdown_checker/paths/files_paths_reader.py
|
|
23
|
+
tests/test_markdown_checker.py
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module to check paths in markdown files.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
def check_broken_paths():
|
|
8
|
+
"""
|
|
9
|
+
Function to check for broken paths.
|
|
10
|
+
"""
|
|
11
|
+
print("check_broken_paths was called")
|
|
12
|
+
subprocess.run(["markdown-checker", "-d", "./tests/resources/", "-f", "check_broken_paths", "-gu", "https://github.com/john0isaac/markdown-checker/blob/main/CONTRIBUTING.md"], check=False)
|
|
13
|
+
|
|
14
|
+
def check_paths_tracking():
|
|
15
|
+
"""
|
|
16
|
+
Function to check paths tracking.
|
|
17
|
+
"""
|
|
18
|
+
print("check_paths_tracking was called")
|
|
19
|
+
subprocess.run(["markdown-checker", "-d", "./tests/resources/", "-f", "check_paths_tracking", "-gu", "https://github.com/john0isaac/markdown-checker/blob/main/CONTRIBUTING.md"], check=False)
|
|
20
|
+
|
|
21
|
+
def check_urls_tracking():
|
|
22
|
+
"""
|
|
23
|
+
Function to check URLs tracking.
|
|
24
|
+
"""
|
|
25
|
+
print("check_urls_tracking was called")
|
|
26
|
+
subprocess.run(["markdown-checker", "-d", "./tests/resources/", "-f", "check_urls_tracking", "-gu", "https://github.com/john0isaac/markdown-checker/blob/main/CONTRIBUTING.md"], check=False)
|
|
27
|
+
|
|
28
|
+
def check_urls_locale():
|
|
29
|
+
"""
|
|
30
|
+
Function to check URLs locale.
|
|
31
|
+
"""
|
|
32
|
+
print("check_urls_locale was called")
|
|
33
|
+
subprocess.run(["markdown-checker", "-d", "./tests/resources/", "-f", "check_urls_locale", "-gu", "https://github.com/john0isaac/markdown-checker/blob/main/CONTRIBUTING.md"], check=False)
|
|
34
|
+
|
|
35
|
+
mydict = {1:check_broken_paths, 2:check_paths_tracking, 3:check_urls_tracking, 4:check_urls_locale}
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
choices = list(map(int,input("Do you want to: \n(1) Run check_broken_paths \n(2) Run check_paths_tracking \n(3) Run check_urls_tracking \n(4) Run check_urls_locale \n").split()))
|
|
39
|
+
except ValueError:
|
|
40
|
+
print("Please input number")
|
|
41
|
+
|
|
42
|
+
for choice in choices:
|
|
43
|
+
if 0 < choice and choice < 5:
|
|
44
|
+
mydict[choice]()
|
|
45
|
+
else:
|
|
46
|
+
print("That is not between 1 and 4! Try again:")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker/paths/files_paths_reader.py
RENAMED
|
File without changes
|
{markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{markdown-checker-0.0.7 → markdown-checker-0.0.8}/markdown_checker.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|