Markdown-Checker 0.0.5__tar.gz → 0.0.7__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.
Files changed (21) hide show
  1. markdown-checker-0.0.7/MANIFEST.in +4 -0
  2. {markdown-checker-0.0.5/markdown_checker.egg-info → markdown-checker-0.0.7}/PKG-INFO +2 -2
  3. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/README.md +1 -1
  4. markdown-checker-0.0.5/markdown_checker/get_input_args/get_input_args.py → markdown-checker-0.0.7/markdown_checker/inputs/input_arguments.py +0 -1
  5. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/markdown_checker/markdown_checker.py +6 -51
  6. markdown-checker-0.0.7/markdown_checker/paths/__init__.py +0 -0
  7. markdown-checker-0.0.7/markdown_checker/paths/files_paths_reader.py +42 -0
  8. markdown-checker-0.0.7/markdown_checker/validate_markdown.py +46 -0
  9. {markdown-checker-0.0.5 → markdown-checker-0.0.7/markdown_checker.egg-info}/PKG-INFO +2 -2
  10. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/markdown_checker.egg-info/SOURCES.txt +4 -2
  11. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/setup.cfg +1 -1
  12. markdown-checker-0.0.5/MANIFEST.in +0 -3
  13. markdown-checker-0.0.5/markdown_checker/validate_markdown.py +0 -45
  14. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/LICENSE +0 -0
  15. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/markdown_checker/__init__.py +0 -0
  16. {markdown-checker-0.0.5/markdown_checker/get_input_args → markdown-checker-0.0.7/markdown_checker/inputs}/__init__.py +0 -0
  17. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/markdown_checker.egg-info/dependency_links.txt +0 -0
  18. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/markdown_checker.egg-info/entry_points.txt +0 -0
  19. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/markdown_checker.egg-info/top_level.txt +0 -0
  20. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/pyproject.toml +0 -0
  21. {markdown-checker-0.0.5 → markdown-checker-0.0.7}/setup.py +0 -0
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include markdown_checker/inputs/*
3
+ include markdown_checker/paths/*
4
+ include setup.cfg
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown-checker
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: A markdown validation reporting tool
5
5
  Home-page: https://github.com/john0isaac/markdown-checker
6
6
  Author: John Aziz
@@ -35,4 +35,4 @@ markdown-checker is a markdown validation reporting tool.
35
35
  3. The output will be displayed in the terminal.
36
36
 
37
37
  # Using markdown-checker in GitHub Actions
38
- The tool has been designed to be run within a GitHub workflow using the [action-check-markdown](https://github.com/marketplace/actions/action-check-markdown) GitHub action. The action will automatically post the output of the tool to your GitHub pull request as a comment.
38
+ 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.
@@ -12,4 +12,4 @@ markdown-checker is a markdown validation reporting tool.
12
12
  3. The output will be displayed in the terminal.
13
13
 
14
14
  # Using markdown-checker in GitHub Actions
15
- The tool has been designed to be run within a GitHub workflow using the [action-check-markdown](https://github.com/marketplace/actions/action-check-markdown) GitHub action. The action will automatically post the output of the tool to your GitHub pull request as a comment.
15
+ 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.
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  """
3
2
  Module providing automatic checks functionality to markdown files
4
3
  following some Guidelines
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  """
3
2
  Module providing automatic checks functionality to markdown files
4
3
  following some Guidelines
@@ -8,50 +7,6 @@ import re
8
7
 
9
8
  # Helper Functions
10
9
 
11
- def get_lessons_paths(root_path: str) -> dict:
12
- """function to compile a dictionary of directories
13
-
14
- Keyword arguments:
15
- root_path -- directory to go through looking for md files
16
- Return: formatted dictionary with directories as key and an array of files as values
17
- """
18
- lessons = {}
19
- # add root path to the dictionary
20
- lessons[root_path] = []
21
- pass_list = ['CODE_OF_CONDUCT.md', 'CONTRIBUTING.md', 'SECURITY.md']
22
- # get lessons folders
23
- for item in os.listdir(root_path):
24
- if os.path.isdir(os.path.join(root_path, item)):
25
- lessons[item] = []
26
-
27
- # get lesson exercises (md, ipynb files)
28
- for lesson, _ in lessons.items():
29
- if lesson != root_path:
30
- for item in os.listdir(os.path.join(root_path, lesson)):
31
- # check for translations directories
32
- if os.path.isdir(os.path.join(root_path, lesson, item)):
33
- for sub_item in os.listdir(os.path.join(root_path, lesson, item)):
34
- if os.path.isdir(os.path.join(root_path, lesson, item, sub_item)):
35
- for sub_item2 in os.listdir(os.path.join(root_path, lesson, item, sub_item)):
36
- # check for .md and .ipynb files and store them
37
- if sub_item2.lower().endswith(('.md', '.ipynb')) and sub_item2 not in pass_list:
38
- lessons[lesson].append(os.path.join(item, sub_item, sub_item2))
39
- # check for .md and .ipynb files and store them
40
- elif sub_item.lower().endswith(('.md', '.ipynb')) and sub_item not in pass_list:
41
- lessons[lesson].append(os.path.join(item, sub_item))
42
- # check for .md and .ipynb files and store them
43
- elif item.lower().endswith(('.md', '.ipynb')) and item not in pass_list:
44
- lessons[lesson].append(item)
45
- # get .md and .ipynb in root directory
46
- for item in os.listdir(root_path):
47
- if item.lower().endswith(('.md', '.ipynb')) and item not in pass_list:
48
- lessons[root_path].append(item)
49
-
50
- # check to remove folders that don't have .md files in them
51
- lessons = {key: values for key, values in lessons.items() if len(values) > 0}
52
-
53
- return lessons
54
-
55
10
  def check_broken_links(file_path : str, link_type : str , check_type: str) -> str:
56
11
  """function that checks if urls and hyperlinks are broken
57
12
 
@@ -65,30 +20,30 @@ def check_broken_links(file_path : str, link_type : str , check_type: str) -> st
65
20
 
66
21
  # check if file has links
67
22
  if len(all_links) > 0:
68
- formatted_output = f" FILE '{file_path}'\n"
23
+ formatted_output = f"|<code>{file_path}</code>|"
69
24
  if link_type == "path":
70
25
  paths = get_paths_from_links(all_links)
71
26
  if check_type == "broken" and len(paths) > 0:
72
27
  broken_path = check_paths_exists(file_path, paths)
73
28
  if len (broken_path) > 0:
74
- formatted_output += f' has the following broken relative paths {broken_path}\n'
29
+ formatted_output += f'<code>{broken_path}</code>|\n'
75
30
  return formatted_output
76
31
  elif check_type == "tracking" and len(paths) > 0:
77
32
  tracking_id_paths = check_url_tracking(paths)
78
33
  if len(tracking_id_paths) > 0:
79
- formatted_output += f' has the following paths with no tracking id {tracking_id_paths}\n'
34
+ formatted_output += f'<code>{tracking_id_paths}</code>|\n'
80
35
  return formatted_output
81
36
  elif link_type == "url":
82
37
  urls = get_urls_from_links(all_links)
83
38
  if check_type == "tracking" and len(urls) > 0:
84
39
  tracking_id_urls = check_url_tracking(urls)
85
40
  if len(tracking_id_urls) > 0:
86
- formatted_output += f' has the following links with no tracking id {tracking_id_urls}\n'
41
+ formatted_output += f'<code>{tracking_id_urls}</code>|\n'
87
42
  return formatted_output
88
43
  elif check_type == "locale" and len(urls) > 0:
89
44
  country_locale_urls = check_url_locale(urls)
90
45
  if len(country_locale_urls) > 0:
91
- formatted_output += f' has the following links with country locale {country_locale_urls}\n'
46
+ formatted_output += f'<code>{country_locale_urls}</code>|\n'
92
47
  return formatted_output
93
48
 
94
49
  def get_links_from_file(file_path: str) -> list:
@@ -187,4 +142,4 @@ def get_paths_from_file(file_path: str) -> list:
187
142
  matches = re.finditer(path_pattern, data)
188
143
  for matched_group in matches:
189
144
  paths.append(matched_group.group())
190
- return paths
145
+ return paths
@@ -0,0 +1,42 @@
1
+ """
2
+ This module contains a function to get a list of file paths from a root directory and
3
+ its subdirectories, filtered by file extension.
4
+
5
+ The main function in this module is `get_files_paths_list`.
6
+
7
+ Functions:
8
+ - get_files_paths_list(root_path: str, extension: list = None) -> list
9
+ """
10
+
11
+ import os
12
+
13
+ def get_files_paths_list(root_path: str, extensions: list = None) -> list:
14
+ """
15
+ function returns a list of files in a directory and its subdirectories,
16
+ filtered by file extensions.
17
+
18
+ Keyword arguments:
19
+ root_path (str): The root directory from which to start the search.
20
+ extensions (list, optional): A list of file extensions to filter by.
21
+ Defaults to [".md", ".ipynb"].
22
+
23
+ Returns:
24
+ list: A list of file paths that match the given file extensions.
25
+ """
26
+ if extensions is None:
27
+ extensions = [".md", ".ipynb"]
28
+
29
+ sub_folders, files_paths = [], []
30
+
31
+ for f in os.scandir(root_path):
32
+ if f.is_dir():
33
+ sub_folders.append(f.path)
34
+ if f.is_file():
35
+ if os.path.splitext(f.name)[1].lower() in extensions:
36
+ files_paths.append(f.path)
37
+
38
+ for directory in list(sub_folders):
39
+ sf, f = get_files_paths_list(directory, extensions)
40
+ sub_folders.extend(sf)
41
+ files_paths.extend(f)
42
+ return sub_folders, files_paths
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Module providing automatic checks functionality to markdown files
4
+ following some Guidelines
5
+ """
6
+ from markdown_checker.inputs.input_arguments import get_input_args
7
+ from markdown_checker.markdown_checker import check_broken_links
8
+ from markdown_checker.paths.files_paths_reader import get_files_paths_list
9
+
10
+ def main() -> None:
11
+ """Main program get inputs and run checks"""
12
+
13
+ # get input arguments directory, function to run
14
+ in_arg = get_input_args()
15
+
16
+ _, files_paths = get_files_paths_list(in_arg.dir)
17
+
18
+ pass_list = ['./CODE_OF_CONDUCT.md', './CONTRIBUTING.md', './SECURITY.md', '.\CODE_OF_CONDUCT.md', '.\CONTRIBUTING.md', '.\SECURITY.md']
19
+ files_paths = [file_path for file_path in files_paths if file_path not in pass_list]
20
+
21
+ formatted_output = ""
22
+
23
+ # iterate over the files to validate the content
24
+ for file_path in files_paths:
25
+ if "check_broken_paths" in in_arg.func:
26
+ broken_paths = check_broken_links(file_path, "path" , "broken")
27
+ if broken_paths:
28
+ formatted_output += broken_paths
29
+ if "check_paths_tracking" in in_arg.func:
30
+ paths_tracking = check_broken_links(file_path, "path" , "tracking")
31
+ if paths_tracking:
32
+ formatted_output += paths_tracking
33
+ if "check_urls_tracking" in in_arg.func:
34
+ urls_tracking = check_broken_links(file_path, "url" , "tracking")
35
+ if urls_tracking:
36
+ formatted_output += urls_tracking
37
+ if "check_urls_locale" in in_arg.func:
38
+ urls_locale = check_broken_links(file_path, "url" , "locale")
39
+ if urls_locale:
40
+ formatted_output += urls_locale
41
+ if formatted_output != "":
42
+ formatted_output = "| File Full Path | Issues |\n|--------|--------|\n" + formatted_output
43
+ print(formatted_output)
44
+
45
+ if __name__ == "__main__":
46
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown-checker
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: A markdown validation reporting tool
5
5
  Home-page: https://github.com/john0isaac/markdown-checker
6
6
  Author: John Aziz
@@ -35,4 +35,4 @@ markdown-checker is a markdown validation reporting tool.
35
35
  3. The output will be displayed in the terminal.
36
36
 
37
37
  # Using markdown-checker in GitHub Actions
38
- The tool has been designed to be run within a GitHub workflow using the [action-check-markdown](https://github.com/marketplace/actions/action-check-markdown) GitHub action. The action will automatically post the output of the tool to your GitHub pull request as a comment.
38
+ 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.
@@ -12,5 +12,7 @@ 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/get_input_args/__init__.py
16
- markdown_checker/get_input_args/get_input_args.py
15
+ markdown_checker/inputs/__init__.py
16
+ markdown_checker/inputs/input_arguments.py
17
+ markdown_checker/paths/__init__.py
18
+ markdown_checker/paths/files_paths_reader.py
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = markdown-checker
3
- version = 0.0.5
3
+ version = 0.0.7
4
4
  author = John Aziz
5
5
  author_email = johnaziz269@gmail.com
6
6
  maintainer = John Aziz
@@ -1,3 +0,0 @@
1
- include README.md
2
- include markdown_checker/get_input_args/*
3
- include setup.cfg
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Module providing automatic checks functionality to markdown files
4
- following some Guidelines
5
- """
6
- import os
7
- from markdown_checker.get_input_args.get_input_args import get_input_args
8
- from markdown_checker.markdown_checker import get_lessons_paths, check_broken_links
9
-
10
- def main() -> None:
11
- """Main program get inputs and run checks"""
12
-
13
- # get input arguments directory, function to run
14
- in_arg = get_input_args()
15
-
16
- lessons = get_lessons_paths(in_arg.dir)
17
-
18
- # iterate over the files to validate the content
19
- for lesson_folder_name, lessons_array in lessons.items():
20
- for lesson_file_name in lessons_array:
21
- file_path = os.path.join(
22
- in_arg.dir,
23
- lesson_folder_name,
24
- lesson_file_name)
25
- if in_arg.dir == lesson_folder_name:
26
- file_path = os.path.join(lesson_folder_name, lesson_file_name)
27
- if "check_broken_paths" in in_arg.func:
28
- formatted_output = check_broken_links(file_path, "path" , "broken")
29
- if formatted_output:
30
- print(formatted_output)
31
- if "check_paths_tracking" in in_arg.func:
32
- formatted_output = check_broken_links(file_path, "path" , "tracking")
33
- if formatted_output:
34
- print(formatted_output)
35
- if "check_urls_tracking" in in_arg.func:
36
- formatted_output = check_broken_links(file_path, "url" , "tracking")
37
- if formatted_output:
38
- print(formatted_output)
39
- if "check_urls_locale" in in_arg.func:
40
- formatted_output = check_broken_links(file_path, "url" , "locale")
41
- if formatted_output:
42
- print(formatted_output)
43
-
44
- if __name__ == "__main__":
45
- main()