markdown-file-analyzer 0.1.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.
File without changes
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: markdown-file-analyzer
3
+ Version: 0.1.0
4
+ Summary: A CLI tool to parse, analyze, and generate summary reports for Markdown files in directories.
5
+ Author: Victor Okenwa
6
+ License: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: pydantic>=2.0.0
11
+ Dynamic: license-file
12
+
13
+ # Markdown Directory Analyzer
14
+
15
+ This project is a Python-based tool that analyzes a directory (and its subdirectories) of Markdown (`.md`) files and generates a comprehensive summary report. The goal is to provide insight into documentation quality and content metrics for codebases, technical blogs, knowledge bases, or any project using Markdown files.
16
+
17
+ ---
18
+
19
+ ## Features
20
+
21
+ - **Recursive Scanning:** Analyzes all Markdown files within the specified root directory and subfolders.
22
+ - **Per-File Metrics:** Reports for each file:
23
+ - File path
24
+ - Word count
25
+ - Header (e.g., `#`/`##`) count
26
+ - Code block count
27
+ - Estimated reading time (minutes, at 200 wpm)
28
+ - **Aggregated Directory Metrics:**
29
+ - Total number of Markdown files
30
+ - Combined word and code block counts
31
+ - Average reading time across files
32
+ - **Generates a Markdown Summary:** Output includes a table breakdown of each file for easy reporting and sharing.
33
+ - **CLI or Interactive Use:** Accepts directory as a command-line argument or prompts for user input.
34
+ - **Saves Output:** Automatically saves analysis to `summary_report.md` in the current working directory.
35
+
36
+ ---
37
+
38
+ ## Getting Started
39
+
40
+ ### 1. **Install Requirements**
41
+
42
+ Make sure you have Python 3.8+ installed.
43
+
44
+ ```bash
45
+ pip install -r requirements.txt
46
+ ```
47
+
48
+ ### 2. **Usage**
49
+
50
+ **From the command line:**
51
+ ```bash
52
+ python main.py /path/to/your/markdown-directory
53
+ ```
54
+
55
+ **Or run and enter directory interactively:**
56
+ ```bash
57
+ python main.py
58
+ # When prompted, type the target folder path (or press Enter for current directory)
59
+ ```
60
+
61
+ After running, view or share your `summary_report.md`!
62
+
63
+ ---
64
+
65
+ ## Example Output
66
+
67
+ ```
68
+ # Markdown Directory Analysis Summary
69
+
70
+ - **Total Files Analyzed:** 5
71
+ - **Total Word Count:** 12,500 words
72
+ - **Total Code Blocks:** 16
73
+ - **Avg Reading Time:** 10.32 minutes
74
+
75
+ ---
76
+
77
+ ### Individual File Breakdown
78
+ | File Path | Words | Headers | Code Blocks | Est. Read Time |
79
+ | :--- | :--- | :--- | :--- | :--- |
80
+ | docs/intro.md | 1200 | 12 | 2 | 6.0 min |
81
+ | guide/howto.md | 3000 | 25 | 5 | 15.0 min |
82
+ | ... | ... | ... | ... | ... |
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Project Structure
88
+
89
+ - `main.py` — Entry point, CLI, report formatting and saving.
90
+ - `analyzer.py` — Analyzes the entire directory and aggregates results.
91
+ - `parser.py` — Parses individual Markdown files and calculates metrics.
92
+ - `models.py` — Data models (using Pydantic) for structured report and file metrics.
93
+ - `requirements.txt` — List of Python dependencies.
94
+
95
+ ---
96
+
97
+ ## Extending / Customization
98
+
99
+ - Add new metrics (e.g. link integrity, image stats) in `parser.py` and update models for richer reports.
100
+ - Adjust reading speed estimation by changing the calculation logic.
101
+ - Customize output format by editing the Markdown rendering in `main.py`.
102
+
103
+ ---
104
+
105
+ ## License
106
+
107
+ MIT License
108
+
109
+ ---
@@ -0,0 +1,97 @@
1
+ # Markdown Directory Analyzer
2
+
3
+ This project is a Python-based tool that analyzes a directory (and its subdirectories) of Markdown (`.md`) files and generates a comprehensive summary report. The goal is to provide insight into documentation quality and content metrics for codebases, technical blogs, knowledge bases, or any project using Markdown files.
4
+
5
+ ---
6
+
7
+ ## Features
8
+
9
+ - **Recursive Scanning:** Analyzes all Markdown files within the specified root directory and subfolders.
10
+ - **Per-File Metrics:** Reports for each file:
11
+ - File path
12
+ - Word count
13
+ - Header (e.g., `#`/`##`) count
14
+ - Code block count
15
+ - Estimated reading time (minutes, at 200 wpm)
16
+ - **Aggregated Directory Metrics:**
17
+ - Total number of Markdown files
18
+ - Combined word and code block counts
19
+ - Average reading time across files
20
+ - **Generates a Markdown Summary:** Output includes a table breakdown of each file for easy reporting and sharing.
21
+ - **CLI or Interactive Use:** Accepts directory as a command-line argument or prompts for user input.
22
+ - **Saves Output:** Automatically saves analysis to `summary_report.md` in the current working directory.
23
+
24
+ ---
25
+
26
+ ## Getting Started
27
+
28
+ ### 1. **Install Requirements**
29
+
30
+ Make sure you have Python 3.8+ installed.
31
+
32
+ ```bash
33
+ pip install -r requirements.txt
34
+ ```
35
+
36
+ ### 2. **Usage**
37
+
38
+ **From the command line:**
39
+ ```bash
40
+ python main.py /path/to/your/markdown-directory
41
+ ```
42
+
43
+ **Or run and enter directory interactively:**
44
+ ```bash
45
+ python main.py
46
+ # When prompted, type the target folder path (or press Enter for current directory)
47
+ ```
48
+
49
+ After running, view or share your `summary_report.md`!
50
+
51
+ ---
52
+
53
+ ## Example Output
54
+
55
+ ```
56
+ # Markdown Directory Analysis Summary
57
+
58
+ - **Total Files Analyzed:** 5
59
+ - **Total Word Count:** 12,500 words
60
+ - **Total Code Blocks:** 16
61
+ - **Avg Reading Time:** 10.32 minutes
62
+
63
+ ---
64
+
65
+ ### Individual File Breakdown
66
+ | File Path | Words | Headers | Code Blocks | Est. Read Time |
67
+ | :--- | :--- | :--- | :--- | :--- |
68
+ | docs/intro.md | 1200 | 12 | 2 | 6.0 min |
69
+ | guide/howto.md | 3000 | 25 | 5 | 15.0 min |
70
+ | ... | ... | ... | ... | ... |
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Project Structure
76
+
77
+ - `main.py` — Entry point, CLI, report formatting and saving.
78
+ - `analyzer.py` — Analyzes the entire directory and aggregates results.
79
+ - `parser.py` — Parses individual Markdown files and calculates metrics.
80
+ - `models.py` — Data models (using Pydantic) for structured report and file metrics.
81
+ - `requirements.txt` — List of Python dependencies.
82
+
83
+ ---
84
+
85
+ ## Extending / Customization
86
+
87
+ - Add new metrics (e.g. link integrity, image stats) in `parser.py` and update models for richer reports.
88
+ - Adjust reading speed estimation by changing the calculation logic.
89
+ - Customize output format by editing the Markdown rendering in `main.py`.
90
+
91
+ ---
92
+
93
+ ## License
94
+
95
+ MIT License
96
+
97
+ ---
@@ -0,0 +1,35 @@
1
+ # Directory wide scanning
2
+
3
+ # Directory Scanner & Aggregator
4
+ from pathlib import Path
5
+
6
+ from markdown_analyzer.models import DirectoryReport, FileMetrics
7
+ from markdown_analyzer.parser import analyze_file
8
+
9
+
10
+ def analyze_directory(directory_path: str) -> DirectoryReport:
11
+ path = Path(directory_path)
12
+
13
+ mark_down_files = path.rglob("*.md")
14
+
15
+ metrics_list: list[FileMetrics] = [
16
+ analyze_file(str(file_path)) for file_path in mark_down_files
17
+ ]
18
+
19
+ total_files: int = len(metrics_list)
20
+ total_words: int = sum(file.word_count for file in metrics_list)
21
+ total_code_blocks: int = sum(file.code_block_count for file in metrics_list)
22
+
23
+ avg_reading_time= 0.0
24
+
25
+ if total_files > 0:
26
+ avg_reading_time: float = sum(file.reading_time_minutes for file in metrics_list) / total_files
27
+
28
+ return DirectoryReport(
29
+ total_files=total_files,
30
+ total_words=total_words,
31
+ total_code_blocks=total_code_blocks,
32
+ avg_reading_time=round(avg_reading_time, 2),
33
+ files=metrics_list
34
+ )
35
+
@@ -0,0 +1,95 @@
1
+ import argparse
2
+ from pathlib import Path
3
+ from markdown_analyzer.analyzer import analyze_directory
4
+ from markdown_analyzer.models import DirectoryReport
5
+
6
+ # formats report into a beautiful Markdown string using multi-line f-strings
7
+ def format_markdown_report(report: DirectoryReport) -> str:
8
+ # 1. Build table rows from report.files
9
+
10
+ table_rows = "\n".join(
11
+ f"| {f.file_path} | {f.word_count} | {f.header_count} | {f.code_block_count} | {f.reading_time_minutes} min |"
12
+ for f in report.files
13
+ )
14
+
15
+ # 2. Construct the full report string
16
+ report_md = f"""# Markdown Directory Analysis Summary
17
+
18
+ - **Total Files Analyzed:** {report.total_files}
19
+ - **Total Word Count:** {report.total_words:,} words
20
+ - **Total Code Blocks:** {report.total_code_blocks}
21
+ - **Avg Reading Time:** {report.avg_reading_time} minutes
22
+
23
+ ---
24
+
25
+ ### Individual File Breakdown
26
+ | File Path | Words | Headers | Code Blocks | Est. Read Time |
27
+ | :--- | :--- | :--- | :--- | :--- |
28
+ {table_rows}
29
+ """
30
+ return report_md
31
+
32
+
33
+ def main():
34
+ # 1. Initialize Parser with CLI metadata
35
+ parser = argparse.ArgumentParser(
36
+ prog="md-analyzer",
37
+ description="Parse and summarize Markdown file metrics across directories.",
38
+ epilog="Thanks for using md-analyzer!",
39
+ )
40
+
41
+ # 2. Define Positional & Optional Arguments
42
+ parser.add_argument(
43
+ "path",
44
+ nargs="?",
45
+ default=".",
46
+ help="Directory path to scan (default: current directory '.')",
47
+ )
48
+ parser.add_argument(
49
+ "-n",
50
+ "--no-save",
51
+ action="store_true",
52
+ help="Don't save report to file, just print to console",
53
+ )
54
+ parser.add_argument(
55
+ "-o",
56
+ "--output",
57
+ type=str,
58
+ default="summary_report.md",
59
+ help="Output file name (default: 'summary_report.md')",
60
+ )
61
+
62
+ # 3. Parse arguments from CLI and store in args variable
63
+ args = parser.parse_args()
64
+
65
+
66
+ # 4. Resolve Path
67
+ target_path = Path(args.path)
68
+
69
+ if not target_path.exists():
70
+ print(f"❌ Error: Path '{args.path}' does not exist.")
71
+ return
72
+
73
+ print(f"\n🔍 Analyzing Markdown files in: {target_path.resolve()} ...\n")
74
+
75
+ # Run analysis & format output
76
+ analysis = analyze_directory(str(target_path))
77
+ formatted_report = format_markdown_report(analysis)
78
+
79
+ print(formatted_report)
80
+
81
+ # 5. Conditionally save report file based on --no-save flag
82
+ if not args.no_save:
83
+ output_file = Path(args.output)
84
+ output_file.write_text(formatted_report, encoding="utf-8")
85
+ print(f"✅ Report saved to: {output_file.resolve()}")
86
+
87
+ else:
88
+ print("ℹ️ Skipping report file creation (--no-save passed).")
89
+
90
+
91
+ if __name__ == "__main__":
92
+ main()
93
+
94
+
95
+
@@ -0,0 +1,19 @@
1
+ # Pydantic Schemas
2
+ from pydantic import BaseModel, Field
3
+
4
+ #This model represents the analyzed statistics of a single Markdown file.
5
+ class FileMetrics(BaseModel):
6
+ file_path: str
7
+ word_count: int = Field(default=0, ge=0)
8
+ reading_time_minutes: float = Field(default=0.0)
9
+ header_count: int = Field(default=0)
10
+ code_block_count: int = Field(default=0)
11
+ has_broken_links: bool = Field(default=False)
12
+
13
+ # This model represents the aggregated summary of an entire folder filled with Markdown files.
14
+ class DirectoryReport(BaseModel):
15
+ total_files: int
16
+ total_words: int
17
+ total_code_blocks: int
18
+ avg_reading_time: float
19
+ files: list[FileMetrics]
@@ -0,0 +1,23 @@
1
+ # Single file parsing Logic
2
+
3
+
4
+ from markdown_analyzer.models import FileMetrics
5
+
6
+
7
+ def analyze_file(file_path: str) -> FileMetrics:
8
+ with open(file_path, "r", encoding="utf-8") as file:
9
+ content = file.read()
10
+ word_count: int = len(content.split())
11
+ reading_time: float = word_count/200.0
12
+
13
+ lines = content.splitlines()
14
+ header_count: int = len([line for line in lines if line.strip().startswith("#")])
15
+ code_block_count: int = len([line for line in lines if line.strip().startswith("```")])//2
16
+
17
+ return FileMetrics(
18
+ file_path=file_path,
19
+ word_count=word_count,
20
+ reading_time_minutes=reading_time,
21
+ header_count=header_count,
22
+ code_block_count=code_block_count,
23
+ )
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: markdown-file-analyzer
3
+ Version: 0.1.0
4
+ Summary: A CLI tool to parse, analyze, and generate summary reports for Markdown files in directories.
5
+ Author: Victor Okenwa
6
+ License: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: pydantic>=2.0.0
11
+ Dynamic: license-file
12
+
13
+ # Markdown Directory Analyzer
14
+
15
+ This project is a Python-based tool that analyzes a directory (and its subdirectories) of Markdown (`.md`) files and generates a comprehensive summary report. The goal is to provide insight into documentation quality and content metrics for codebases, technical blogs, knowledge bases, or any project using Markdown files.
16
+
17
+ ---
18
+
19
+ ## Features
20
+
21
+ - **Recursive Scanning:** Analyzes all Markdown files within the specified root directory and subfolders.
22
+ - **Per-File Metrics:** Reports for each file:
23
+ - File path
24
+ - Word count
25
+ - Header (e.g., `#`/`##`) count
26
+ - Code block count
27
+ - Estimated reading time (minutes, at 200 wpm)
28
+ - **Aggregated Directory Metrics:**
29
+ - Total number of Markdown files
30
+ - Combined word and code block counts
31
+ - Average reading time across files
32
+ - **Generates a Markdown Summary:** Output includes a table breakdown of each file for easy reporting and sharing.
33
+ - **CLI or Interactive Use:** Accepts directory as a command-line argument or prompts for user input.
34
+ - **Saves Output:** Automatically saves analysis to `summary_report.md` in the current working directory.
35
+
36
+ ---
37
+
38
+ ## Getting Started
39
+
40
+ ### 1. **Install Requirements**
41
+
42
+ Make sure you have Python 3.8+ installed.
43
+
44
+ ```bash
45
+ pip install -r requirements.txt
46
+ ```
47
+
48
+ ### 2. **Usage**
49
+
50
+ **From the command line:**
51
+ ```bash
52
+ python main.py /path/to/your/markdown-directory
53
+ ```
54
+
55
+ **Or run and enter directory interactively:**
56
+ ```bash
57
+ python main.py
58
+ # When prompted, type the target folder path (or press Enter for current directory)
59
+ ```
60
+
61
+ After running, view or share your `summary_report.md`!
62
+
63
+ ---
64
+
65
+ ## Example Output
66
+
67
+ ```
68
+ # Markdown Directory Analysis Summary
69
+
70
+ - **Total Files Analyzed:** 5
71
+ - **Total Word Count:** 12,500 words
72
+ - **Total Code Blocks:** 16
73
+ - **Avg Reading Time:** 10.32 minutes
74
+
75
+ ---
76
+
77
+ ### Individual File Breakdown
78
+ | File Path | Words | Headers | Code Blocks | Est. Read Time |
79
+ | :--- | :--- | :--- | :--- | :--- |
80
+ | docs/intro.md | 1200 | 12 | 2 | 6.0 min |
81
+ | guide/howto.md | 3000 | 25 | 5 | 15.0 min |
82
+ | ... | ... | ... | ... | ... |
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Project Structure
88
+
89
+ - `main.py` — Entry point, CLI, report formatting and saving.
90
+ - `analyzer.py` — Analyzes the entire directory and aggregates results.
91
+ - `parser.py` — Parses individual Markdown files and calculates metrics.
92
+ - `models.py` — Data models (using Pydantic) for structured report and file metrics.
93
+ - `requirements.txt` — List of Python dependencies.
94
+
95
+ ---
96
+
97
+ ## Extending / Customization
98
+
99
+ - Add new metrics (e.g. link integrity, image stats) in `parser.py` and update models for richer reports.
100
+ - Adjust reading speed estimation by changing the calculation logic.
101
+ - Customize output format by editing the Markdown rendering in `main.py`.
102
+
103
+ ---
104
+
105
+ ## License
106
+
107
+ MIT License
108
+
109
+ ---
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ markdown_analyzer/__init__.py
5
+ markdown_analyzer/analyzer.py
6
+ markdown_analyzer/main.py
7
+ markdown_analyzer/models.py
8
+ markdown_analyzer/parser.py
9
+ markdown_file_analyzer.egg-info/PKG-INFO
10
+ markdown_file_analyzer.egg-info/SOURCES.txt
11
+ markdown_file_analyzer.egg-info/dependency_links.txt
12
+ markdown_file_analyzer.egg-info/entry_points.txt
13
+ markdown_file_analyzer.egg-info/requires.txt
14
+ markdown_file_analyzer.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ md-analyzer = markdown_analyzer.main:main
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "markdown-file-analyzer" # Unique name on PyPI
7
+ version = "0.1.0"
8
+ description = "A CLI tool to parse, analyze, and generate summary reports for Markdown files in directories."
9
+ readme = "README.md"
10
+ authors = [
11
+ { name = "Victor Okenwa" }
12
+ ]
13
+ license = { text = "MIT" }
14
+ requires-python = ">=3.9"
15
+ dependencies = [
16
+ "pydantic>=2.0.0"
17
+ ]
18
+
19
+ # This creates the terminal executable command!
20
+ [project.scripts]
21
+ md-analyzer = "markdown_analyzer.main:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+