folderTree-cli 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.
- foldertree_cli-0.1.0/LICENSE +21 -0
- foldertree_cli-0.1.0/PKG-INFO +203 -0
- foldertree_cli-0.1.0/README.md +178 -0
- foldertree_cli-0.1.0/pyproject.toml +59 -0
- foldertree_cli-0.1.0/setup.cfg +4 -0
- foldertree_cli-0.1.0/src/folderTree/__init__.py +0 -0
- foldertree_cli-0.1.0/src/folderTree/__main__.py +5 -0
- foldertree_cli-0.1.0/src/folderTree/analyzers/__init__.py +0 -0
- foldertree_cli-0.1.0/src/folderTree/analyzers/languages.py +65 -0
- foldertree_cli-0.1.0/src/folderTree/analyzers/statistics.py +70 -0
- foldertree_cli-0.1.0/src/folderTree/cli/__init__.py +0 -0
- foldertree_cli-0.1.0/src/folderTree/cli/main.py +66 -0
- foldertree_cli-0.1.0/src/folderTree/cli/parser.py +35 -0
- foldertree_cli-0.1.0/src/folderTree/config.py +17 -0
- foldertree_cli-0.1.0/src/folderTree/exporters/__init__.py +0 -0
- foldertree_cli-0.1.0/src/folderTree/exporters/markdown.py +27 -0
- foldertree_cli-0.1.0/src/folderTree/exporters/txt.py +28 -0
- foldertree_cli-0.1.0/src/folderTree/generators/__init__.py +0 -0
- foldertree_cli-0.1.0/src/folderTree/generators/documentation.py +116 -0
- foldertree_cli-0.1.0/src/folderTree/generators/tree.py +76 -0
- foldertree_cli-0.1.0/src/folderTree/models/__init__.py +11 -0
- foldertree_cli-0.1.0/src/folderTree/models/file.py +56 -0
- foldertree_cli-0.1.0/src/folderTree/models/folder.py +47 -0
- foldertree_cli-0.1.0/src/folderTree/models/metadata.py +13 -0
- foldertree_cli-0.1.0/src/folderTree/models/project.py +18 -0
- foldertree_cli-0.1.0/src/folderTree/scanner/__init__.py +0 -0
- foldertree_cli-0.1.0/src/folderTree/scanner/ignore.py +37 -0
- foldertree_cli-0.1.0/src/folderTree/scanner/metadata_collector.py +20 -0
- foldertree_cli-0.1.0/src/folderTree/scanner/scanner.py +111 -0
- foldertree_cli-0.1.0/src/folderTree/utils/__init__.py +0 -0
- foldertree_cli-0.1.0/src/folderTree/utils/constants.py +68 -0
- foldertree_cli-0.1.0/src/folderTree/utils/formatter.py +53 -0
- foldertree_cli-0.1.0/src/folderTree/utils/helpers.py +41 -0
- foldertree_cli-0.1.0/src/folderTree_cli.egg-info/PKG-INFO +203 -0
- foldertree_cli-0.1.0/src/folderTree_cli.egg-info/SOURCES.txt +47 -0
- foldertree_cli-0.1.0/src/folderTree_cli.egg-info/dependency_links.txt +1 -0
- foldertree_cli-0.1.0/src/folderTree_cli.egg-info/entry_points.txt +2 -0
- foldertree_cli-0.1.0/src/folderTree_cli.egg-info/top_level.txt +1 -0
- foldertree_cli-0.1.0/tests/test_cli.py +73 -0
- foldertree_cli-0.1.0/tests/test_cli_parser.py +53 -0
- foldertree_cli-0.1.0/tests/test_documentation.py +80 -0
- foldertree_cli-0.1.0/tests/test_ignore.py +13 -0
- foldertree_cli-0.1.0/tests/test_languages.py +90 -0
- foldertree_cli-0.1.0/tests/test_markdown_exporter.py +90 -0
- foldertree_cli-0.1.0/tests/test_models.py +0 -0
- foldertree_cli-0.1.0/tests/test_scanner.py +76 -0
- foldertree_cli-0.1.0/tests/test_statistics.py +83 -0
- foldertree_cli-0.1.0/tests/test_tree.py +85 -0
- foldertree_cli-0.1.0/tests/test_txt_exporter.py +83 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kaushal Kumar Jha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: folderTree-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate beautiful folder tree structures and project documentation.
|
|
5
|
+
Author: Kaushal Kumar Jha
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Nikk-hub-code/folderTree
|
|
8
|
+
Project-URL: Repository, https://github.com/Nikk-hub-code/folderTree
|
|
9
|
+
Project-URL: Issues, https://github.com/Nikk-hub-code/folderTree/issues
|
|
10
|
+
Keywords: folder-tree,tree,documentation,cli,filesystem,project,directory,python
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# FolderTree
|
|
27
|
+
|
|
28
|
+
A lightweight command-line tool that automatically analyzes a project directory and generates clean, well-structured project documentation.
|
|
29
|
+
|
|
30
|
+
FolderTree scans your project, collects metadata, analyzes project statistics, detects programming languages, generates a folder tree, and exports documentation in Markdown or TXT format.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- 📁 Scan any project directory
|
|
37
|
+
- 🌳 Generate a beautiful folder tree
|
|
38
|
+
- 📊 Analyze project statistics
|
|
39
|
+
- 💻 Detect programming languages
|
|
40
|
+
- 📝 Generate project documentation
|
|
41
|
+
- 📄 Export documentation as Markdown or TXT
|
|
42
|
+
- ⚡ Fast and simple CLI interface
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Requirements
|
|
47
|
+
|
|
48
|
+
- Python **3.11** or later
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install folderTree
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
After installation, the `folderTree` command will be available globally.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Show available commands
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
folderTree --help
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Generate documentation in the terminal
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
folderTree scan .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
or
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
folderTree scan path/to/project
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Example
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
folderTree scan sample_projects/python_project
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### Export as Markdown
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
folderTree scan . -o PROJECT_DOCUMENTATION.md
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### Export as TXT
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
folderTree scan . -o PROJECT_DOCUMENTATION.txt
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Example Output
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
# Project Documentation
|
|
112
|
+
|
|
113
|
+
## Project Information
|
|
114
|
+
|
|
115
|
+
- Project Name: folderTree
|
|
116
|
+
- Project Location: D:\Projects\folderTree
|
|
117
|
+
- Project Created: 2026-07-10
|
|
118
|
+
- Documentation Generated: 2026-07-19
|
|
119
|
+
|
|
120
|
+
## Statistics
|
|
121
|
+
|
|
122
|
+
- Total Files: 59
|
|
123
|
+
- Total Folders: 22
|
|
124
|
+
- Total Size: 41.94 KB
|
|
125
|
+
|
|
126
|
+
## Languages
|
|
127
|
+
|
|
128
|
+
- Python: 47
|
|
129
|
+
- Markdown: 4
|
|
130
|
+
- TOML: 1
|
|
131
|
+
- HTML: 1
|
|
132
|
+
- CSS: 1
|
|
133
|
+
- JavaScript: 1
|
|
134
|
+
|
|
135
|
+
## Folder Structure
|
|
136
|
+
|
|
137
|
+
folderTree/
|
|
138
|
+
├── src/
|
|
139
|
+
│ └── folderTree/
|
|
140
|
+
├── tests/
|
|
141
|
+
├── README.md
|
|
142
|
+
├── LICENSE
|
|
143
|
+
└── pyproject.toml
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Project Structure
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
folderTree/
|
|
152
|
+
│
|
|
153
|
+
├── src/
|
|
154
|
+
│ └── folderTree/
|
|
155
|
+
│ ├── analyzers/
|
|
156
|
+
│ ├── cli/
|
|
157
|
+
│ ├── exporters/
|
|
158
|
+
│ ├── generators/
|
|
159
|
+
│ ├── models/
|
|
160
|
+
│ ├── scanner/
|
|
161
|
+
│ └── utils/
|
|
162
|
+
│
|
|
163
|
+
├── tests/
|
|
164
|
+
├── docs/
|
|
165
|
+
├── README.md
|
|
166
|
+
├── LICENSE
|
|
167
|
+
├── CHANGELOG.md
|
|
168
|
+
└── pyproject.toml
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
Clone the repository:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
git clone https://github.com/Nikk-hub-code/folderTree.git
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Move into the project directory:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
cd folderTree
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Install in editable mode:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
pip install -e .
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Run the test suite:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
pytest
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# FolderTree
|
|
2
|
+
|
|
3
|
+
A lightweight command-line tool that automatically analyzes a project directory and generates clean, well-structured project documentation.
|
|
4
|
+
|
|
5
|
+
FolderTree scans your project, collects metadata, analyzes project statistics, detects programming languages, generates a folder tree, and exports documentation in Markdown or TXT format.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 📁 Scan any project directory
|
|
12
|
+
- 🌳 Generate a beautiful folder tree
|
|
13
|
+
- 📊 Analyze project statistics
|
|
14
|
+
- 💻 Detect programming languages
|
|
15
|
+
- 📝 Generate project documentation
|
|
16
|
+
- 📄 Export documentation as Markdown or TXT
|
|
17
|
+
- ⚡ Fast and simple CLI interface
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- Python **3.11** or later
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install folderTree
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
After installation, the `folderTree` command will be available globally.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Show available commands
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
folderTree --help
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### Generate documentation in the terminal
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
folderTree scan .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
or
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
folderTree scan path/to/project
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Example
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
folderTree scan sample_projects/python_project
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### Export as Markdown
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
folderTree scan . -o PROJECT_DOCUMENTATION.md
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### Export as TXT
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
folderTree scan . -o PROJECT_DOCUMENTATION.txt
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Example Output
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
# Project Documentation
|
|
87
|
+
|
|
88
|
+
## Project Information
|
|
89
|
+
|
|
90
|
+
- Project Name: folderTree
|
|
91
|
+
- Project Location: D:\Projects\folderTree
|
|
92
|
+
- Project Created: 2026-07-10
|
|
93
|
+
- Documentation Generated: 2026-07-19
|
|
94
|
+
|
|
95
|
+
## Statistics
|
|
96
|
+
|
|
97
|
+
- Total Files: 59
|
|
98
|
+
- Total Folders: 22
|
|
99
|
+
- Total Size: 41.94 KB
|
|
100
|
+
|
|
101
|
+
## Languages
|
|
102
|
+
|
|
103
|
+
- Python: 47
|
|
104
|
+
- Markdown: 4
|
|
105
|
+
- TOML: 1
|
|
106
|
+
- HTML: 1
|
|
107
|
+
- CSS: 1
|
|
108
|
+
- JavaScript: 1
|
|
109
|
+
|
|
110
|
+
## Folder Structure
|
|
111
|
+
|
|
112
|
+
folderTree/
|
|
113
|
+
├── src/
|
|
114
|
+
│ └── folderTree/
|
|
115
|
+
├── tests/
|
|
116
|
+
├── README.md
|
|
117
|
+
├── LICENSE
|
|
118
|
+
└── pyproject.toml
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Project Structure
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
folderTree/
|
|
127
|
+
│
|
|
128
|
+
├── src/
|
|
129
|
+
│ └── folderTree/
|
|
130
|
+
│ ├── analyzers/
|
|
131
|
+
│ ├── cli/
|
|
132
|
+
│ ├── exporters/
|
|
133
|
+
│ ├── generators/
|
|
134
|
+
│ ├── models/
|
|
135
|
+
│ ├── scanner/
|
|
136
|
+
│ └── utils/
|
|
137
|
+
│
|
|
138
|
+
├── tests/
|
|
139
|
+
├── docs/
|
|
140
|
+
├── README.md
|
|
141
|
+
├── LICENSE
|
|
142
|
+
├── CHANGELOG.md
|
|
143
|
+
└── pyproject.toml
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
Clone the repository:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
git clone https://github.com/Nikk-hub-code/folderTree.git
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Move into the project directory:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
cd folderTree
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Install in editable mode:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pip install -e .
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Run the test suite:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pytest
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "folderTree-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Generate beautiful folder tree structures and project documentation."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Kaushal Kumar Jha" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
keywords = [
|
|
18
|
+
"folder-tree",
|
|
19
|
+
"tree",
|
|
20
|
+
"documentation",
|
|
21
|
+
"cli",
|
|
22
|
+
"filesystem",
|
|
23
|
+
"project",
|
|
24
|
+
"directory",
|
|
25
|
+
"python"
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 3 - Alpha",
|
|
30
|
+
"Environment :: Console",
|
|
31
|
+
"Intended Audience :: Developers",
|
|
32
|
+
"Operating System :: OS Independent",
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Programming Language :: Python :: 3.13",
|
|
37
|
+
"Topic :: Software Development",
|
|
38
|
+
"Topic :: Utilities",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
license-files = ["LICENSE"]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/Nikk-hub-code/folderTree"
|
|
45
|
+
Repository = "https://github.com/Nikk-hub-code/folderTree"
|
|
46
|
+
Issues = "https://github.com/Nikk-hub-code/folderTree/issues"
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
folderTree = "folderTree.cli.main:main"
|
|
50
|
+
|
|
51
|
+
[tool.setuptools]
|
|
52
|
+
package-dir = { "" = "src" }
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.packages.find]
|
|
55
|
+
where = ["src"]
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
testpaths = ["tests"]
|
|
59
|
+
pythonpath = ["src"]
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
|
|
5
|
+
from folderTree.models import Folder, Project
|
|
6
|
+
from folderTree.utils.constants import EXTENSION_TO_LANGUAGE
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(slots=True)
|
|
10
|
+
class LanguageStatistics:
|
|
11
|
+
"""
|
|
12
|
+
Stores language statistics for a project.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
language_counts: dict[str, int] = field(default_factory=dict)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class LanguageAnalyzer:
|
|
19
|
+
"""
|
|
20
|
+
Analyzes programming languages used in a project.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def analyze(self, project: Project) -> LanguageStatistics:
|
|
24
|
+
"""
|
|
25
|
+
Analyze the project and return language statistics.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
statistics = LanguageStatistics()
|
|
29
|
+
|
|
30
|
+
self._walk_folder(
|
|
31
|
+
project.root_folder,
|
|
32
|
+
statistics,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return statistics
|
|
36
|
+
|
|
37
|
+
def _walk_folder(
|
|
38
|
+
self,
|
|
39
|
+
folder: Folder,
|
|
40
|
+
statistics: LanguageStatistics,
|
|
41
|
+
) -> None:
|
|
42
|
+
"""
|
|
43
|
+
Recursively walk through folders.
|
|
44
|
+
"""
|
|
45
|
+
# Process files in the current folder
|
|
46
|
+
for file in folder.files:
|
|
47
|
+
|
|
48
|
+
language = EXTENSION_TO_LANGUAGE.get(
|
|
49
|
+
file.extension.lower(),
|
|
50
|
+
"Unknown",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
file.language = language
|
|
54
|
+
|
|
55
|
+
statistics.language_counts[language] = (
|
|
56
|
+
statistics.language_counts.get(language, 0) + 1
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Recursively process subfolders
|
|
60
|
+
for subfolder in folder.folders:
|
|
61
|
+
|
|
62
|
+
self._walk_folder(
|
|
63
|
+
subfolder,
|
|
64
|
+
statistics,
|
|
65
|
+
)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
|
|
5
|
+
from folderTree.models import Folder, Project
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(slots=True)
|
|
9
|
+
class Statistics:
|
|
10
|
+
"""
|
|
11
|
+
Stores statistics about a scanned project.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
total_files: int = 0
|
|
15
|
+
total_folders: int = 0
|
|
16
|
+
total_size: int = 0
|
|
17
|
+
|
|
18
|
+
extension_counts: dict[str, int] = field(default_factory=dict)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class StatisticsAnalyzer:
|
|
22
|
+
"""
|
|
23
|
+
Analyzes a Project and generates statistics.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def analyze(self, project: Project) -> Statistics:
|
|
27
|
+
"""
|
|
28
|
+
Analyze a project and return statistics.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
statistics = Statistics()
|
|
32
|
+
|
|
33
|
+
self._walk_folder(
|
|
34
|
+
project.root_folder,
|
|
35
|
+
statistics,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return statistics
|
|
39
|
+
|
|
40
|
+
def _walk_folder(
|
|
41
|
+
self,
|
|
42
|
+
folder: Folder,
|
|
43
|
+
statistics: Statistics,
|
|
44
|
+
) -> None:
|
|
45
|
+
"""
|
|
46
|
+
Recursively walk through folders and collect statistics.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
# Count the current folder
|
|
50
|
+
statistics.total_folders += 1
|
|
51
|
+
|
|
52
|
+
# Process files in the current folder
|
|
53
|
+
for file in folder.files:
|
|
54
|
+
|
|
55
|
+
statistics.total_files += 1
|
|
56
|
+
|
|
57
|
+
statistics.total_size += file.size
|
|
58
|
+
|
|
59
|
+
extension = file.extension.lower()
|
|
60
|
+
|
|
61
|
+
statistics.extension_counts[extension] = (
|
|
62
|
+
statistics.extension_counts.get(extension, 0) + 1
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Recursively process subfolders
|
|
66
|
+
for subfolder in folder.folders:
|
|
67
|
+
self._walk_folder(
|
|
68
|
+
subfolder,
|
|
69
|
+
statistics,
|
|
70
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from folderTree.exporters.markdown import MarkdownExporter
|
|
4
|
+
from folderTree.exporters.txt import TXTExporter
|
|
5
|
+
from folderTree.generators.documentation import DocumentationGenerator
|
|
6
|
+
from folderTree.scanner.scanner import ProjectScanner
|
|
7
|
+
from folderTree.cli.parser import create_parser
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main() -> None:
|
|
11
|
+
"""
|
|
12
|
+
Entry point for the FolderTree CLI.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
parser = create_parser()
|
|
16
|
+
|
|
17
|
+
args = parser.parse_args()
|
|
18
|
+
|
|
19
|
+
if args.command == "scan":
|
|
20
|
+
scan(Path(args.path), args.output)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def scan(
|
|
24
|
+
project_path: Path,
|
|
25
|
+
output: str | None,
|
|
26
|
+
) -> None:
|
|
27
|
+
"""
|
|
28
|
+
Scan a project and generate documentation.
|
|
29
|
+
"""
|
|
30
|
+
scanner = ProjectScanner()
|
|
31
|
+
|
|
32
|
+
project = scanner.scan(project_path)
|
|
33
|
+
|
|
34
|
+
generator = DocumentationGenerator()
|
|
35
|
+
|
|
36
|
+
documentation = generator.generate(project)
|
|
37
|
+
|
|
38
|
+
if output is None:
|
|
39
|
+
print(documentation)
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
output_path = Path(output)
|
|
43
|
+
|
|
44
|
+
suffix = output_path.suffix.lower()
|
|
45
|
+
|
|
46
|
+
if suffix == ".md":
|
|
47
|
+
exporter = MarkdownExporter()
|
|
48
|
+
|
|
49
|
+
elif suffix == ".txt":
|
|
50
|
+
exporter = TXTExporter()
|
|
51
|
+
|
|
52
|
+
else:
|
|
53
|
+
raise ValueError(
|
|
54
|
+
f"Unsupported output format: {suffix}"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
exporter.export(
|
|
58
|
+
documentation,
|
|
59
|
+
output_path,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
print("✓ Documentation generated successfully.")
|
|
63
|
+
print(f"Output: {output_path}")
|
|
64
|
+
|
|
65
|
+
if __name__ == "__main__":
|
|
66
|
+
main()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from argparse import ArgumentParser
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def create_parser() -> ArgumentParser:
|
|
5
|
+
"""
|
|
6
|
+
Create and configure the FolderTree CLI parser.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
parser = ArgumentParser(
|
|
10
|
+
prog="folderTree",
|
|
11
|
+
description="Generate project documentation.",
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
subparsers = parser.add_subparsers(
|
|
15
|
+
dest="command",
|
|
16
|
+
required=True,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
scan_parser = subparsers.add_parser(
|
|
20
|
+
"scan",
|
|
21
|
+
help="Scan a project directory.",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
scan_parser.add_argument(
|
|
25
|
+
"path",
|
|
26
|
+
help="Path to the project directory.",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
scan_parser.add_argument(
|
|
30
|
+
"-o",
|
|
31
|
+
"--output",
|
|
32
|
+
help="Output file (.md or .txt).",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return parser
|