-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreadgen.toml
More file actions
209 lines (175 loc) · 5.94 KB
/
readgen.toml
File metadata and controls
209 lines (175 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
[ReadGen]
title = "ReadGen"
content = """
## This document was automatically generated by ReadGen as well!
### ${project.name} (${project.version})
${project.description}
"""
[Features]
content = """
1. Read project information from pyproject.toml
2. Read custom content from readgen.toml
- Support variable substitution from pyproject.toml
- Configure directory structure display with depth control
- Toggle directory section display
3. Scan and filter project structure
- Support glob patterns for excluding directories and files
- Flexible depth control for directory display
- Configurable file visibility
- Support wildcard patterns for excluding directories and files
4. Extract comments from Python files for documentation
- Read first-line comments for description
- Support aligned comment display in directory tree
5. Generate a standardized README.md
- Consistent formatting
- Automatic section organization
- Customizable content blocks
"""
[Installation]
content = """
```bash
# Recommendation, as it can be used globally.
$ pipx install tbi-readgen
```
"""
[Usage]
content = """
## CLI
```bash
# Overwrite README.md.
$ readgen -f
# Generate README.md without overwriting.
$ readgen
```
## Configurable Project Information
Create a `readgen.toml` file in the project root:
````toml
[Title]
title = "Method to overwrite [Title], with support for spaces."
content = "Content of the Title Block"
[Markdown]
content = \"\"\"
## This is a markdown block
1. Read project information from pyproject.toml
2. Read custom content from readgen.toml
3. Scan the project directory structure
4. Extract docstrings from `__init__.py` files in each folder
5. Generate a standardized README.md
```bash
$ pipx install tbi-readgen
```
\"\"\"
[Variables]
content = \"\"\"
Examples of variables from pyproject.toml:
- Use \\${project.version} to get the project version
- Use \\${project.name} to get the project name
\"\"\"
[License]
content = "This project is licensed under the \\${project.license} License."
[directory] # `directory` is a built-in method and will not be listed.
title = "Directory Structure" # Block names are customizable, allowing you to override the default "Directory Structure."
content = "The content displayed below the title."
enable = true # Default is true. Show the directory structure.
show_files = true # Default is true. Show files in the directory structure.
show_comments = true # Default is true. Show first-line comments in the directory structure.
max_depth = 1 # Optional. Specifies the maximum directory depth to display. Omit this line for no limit.
# Exclude patterns support various matching formats:
# Note: __init__.py files are always excluded from the file listing since their
# comments are shown at the directory level. This behavior cannot be overridden.
exclude_patterns = [
# 1. Directory specific patterns - must end with "/"
"env/", # Matches only 'env' directory
"dist/", # Matches only 'dist' directory
# 2. Root-level file/directory matches
"env", # Matches file/directory named 'env' in root
"file.txt", # Matches specific file in root
# 3. Recursive File extension wildcards
"**/*.py", # Matches all Python files at any depth
"**/*.pyc", # Matches all compiled Python files at any depth
# 4. Recursive directory patterns
"**/__pycache__/", # Matches __pycache__ dirs at any depth
"**/node_modules/", # Matches node_modules dirs at any depth
# 5. Path-specific depth patterns
"app/web/static/*/*", # Matches files two levels deep in static
# e.g.: static/css/main.css - excluded
# static/css - not excluded
# Common excludes
"**/__pycache__/",
".git/",
"build/",
".env*", # Matches all .env files (.env, .env.dev)
"*.egg-info/",
"dist/",
"env/",
]
[env] # `env` is a built-in method and will not be listed.
title = "Environment Variables" # Block names are customizable, allowing you to override the default "Environment Variables."
content = "The content displayed below the title."
enable = false # Default is true. Show the environment with description from the .env file.
env_file = ".env" # Default is ".env". The file to read the environment variables from.
````
# .env file
If block comments are placed above `.env` variables, they should follow this format:
```sh
# Project identification code used for service registration and resource management
PROJECT_ID=tbi-readgen
PROJECT_NAME=ReadGen
# Application runtime environment (dev/stage/prod)
APP_ENV=dev
APP_KEY=secret-key
```
will be displayed as:
### Environment Variables
Project identification code used for service registration and resource management
- `PROJECT_ID`
- `PROJECT_NAME`
Application runtime environment (dev/stage/prod)
- `APP_ENV`
- `APP_KEY`
# show_comments
If `show_comments` is set to `true`, first-line comments with a `#` prefix in the directory structure will be displayed.
```
readgen/
├── LICENSE
└── src/
└── readgen/ # Comments from the `__init__.py` file will be displayed in the parent directory.
├── cli.py # Comments with a `#` prefix at the beginning of the line will be displayed here.
├── config.py
...
```
"""
[Development]
content = """
### Setup
```bash
git clone https://github.com/TaiwanBigdata/readgen.git
cd readgen
python -m venv env
source env/bin/activate # Linux/Mac
pip install -e .
```
"""
[env]
enable = false
env_file = ".env"
[directory]
enable = true
exclude_patterns = [
".cursorrules",
".env*",
"**/.DS_Store",
".git/",
".gitignore",
"env/",
"**/__pycache__/",
"*.egg-info/",
"jupyterlab",
"secrets",
"build",
"dist",
]
show_files = true
show_comments = true
[License]
content = "This project is licensed under the ${project.license} License."