devDocs 0.1.0__py3-none-any.whl
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/__init__.py +0 -0
- devDocs/cli.py +112 -0
- devdocs-0.1.0.dist-info/METADATA +138 -0
- devdocs-0.1.0.dist-info/RECORD +7 -0
- devdocs-0.1.0.dist-info/WHEEL +5 -0
- devdocs-0.1.0.dist-info/entry_points.txt +2 -0
- devdocs-0.1.0.dist-info/top_level.txt +1 -0
devDocs/__init__.py
ADDED
|
File without changes
|
devDocs/cli.py
ADDED
|
@@ -0,0 +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.')
|
|
112
|
+
if __name__=='__main__':x()
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: devDocs
|
|
3
|
+
Version: 0.1.0
|
|
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
|
+
# My Project
|
|
22
|
+
|
|
23
|
+
## Folder Structure
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
.
|
|
27
|
+
├── main.py
|
|
28
|
+
├── secret
|
|
29
|
+
└── setup.py
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Description
|
|
33
|
+
|
|
34
|
+
No description provided.
|
|
35
|
+
|
|
36
|
+
## How to Use
|
|
37
|
+
|
|
38
|
+
No usage instructions provided. Refer to `main.py` and `setup.py` for potential execution details.
|
|
39
|
+
|
|
40
|
+
## Technologies Used
|
|
41
|
+
|
|
42
|
+
* Python
|
|
43
|
+
|
|
44
|
+
## Architecture or Code Overview
|
|
45
|
+
|
|
46
|
+
No architecture or code overview provided. Requires inspection of source files `main.py`, `secret`, and `setup.py`.
|
|
47
|
+
|
|
48
|
+
## Known Issues / Improvements
|
|
49
|
+
|
|
50
|
+
* No issues or improvements are provided.
|
|
51
|
+
|
|
52
|
+
## Additional Notes or References
|
|
53
|
+
|
|
54
|
+
* Authors: Anonymous
|
|
55
|
+
* Keywords: `# README`
|
|
56
|
+
|
|
57
|
+
# cli.py
|
|
58
|
+
|
|
59
|
+
## Folder Structure
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
.
|
|
63
|
+
├── cli.py
|
|
64
|
+
└── docs
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Description
|
|
68
|
+
|
|
69
|
+
This Python script automatically generates `README.md` documentation for a project by parsing the source code and folder structure. It utilizes the Google Gemini API to generate the documentation content and organizes the output within a specified directory.
|
|
70
|
+
|
|
71
|
+
## How to Use
|
|
72
|
+
|
|
73
|
+
1. **Install Dependencies:**
|
|
74
|
+
* Ensure you have Python and pip installed.
|
|
75
|
+
* Install the required packages: `pip install google-genai`
|
|
76
|
+
2. **Get a Google Gemini API Key:**
|
|
77
|
+
* Obtain an API key from Google AI Studio.
|
|
78
|
+
3. **Run the Script:**
|
|
79
|
+
* Navigate to the project directory in your terminal.
|
|
80
|
+
* Execute the script using: `python cli.py [OPTIONS]`
|
|
81
|
+
* When prompted, paste your Google Gemini API Key.
|
|
82
|
+
|
|
83
|
+
**CLI Options:**
|
|
84
|
+
|
|
85
|
+
* `-p` or `--path`: Root path to scan (default: `.`, current directory)
|
|
86
|
+
* `--name`: Project name to include in README (default: `My Project`)
|
|
87
|
+
* `--description`: Short description of the project (default: `No description provided.`)
|
|
88
|
+
* `--authors`: Comma-separated list of author names (default: `Anonymous`)
|
|
89
|
+
* `--keywords`: Comma-separated keywords (e.g., cli, docs, auto) (default: None)
|
|
90
|
+
* `--overwrite`: Overwrite existing README files (default: False)
|
|
91
|
+
* `--output`: Output directory where docs will be stored (default: `docs`)
|
|
92
|
+
* `--exclude`: Folders, files, extensions to exclude (e.g., docs, ext, setting, config)
|
|
93
|
+
* `--include`: Folders, files, extensions to include (e.g., docs, ext, setting, config)
|
|
94
|
+
|
|
95
|
+
**Example:**
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
python cli.py --path . --name "My Awesome Project" --description "A brief description of the project" --authors "Gantavya Bansal" --keywords "cli, documentation" --overwrite --output docs
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Technologies Used
|
|
102
|
+
|
|
103
|
+
* **Python:** Programming language.
|
|
104
|
+
* **google-genai:** Google Generative AI library.
|
|
105
|
+
* **argparse:** Parsing command-line arguments.
|
|
106
|
+
* **os:** File system operations.
|
|
107
|
+
* **logging:** Logging errors and information.
|
|
108
|
+
|
|
109
|
+
## Architecture or Code Overview
|
|
110
|
+
|
|
111
|
+
The script operates as follows:
|
|
112
|
+
|
|
113
|
+
1. **Initialization:** Sets up logging and imports necessary modules.
|
|
114
|
+
2. **Argument Parsing:** Uses `argparse` to handle command-line arguments.
|
|
115
|
+
3. **File System Traversal:**
|
|
116
|
+
* `d()`: Recursively traverses the directory structure, excluding and including files based on user-defined filters.
|
|
117
|
+
* `b()`: Generates a tree view of the project's folder structure.
|
|
118
|
+
4. **File Reading:**
|
|
119
|
+
* `u()`: Reads the content of a code file.
|
|
120
|
+
* `K()`: Reads an existing README file.
|
|
121
|
+
5. **Documentation Generation:**
|
|
122
|
+
* `s()`: Interacts with the Google Gemini API, passing the filename, code, and existing README to generate the Markdown documentation.
|
|
123
|
+
6. **README Writing:**
|
|
124
|
+
* `c()`: Writes the generated documentation to a `README.md` file.
|
|
125
|
+
7. **Main Execution:** The `x()` function handles the main workflow: parses arguments, sets up the Gemini API client, traverses the file structure, and generates the documentation.
|
|
126
|
+
|
|
127
|
+
## Known Issues / Improvements
|
|
128
|
+
|
|
129
|
+
* Error handling for API failures is basic. Implement more robust retry mechanisms.
|
|
130
|
+
* Improve the exclusion and inclusion logic to support more complex patterns.
|
|
131
|
+
* Enhance the prompt sent to the Gemini API for more accurate and detailed documentation.
|
|
132
|
+
* Add support for different output formats (e.g., other than Markdown).
|
|
133
|
+
|
|
134
|
+
## Additional Notes or References
|
|
135
|
+
|
|
136
|
+
* This script utilizes the Google Gemini API. Ensure you have a valid API key.
|
|
137
|
+
* The generated documentation is based on the provided context and the Gemini API's output.
|
|
138
|
+
* Consider licensing your project with a license file.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
devDocs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
devDocs/cli.py,sha256=dBh4CWo663DO3Y6BaK6pzt0bbM59dby5Ohwq756sjdA,7146
|
|
3
|
+
devdocs-0.1.0.dist-info/METADATA,sha256=00hw2QFrEtbVoKUiw8SDGvtbcm7OFBBD3qigLhYnEks,5129
|
|
4
|
+
devdocs-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
+
devdocs-0.1.0.dist-info/entry_points.txt,sha256=qYlCz-Z_YdF0iwwqYyS0HOnD-pCODGZK1uDUOz153cY,42
|
|
6
|
+
devdocs-0.1.0.dist-info/top_level.txt,sha256=8MbR4oIDdHPewET4lABX_7hFOOwNM5Kxdm-VcUfx86k,8
|
|
7
|
+
devdocs-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
devDocs
|