devDocs 0.1.0__tar.gz → 1.0.1__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.
devdocs-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,237 @@
1
+ Metadata-Version: 2.4
2
+ Name: devDocs
3
+ Version: 1.0.1
4
+ Summary: A CLI tool to auto-generate professional README.md files using Google Gemini API.
5
+ Author: Gantavya Bansal
6
+ Author-email: Gantavya Bansal <gantavyaoo@gmail.com>
7
+ License: MIT
8
+ Keywords: cli,documentation,readme,generator,gemini-ai
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Documentation
13
+ Classifier: Topic :: Software Development :: Code Generators
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: google-genai
17
+ Requires-Dist: httpx
18
+ Dynamic: author
19
+ Dynamic: requires-python
20
+
21
+
22
+ ---
23
+
24
+ # PKG NAME📘: `devDocs` – AI-powered automated project documentation writer
25
+
26
+ `devDocs` is a **command-line tool** that automatically creates high-quality `README.md` files by analyzing your project’s **folder structure**, **source code**, and any existing documentation. It uses the **Google Gemini API** to generate clear, structured, and professional Markdown documentation.
27
+
28
+ Perfect for:
29
+
30
+ * Open-source contributors 💡
31
+ * Developers maintaining internal tools 🛠️
32
+ * Hackathon projects needing clean docs fast 🚀
33
+
34
+ ---
35
+
36
+ ## 📂 Example Project Structure
37
+
38
+ Here’s how your project might look before and after using `devDocs`:
39
+
40
+ ```bash
41
+ your-project/
42
+ ├── src/
43
+ │ ├── main.py
44
+ │ └── utils.py
45
+ ├── tests/
46
+ ├── requirements.txt
47
+ ├── LICENSE
48
+ └── README.md <-- Generated/Overwritten by devDocs
49
+ ```
50
+
51
+ ---
52
+
53
+ ## ⚙️ How It Works (Behind the Scenes)
54
+
55
+ Here's what happens when you run `devDocs`:
56
+
57
+ 1. **Scans your project** – Analyzes directory structure, code files, and existing README files.
58
+ 2. **Parses content** – Gathers code and documentation from each relevant file/folder.
59
+ 3. **Generates documentation** – Sends context to Google Gemini API to craft a structured `README.md`.
60
+ 4. **Saves output** – Writes the generated Markdown into your project (or into a custom output folder).
61
+
62
+ 🔁 Optional features:
63
+
64
+ * Preserves your original README unless you use `--overwrite`.
65
+ * Includes/excludes specific files or folders with filters.
66
+
67
+ ---
68
+
69
+ ## 📦 Installation
70
+
71
+ Install from PyPI:
72
+
73
+ ```bash
74
+ pip install devDocs
75
+ ```
76
+
77
+ ---
78
+
79
+ ## 🔑 Requirements
80
+
81
+ * **Python 3.8+**
82
+ * **Google Gemini API Key**
83
+ Get one from [Google AI Studio](https://aistudio.google.com/).
84
+
85
+ ---
86
+
87
+ ## 🚀 Usage
88
+
89
+ Inside the root folder of your project, run:
90
+
91
+ ```bash
92
+ devDocs [OPTIONS]
93
+ ```
94
+
95
+ The CLI will prompt for your **Google Gemini API key**. Paste it once when asked.
96
+
97
+ ### CLI Options
98
+
99
+ | Option | Description |
100
+ | --------------- | ------------------------------------------------------------- |
101
+ | `--path` | Root path to scan (default: current directory) |
102
+ | `--name` | Project name to display in the README |
103
+ | `--description` | Short description for the project |
104
+ | `--authors` | Comma-separated list of authors |
105
+ | `--keywords` | Comma-separated list of keywords (e.g., cli, docs, auto) |
106
+ | `--overwrite` | Overwrite existing `README.md` files (default: False) |
107
+ | `--output` | Output folder to save generated docs (default: `docs/`) |
108
+ | `--exclude` | Comma-separated folders/files/extensions to **exclude** |
109
+ | `--include` | Comma-separated folders/files/extensions to **force include** |
110
+
111
+ ---
112
+
113
+ ### ✅ Example Command
114
+
115
+ ```bash
116
+ devDocs --path . \
117
+ --name "Cool Dev Tool" \
118
+ --description "Generate AI-based READMEs effortlessly" \
119
+ --authors "Gantavya Bansal" \
120
+ --keywords "cli, docs, automation, openai" \
121
+ --output docs \
122
+ --overwrite
123
+ ```
124
+
125
+ This will:
126
+
127
+ * Walk through all folders from current directory
128
+ * Create a `docs/README.md` and other structured markdowns
129
+ * Overwrite existing README if one exists
130
+
131
+ ---
132
+
133
+ ## 🧠 Features
134
+
135
+ * ✅ Generates structured, professional `README.md` files automatically
136
+ * ✅ Preserves original docs unless `--overwrite` is set
137
+ * ✅ Supports **include/exclude** filtering for granular control
138
+ * ✅ Smart project tree visualization included in docs
139
+ * ✅ Outputs all documentation to a single folder (`--output`)
140
+ * ✅ Powered by Google Gemini AI (clean & readable Markdown)
141
+
142
+ ---
143
+
144
+ ## 🏗️ Example Output (Generated)
145
+
146
+ Here’s a sample snippet of what the generated README might look like:
147
+
148
+ ```
149
+ # Cool Dev Tool
150
+
151
+ This is a CLI tool for generating clean README.md files using Google Gemini.
152
+
153
+ ## Folder Structure
154
+ your-project/
155
+ ├── src/
156
+ │ ├── main.py
157
+ │ └── utils.py
158
+ ├── README.md
159
+ ...
160
+
161
+ ## Usage
162
+ ...
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 🧱 Technologies Used
168
+
169
+ * `Python 3.8+`
170
+ * [`google-genai`](https://pypi.org/project/google-generativeai/)
171
+ * `argparse`, `os`, `logging`, `time` – for CLI and system interaction
172
+
173
+ ---
174
+
175
+ ## 🧰 Developer Notes
176
+
177
+ If you're contributing or extending this project:
178
+
179
+ ### Core Files
180
+
181
+ | File | Purpose |
182
+ | ------------------ | ----------------------------------------------- |
183
+ | `cli.py` | CLI interface + core logic |
184
+ | `README.md` | The README template output (can be regenerated) |
185
+ | `LookFolder()` | Recursive folder/file scanner |
186
+ | `GenerateReadMe()` | Sends data to Gemini and processes results |
187
+ | `print_tree()` | Generates folder structure view in tree format |
188
+
189
+ ### Data Flow
190
+
191
+ 1. CLI parses args →
192
+ 2. Filters folders/files →
193
+ 3. Reads source + existing docs →
194
+ 4. Calls `GenerateReadMe()` →
195
+ 5. Writes Markdown to output
196
+
197
+ ### API Instruction Logic (Simplified)
198
+
199
+ ```python
200
+ system_instruction = '''
201
+ You are Gantavya Bansal, a senior engineer and tech writer.
202
+ Generate clean, professional Markdown documentation using code + structure context.
203
+ Include:
204
+ - Title
205
+ - Folder Tree
206
+ - Description
207
+ - Usage
208
+ - Tech Stack
209
+ - Known Issues
210
+ - Licensing
211
+ '''
212
+ ```
213
+
214
+ ---
215
+
216
+ ## ⚠️ Known Limitations
217
+
218
+ * 📡 Needs an internet connection for Gemini API
219
+ * 🔁 Limited retry logic for failed API calls
220
+ * ⚙️ Include/exclude filters don't yet support regex
221
+ * 📄 Only supports `.md` output format
222
+
223
+ ---
224
+
225
+ ## 📜 License
226
+
227
+ **MIT License** – You’re free to use, modify, and share.
228
+ Attribution is appreciated!
229
+
230
+ ---
231
+
232
+ ## 💬 Contributing
233
+
234
+ Feel free to open issues, suggest improvements, or contribute directly.
235
+ Pull requests are always welcome!
236
+
237
+ ---
@@ -0,0 +1,217 @@
1
+
2
+ ---
3
+
4
+ # PKG NAME📘: `devDocs` – AI-powered automated project documentation writer
5
+
6
+ `devDocs` is a **command-line tool** that automatically creates high-quality `README.md` files by analyzing your project’s **folder structure**, **source code**, and any existing documentation. It uses the **Google Gemini API** to generate clear, structured, and professional Markdown documentation.
7
+
8
+ Perfect for:
9
+
10
+ * Open-source contributors 💡
11
+ * Developers maintaining internal tools 🛠️
12
+ * Hackathon projects needing clean docs fast 🚀
13
+
14
+ ---
15
+
16
+ ## 📂 Example Project Structure
17
+
18
+ Here’s how your project might look before and after using `devDocs`:
19
+
20
+ ```bash
21
+ your-project/
22
+ ├── src/
23
+ │ ├── main.py
24
+ │ └── utils.py
25
+ ├── tests/
26
+ ├── requirements.txt
27
+ ├── LICENSE
28
+ └── README.md <-- Generated/Overwritten by devDocs
29
+ ```
30
+
31
+ ---
32
+
33
+ ## ⚙️ How It Works (Behind the Scenes)
34
+
35
+ Here's what happens when you run `devDocs`:
36
+
37
+ 1. **Scans your project** – Analyzes directory structure, code files, and existing README files.
38
+ 2. **Parses content** – Gathers code and documentation from each relevant file/folder.
39
+ 3. **Generates documentation** – Sends context to Google Gemini API to craft a structured `README.md`.
40
+ 4. **Saves output** – Writes the generated Markdown into your project (or into a custom output folder).
41
+
42
+ 🔁 Optional features:
43
+
44
+ * Preserves your original README unless you use `--overwrite`.
45
+ * Includes/excludes specific files or folders with filters.
46
+
47
+ ---
48
+
49
+ ## 📦 Installation
50
+
51
+ Install from PyPI:
52
+
53
+ ```bash
54
+ pip install devDocs
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 🔑 Requirements
60
+
61
+ * **Python 3.8+**
62
+ * **Google Gemini API Key**
63
+ Get one from [Google AI Studio](https://aistudio.google.com/).
64
+
65
+ ---
66
+
67
+ ## 🚀 Usage
68
+
69
+ Inside the root folder of your project, run:
70
+
71
+ ```bash
72
+ devDocs [OPTIONS]
73
+ ```
74
+
75
+ The CLI will prompt for your **Google Gemini API key**. Paste it once when asked.
76
+
77
+ ### CLI Options
78
+
79
+ | Option | Description |
80
+ | --------------- | ------------------------------------------------------------- |
81
+ | `--path` | Root path to scan (default: current directory) |
82
+ | `--name` | Project name to display in the README |
83
+ | `--description` | Short description for the project |
84
+ | `--authors` | Comma-separated list of authors |
85
+ | `--keywords` | Comma-separated list of keywords (e.g., cli, docs, auto) |
86
+ | `--overwrite` | Overwrite existing `README.md` files (default: False) |
87
+ | `--output` | Output folder to save generated docs (default: `docs/`) |
88
+ | `--exclude` | Comma-separated folders/files/extensions to **exclude** |
89
+ | `--include` | Comma-separated folders/files/extensions to **force include** |
90
+
91
+ ---
92
+
93
+ ### ✅ Example Command
94
+
95
+ ```bash
96
+ devDocs --path . \
97
+ --name "Cool Dev Tool" \
98
+ --description "Generate AI-based READMEs effortlessly" \
99
+ --authors "Gantavya Bansal" \
100
+ --keywords "cli, docs, automation, openai" \
101
+ --output docs \
102
+ --overwrite
103
+ ```
104
+
105
+ This will:
106
+
107
+ * Walk through all folders from current directory
108
+ * Create a `docs/README.md` and other structured markdowns
109
+ * Overwrite existing README if one exists
110
+
111
+ ---
112
+
113
+ ## 🧠 Features
114
+
115
+ * ✅ Generates structured, professional `README.md` files automatically
116
+ * ✅ Preserves original docs unless `--overwrite` is set
117
+ * ✅ Supports **include/exclude** filtering for granular control
118
+ * ✅ Smart project tree visualization included in docs
119
+ * ✅ Outputs all documentation to a single folder (`--output`)
120
+ * ✅ Powered by Google Gemini AI (clean & readable Markdown)
121
+
122
+ ---
123
+
124
+ ## 🏗️ Example Output (Generated)
125
+
126
+ Here’s a sample snippet of what the generated README might look like:
127
+
128
+ ```
129
+ # Cool Dev Tool
130
+
131
+ This is a CLI tool for generating clean README.md files using Google Gemini.
132
+
133
+ ## Folder Structure
134
+ your-project/
135
+ ├── src/
136
+ │ ├── main.py
137
+ │ └── utils.py
138
+ ├── README.md
139
+ ...
140
+
141
+ ## Usage
142
+ ...
143
+ ```
144
+
145
+ ---
146
+
147
+ ## 🧱 Technologies Used
148
+
149
+ * `Python 3.8+`
150
+ * [`google-genai`](https://pypi.org/project/google-generativeai/)
151
+ * `argparse`, `os`, `logging`, `time` – for CLI and system interaction
152
+
153
+ ---
154
+
155
+ ## 🧰 Developer Notes
156
+
157
+ If you're contributing or extending this project:
158
+
159
+ ### Core Files
160
+
161
+ | File | Purpose |
162
+ | ------------------ | ----------------------------------------------- |
163
+ | `cli.py` | CLI interface + core logic |
164
+ | `README.md` | The README template output (can be regenerated) |
165
+ | `LookFolder()` | Recursive folder/file scanner |
166
+ | `GenerateReadMe()` | Sends data to Gemini and processes results |
167
+ | `print_tree()` | Generates folder structure view in tree format |
168
+
169
+ ### Data Flow
170
+
171
+ 1. CLI parses args →
172
+ 2. Filters folders/files →
173
+ 3. Reads source + existing docs →
174
+ 4. Calls `GenerateReadMe()` →
175
+ 5. Writes Markdown to output
176
+
177
+ ### API Instruction Logic (Simplified)
178
+
179
+ ```python
180
+ system_instruction = '''
181
+ You are Gantavya Bansal, a senior engineer and tech writer.
182
+ Generate clean, professional Markdown documentation using code + structure context.
183
+ Include:
184
+ - Title
185
+ - Folder Tree
186
+ - Description
187
+ - Usage
188
+ - Tech Stack
189
+ - Known Issues
190
+ - Licensing
191
+ '''
192
+ ```
193
+
194
+ ---
195
+
196
+ ## ⚠️ Known Limitations
197
+
198
+ * 📡 Needs an internet connection for Gemini API
199
+ * 🔁 Limited retry logic for failed API calls
200
+ * ⚙️ Include/exclude filters don't yet support regex
201
+ * 📄 Only supports `.md` output format
202
+
203
+ ---
204
+
205
+ ## 📜 License
206
+
207
+ **MIT License** – You’re free to use, modify, and share.
208
+ Attribution is appreciated!
209
+
210
+ ---
211
+
212
+ ## 💬 Contributing
213
+
214
+ Feel free to open issues, suggest improvements, or contribute directly.
215
+ Pull requests are always welcome!
216
+
217
+ ---
@@ -1,112 +1,112 @@
1
- i='docs'
2
- V='utf-8'
3
- U='README'
4
- T=any
5
- S=open
6
- C='.md'
7
- M='.'
8
- G=str
9
- F=print
10
- E=Exception
11
- A=''
12
- from logging import basicConfig as j,info as H,WARNING as W,INFO,getLogger as X,exception as D
13
- from os import listdir as k,getcwd as J,chdir as O,scandir as l,curdir as m,makedirs as P
14
- from os.path import isdir as N,join as B,splitext as n,exists as Y,getsize as o,dirname as Z,abspath as a
15
- from google.genai import Client as p
16
- from google.genai.types import GenerateContentConfig as q
17
- from argparse import ArgumentParser as r
18
- from time import sleep
19
- j(level=INFO)
20
- X('google_genai').setLevel(W)
21
- X('httpx').setLevel(W)
22
- def s(file,code,readme):
23
- A=file
24
- try:sleep(1);B=f.models.generate_content(model='gemini-2.0-flash-lite',config=q(system_instruction='\nYou are Gantavya Bansal, a senior software engineer and expert technical writer. Your task is to generate clean, professional, and well-structured `README.md` documentation in Markdown format. Use the provided filename, source code, and any existing README or folder structure as context.\n\nYour output must be:\n\n- Concise and easy to follow\n- Focused on technical clarity and usability\n- Markdown-only (no extra commentary, no code fences)\n\nYour output must include:\n\n1. **Project Title** – Inferred from the filename or main script\n2. **Folder Structure** – Tree view if available, with clickable index links\n3. **Description** – What the project does and its purpose\n4. **How to Use** – Installation steps, CLI/API usage examples\n5. **Technologies Used** – Languages, tools, libraries\n6. **Architecture or Code Overview** – Key components, flow, functions, or classes\n7. **Known Issues / Improvements** – Current limitations, TODOs\n8. **Additional Notes or References** – Licensing, credits, related tools\n\nOnly return the final `README.md` content. Do not include any explanations, prefixes, or suffixes.\n\n '),contents=[f"Filename: {A}",f"Code:\n{code}",f"Existing README (if any):\n{readme}"]);return B.text.removeprefix('```markdown').removesuffix('```').strip()
25
- except E as C:D(f"Error generating README for {A}: {C}");return f"# {A}\n\n⚠️ Failed to generate documentation GEMINI SERVER ERROR."
26
- def b(start_path=M,prefix=A):
27
- L=prefix;C=start_path
28
- try:
29
- I=A;J=[];F=[]
30
- if not N(C):
31
- if N(Z(a(C))):C=Z(a(C))
32
- else:return A
33
- with l(C)as G:
34
- for H in G:
35
- if e(H.name):
36
- if H.is_dir():F.append(H.name)
37
- else:J.append(H.name)
38
- F.sort();J.sort();G=F+J
39
- for(O,K)in enumerate(G):
40
- P=B(C,K);M=O==len(G)-1;Q='└── 'if M else'├── ';I+=L+Q+K+'\n'
41
- if K in F:R=' 'if M else'│ ';I+=b(P,L+R)
42
- return I
43
- except E as S:D(f"Error generating Tree for {C} dir: {S}");return f"# {C}\n\n⚠️ Failed to generate documentation tree."
44
- def t(base,folders,files):
45
- I=files;G=folders;C=base
46
- try:
47
- F=K(C);F+=f"\n {b(start_path=C)} \n"
48
- if G:
49
- for L in G:O=B(J(),L);F+=f"\n readme for folder:{L} \n content inside: \n {K(O)} \n"
50
- if I:
51
- for N in I:F+=f"\n readme for file:{N} \n content inside: {K(N)} \n"
52
- c(U if C==M else C,F,K(U if C==M else C));H(A)
53
- except E as P:D(f"Error generating README for {C}: {P}")
54
- def K(file):
55
- B=file
56
- try:
57
- if Y(B+C):
58
- with S(B+C,'r',encoding=V)as F:return F.read()
59
- else:return A
60
- except E as G:D(f"Error reading README for {B}: {G}");return f"# {B}\n\n⚠️ Failed to read {B}.md"
61
- def u(file):
62
- A=file
63
- try:
64
- with S(A,'r',encoding=V)as B:return B.read()
65
- except E as C:D(f"Error reading code in {A}: {C}");return f"# {A}\n\n⚠️ Failed to read {A}"
66
- def c(file,code,readme):
67
- O='README.md';K=readme;G=file
68
- try:
69
- Q=J().replace(R,A).lstrip('\\/').replace('\\','/');L=B(R,I,Q);P(L,exist_ok=True);M=n(G)[0]+C
70
- if U in M.upper():
71
- if not h:H('skipping overwriting README');N=B(L,O)
72
- else:N=B(O)
73
- else:N=B(L,M)
74
- K=g+K
75
- with S(N,'w',encoding=V)as T:T.write(s(G,code,K))
76
- F(f"Written to: {M}")
77
- except E as W:D(f"Error writing README for {G}: {W}")
78
- L=['cache','node','module','pkg','package','@','$','#','&','util','hook','component','python','compile','dist','build','env',i,'lib','bin','obj','out','__pycache__','.next','.turbo','.expo','.idea','.vscode','coverage','test','tests','fixtures','migrations','assets','static','logs','debug','config','style']
79
- v=[M,'-','_','~']
80
- Q=['.log','.png','.jpg','.jpeg','.svg','.ico','.gif','.webp','.pyc','.class','.zip','.min.js','.mp4','.mp3','.wav','.pdf','.docx','.xlsx','.db','.sqlite','.bak','.7z','.rar','.tar.gz','.exe','.dll','.so','.ttf','.woff','.eot','.swp','.map','.webm',C,'.css']
81
- def d(base):
82
- I=base
83
- try:
84
- O(I);F(f"Reading Folder: {I}");P=[A for A in k()if e(A)];L=[A for A in P if N(B(J(),A))]
85
- if L:
86
- F('Folders found:')
87
- for C in L:H(C)
88
- for C in L:H(A);F(f"Opening Folder: {C}");d(C);F(f"Closing Folder: {C}");H(A)
89
- M=[A for A in P if not N(B(J(),A))and o(A)<1000000]
90
- if M:
91
- F('Files found:')
92
- for G in M:H(G)
93
- for G in M:Q=u(G);R=K(G);c(G,Q,R)
94
- t(I,L,M);O('..')
95
- except E as S:D(f"Failed to read {I} folder.")
96
- def w(include,exclude):
97
- C=exclude;B=include
98
- try:
99
- B=[A.strip()for A in B.split(',')if A.strip()];C=[A.strip()for A in C.split(',')if A.strip()]
100
- for F in B:L.append(F.strip())
101
- for A in C:
102
- if A in L:L.remove(A.strip())
103
- if A in Q:Q.remove(A.strip())
104
- except E as G:D('Error in use with args --include || --exclude')
105
- def e(entry):A=entry.lower();return not T(A.startswith(B)for B in v)and not T(A.endswith(B)for B in Q)and not T(B in A for B in L)
106
- def x():
107
- try:
108
- B=r(description='Auto-generate documentation from source code and folder structure.');B.add_argument('-p','--path',type=G,default=M,help='Root path to scan (default: current directory)');B.add_argument('--name',type=G,default='My Project',help='Project name to include in README');B.add_argument('--description',type=G,default='No description provided.',help='Short description of the project');B.add_argument('--authors',type=G,default='Anonymous',help='Comma-separated list of author names');B.add_argument('--keywords',type=G,default=A,help='Comma-separated keywords (e.g., cli, docs, auto)');B.add_argument('--overwrite',action='store_true',help='Overwrite existing README files (default: False)');B.add_argument('--output',type=G,default=i,help='Output dir where docs to be stored (default: docs)');B.add_argument('--exclude',type=G,default=A,help='Folders, files, extensionse to exclude ((e.g., docs, ext, setting, config)');B.add_argument('--include',type=G,default=A,help='Folders, files, extensionse to include ((e.g., docs, ext, setting, config)');global f;global R;global I;global g;global h;C=B.parse_args();R=J();h=C.overwrite;I=C.output;w(include=C.include,exclude=C.exclude)
109
- if not Y(I):P(I)
110
- L.append(I);g=f"name: {C.name}\ndescription: {C.description}\nauthors: {C.authors}\nkeywords: {C.keywords}";f=p(api_key=input('Paste your Google Gemini API Key here:').strip());F(f"📁 Starting in: {C.path}");P(I,exist_ok=True);O(C.path);d(m);F('✅ Documentation generated successfully.')
111
- except E as H:D('Error during execution. Try using --help.')
1
+ i='docs'
2
+ V='utf-8'
3
+ U='README'
4
+ T=any
5
+ S=open
6
+ C='.md'
7
+ M='.'
8
+ G=str
9
+ F=print
10
+ E=Exception
11
+ A=''
12
+ from logging import basicConfig as j,info as H,WARNING as W,INFO,getLogger as X,exception as D
13
+ from os import listdir as k,getcwd as J,chdir as O,scandir as l,curdir as m,makedirs as P
14
+ from os.path import isdir as N,join as B,splitext as n,exists as Y,getsize as o,dirname as Z,abspath as a
15
+ from google.genai import Client as p
16
+ from google.genai.types import GenerateContentConfig as q
17
+ from argparse import ArgumentParser as r
18
+ from time import sleep
19
+ j(level=INFO)
20
+ X('google_genai').setLevel(W)
21
+ X('httpx').setLevel(W)
22
+ def s(file,code,readme):
23
+ A=file
24
+ try:sleep(1);B=f.models.generate_content(model='gemini-2.0-flash-lite',config=q(system_instruction='\nYou are Gantavya Bansal, a senior software engineer and expert technical writer. Your task is to generate clean, professional, and well-structured `README.md` documentation in Markdown format. Use the provided filename, source code, and any existing README or folder structure as context.\n\nYour output must be:\n\n- Concise and easy to follow\n- Focused on technical clarity and usability\n- Markdown-only (no extra commentary, no code fences)\n\nYour output must include:\n\n1. **Project Title** – Inferred from the filename or main script\n2. **Folder Structure** – Tree view if available, with clickable index links\n3. **Description** – What the project does and its purpose\n4. **How to Use** – Installation steps, CLI/API usage examples\n5. **Technologies Used** – Languages, tools, libraries\n6. **Architecture or Code Overview** – Key components, flow, functions, or classes\n7. **Known Issues / Improvements** – Current limitations, TODOs\n8. **Additional Notes or References** – Licensing, credits, related tools\n\nOnly return the final `README.md` content. Do not include any explanations, prefixes, or suffixes.\n\n '),contents=[f"Filename: {A}",f"Code:\n{code}",f"Existing README (if any):\n{readme}"]);return B.text.removeprefix('```markdown').removesuffix('```').strip()
25
+ except E as C:D(f"Error generating README for {A}: {C}");return f"# {A}\n\n⚠️ Failed to generate documentation GEMINI SERVER ERROR."
26
+ def b(start_path=M,prefix=A):
27
+ L=prefix;C=start_path
28
+ try:
29
+ I=A;J=[];F=[]
30
+ if not N(C):
31
+ if N(Z(a(C))):C=Z(a(C))
32
+ else:return A
33
+ with l(C)as G:
34
+ for H in G:
35
+ if e(H.name):
36
+ if H.is_dir():F.append(H.name)
37
+ else:J.append(H.name)
38
+ F.sort();J.sort();G=F+J
39
+ for(O,K)in enumerate(G):
40
+ P=B(C,K);M=O==len(G)-1;Q='└── 'if M else'├── ';I+=L+Q+K+'\n'
41
+ if K in F:R=' 'if M else'│ ';I+=b(P,L+R)
42
+ return I
43
+ except E as S:D(f"Error generating Tree for {C} dir: {S}");return f"# {C}\n\n⚠️ Failed to generate documentation tree."
44
+ def t(base,folders,files):
45
+ I=files;G=folders;C=base
46
+ try:
47
+ F=K(C);F+=f"\n {b(start_path=C)} \n"
48
+ if G:
49
+ for L in G:O=B(J(),L);F+=f"\n readme for folder:{L} \n content inside: \n {K(O)} \n"
50
+ if I:
51
+ for N in I:F+=f"\n readme for file:{N} \n content inside: {K(N)} \n"
52
+ c(U if C==M else C,F,K(U if C==M else C));H(A)
53
+ except E as P:D(f"Error generating README for {C}: {P}")
54
+ def K(file):
55
+ B=file
56
+ try:
57
+ if Y(B+C):
58
+ with S(B+C,'r',encoding=V)as F:return F.read()
59
+ else:return A
60
+ except E as G:D(f"Error reading README for {B}: {G}");return f"# {B}\n\n⚠️ Failed to read {B}.md"
61
+ def u(file):
62
+ A=file
63
+ try:
64
+ with S(A,'r',encoding=V)as B:return B.read()
65
+ except E as C:D(f"Error reading code in {A}: {C}");return f"# {A}\n\n⚠️ Failed to read {A}"
66
+ def c(file,code,readme):
67
+ O='README.md';K=readme;G=file
68
+ try:
69
+ Q=J().replace(R,A).lstrip('\\/').replace('\\','/');L=B(R,I,Q);P(L,exist_ok=True);M=n(G)[0]+C
70
+ if U in M.upper():
71
+ if not h:H('skipping overwriting README');N=B(L,O)
72
+ else:N=B(O)
73
+ else:N=B(L,M)
74
+ K=g+K
75
+ with S(N,'w',encoding=V)as T:T.write(s(G,code,K))
76
+ F(f"Written to: {M}")
77
+ except E as W:D(f"Error writing README for {G}: {W}")
78
+ L=['cache','node','module','pkg','package','@','$','#','&','util','hook','component','python','compile','dist','build','env',i,'lib','bin','obj','out','__pycache__','.next','.turbo','.expo','.idea','.vscode','coverage','test','tests','fixtures','migrations','assets','static','logs','debug','config','style']
79
+ v=[M,'-','_','~']
80
+ Q=['.log','.png','.jpg','.jpeg','.svg','.ico','.gif','.webp','.pyc','.class','.zip','.min.js','.mp4','.mp3','.wav','.pdf','.docx','.xlsx','.db','.sqlite','.bak','.7z','.rar','.tar.gz','.exe','.dll','.so','.ttf','.woff','.eot','.swp','.map','.webm',C,'.css']
81
+ def d(base):
82
+ I=base
83
+ try:
84
+ O(I);F(f"Reading Folder: {I}");P=[A for A in k()if e(A)];L=[A for A in P if N(B(J(),A))]
85
+ if L:
86
+ F('Folders found:')
87
+ for C in L:H(C)
88
+ for C in L:H(A);F(f"Opening Folder: {C}");d(C);F(f"Closing Folder: {C}");H(A)
89
+ M=[A for A in P if not N(B(J(),A))and o(A)<1000000]
90
+ if M:
91
+ F('Files found:')
92
+ for G in M:H(G)
93
+ for G in M:Q=u(G);R=K(G);c(G,Q,R)
94
+ t(I,L,M);O('..')
95
+ except E as S:D(f"Failed to read {I} folder.")
96
+ def w(include,exclude):
97
+ C=exclude;B=include
98
+ try:
99
+ B=[A.strip()for A in B.split(',')if A.strip()];C=[A.strip()for A in C.split(',')if A.strip()]
100
+ for F in B:L.append(F.strip())
101
+ for A in C:
102
+ if A in L:L.remove(A.strip())
103
+ if A in Q:Q.remove(A.strip())
104
+ except E as G:D('Error in use with args --include || --exclude')
105
+ def e(entry):A=entry.lower();return not T(A.startswith(B)for B in v)and not T(A.endswith(B)for B in Q)and not T(B in A for B in L)
106
+ def x():
107
+ try:
108
+ B=r(description='Auto-generate documentation from source code and folder structure.');B.add_argument('-p','--path',type=G,default=M,help='Root path to scan (default: current directory)');B.add_argument('--name',type=G,default='My Project',help='Project name to include in README');B.add_argument('--description',type=G,default='No description provided.',help='Short description of the project');B.add_argument('--authors',type=G,default='Anonymous',help='Comma-separated list of author names');B.add_argument('--keywords',type=G,default=A,help='Comma-separated keywords (e.g., cli, docs, auto)');B.add_argument('--overwrite',action='store_true',help='Overwrite existing README files (default: False)');B.add_argument('--output',type=G,default=i,help='Output dir where docs to be stored (default: docs)');B.add_argument('--exclude',type=G,default=A,help='Folders, files, extensionse to exclude ((e.g., docs, ext, setting, config)');B.add_argument('--include',type=G,default=A,help='Folders, files, extensionse to include ((e.g., docs, ext, setting, config)');global f;global R;global I;global g;global h;C=B.parse_args();R=J();h=C.overwrite;I=C.output;w(include=C.include,exclude=C.exclude)
109
+ if not Y(I):P(I)
110
+ L.append(I);g=f"name: {C.name}\ndescription: {C.description}\nauthors: {C.authors}\nkeywords: {C.keywords}";f=p(api_key=input('Paste your Google Gemini API Key here:').strip());F(f"📁 Starting in: {C.path}");P(I,exist_ok=True);O(C.path);d(m);F('✅ Documentation generated successfully.')
111
+ except E as H:D('Error during execution. Try using --help.')
112
112
  if __name__=='__main__':x()