diff --git a/README.md b/README.md index 1c430b3..c952083 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@ --- -# PKG NAMEπŸ“˜: `devDocs` – AI-powered automated project documentation writer +# πŸ“˜ `devDocs` – AI-Powered README Generator -`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. +`devDocs` is a command-line tool that automatically generates clean, professional `README.md` files by analyzing your **project structure**, **source code**, and any **existing documentation**. -Perfect for: +Powered by the **Google Gemini API**, it's ideal for: -* Open-source contributors πŸ’‘ -* Developers maintaining internal tools πŸ› οΈ -* Hackathon projects needing clean docs fast πŸš€ +* πŸ’‘ Open-source contributors +* πŸ› οΈ Internal dev tools +* πŸš€ Hackathon projects needing docs fast --- -## πŸ“‚ Example Project Structure +## πŸ“‚ Example Project Layout -Here’s how your project might look before and after using `devDocs`: +Before and after running `devDocs`: ```bash your-project/ @@ -25,30 +25,29 @@ your-project/ β”œβ”€β”€ tests/ β”œβ”€β”€ requirements.txt β”œβ”€β”€ LICENSE -└── README.md <-- Generated/Overwritten by devDocs +β”œβ”€β”€ docs/ # ← Generated by devDocs +└── README.md # ← Overwritten by devDocs (if chosen) ``` --- -## βš™οΈ How It Works (Behind the Scenes) +## βš™οΈ How It Works -Here's what happens when you run `devDocs`: +1. **Scans** project directory and source files +2. **Parses** content (code, comments, old README) +3. **Generates** documentation via Google Gemini +4. **Saves** output in Markdown format -1. **Scans your project** – Analyzes directory structure, code files, and existing README files. -2. **Parses content** – Gathers code and documentation from each relevant file/folder. -3. **Generates documentation** – Sends context to Google Gemini API to craft a structured `README.md`. -4. **Saves output** – Writes the generated Markdown into your project (or into a custom output folder). +### Optional Features -πŸ” Optional features: - -* Preserves your original README unless you use `--overwrite`. -* Includes/excludes specific files or folders with filters. +* Preserve existing README (unless `--overwrite` is set) +* Include/exclude specific files or folders via filters --- ## πŸ“¦ Installation -Install from PyPI: +Install via pip: ```bash pip install devDocs @@ -58,128 +57,84 @@ pip install devDocs ## πŸ”‘ Requirements -* **Python 3.8+** -* **Google Gemini API Key** - Get one from [Google AI Studio](https://aistudio.google.com/). +* Python 3.8+ +* Google Gemini API Key (get one at [Google AI Studio](https://aistudio.google.com/)) --- ## πŸš€ Usage -Inside the root folder of your project, run: +Run inside your project’s root: ```bash devDocs [OPTIONS] ``` -The CLI will prompt for your **Google Gemini API key**. Paste it once when asked. +Paste your **Gemini API key** when prompted. ### CLI Options -| Option | Description | -| --------------- | ------------------------------------------------------------- | -| `--path` | Root path to scan (default: current directory) | -| `--name` | Project name to display in the README | -| `--description` | Short description for the project | -| `--authors` | Comma-separated list of authors | -| `--keywords` | Comma-separated list of keywords (e.g., cli, docs, auto) | -| `--overwrite` | Overwrite existing `README.md` files (default: False) | -| `--output` | Output folder to save generated docs (default: `docs/`) | -| `--exclude` | Comma-separated folders/files/extensions to **exclude** | -| `--include` | Comma-separated folders/files/extensions to **force include** | +| Option | Description | +| --------------- | ------------------------------------------------- | +| `--path` | Root folder to scan (default: `.`) | +| `--name` | Project name to display in the README | +| `--description` | Short project summary | +| `--authors` | Comma-separated list of authors | +| `--keywords` | Comma-separated keywords (e.g., cli, docs, ai) | +| `--overwrite` | Overwrite existing `README.md` (default: False) | +| `--output` | Output folder (default: `docs/`) | +| `--exclude` | Comma-separated paths/extensions to exclude | +| `--include` | Comma-separated paths/extensions to force include | --- -### βœ… Example Command +### βœ… Example ```bash devDocs --path . \ --name "Cool Dev Tool" \ --description "Generate AI-based READMEs effortlessly" \ --authors "Gantavya Bansal" \ - --keywords "cli, docs, automation, openai" \ + --keywords "cli, docs, automation" \ --output docs \ --overwrite ``` -This will: - -* Walk through all folders from current directory -* Create a `docs/README.md` and other structured markdowns -* Overwrite existing README if one exists - --- -## 🧠 Features +## 🧠 Key Features -* βœ… Generates structured, professional `README.md` files automatically -* βœ… Preserves original docs unless `--overwrite` is set -* βœ… Supports **include/exclude** filtering for granular control -* βœ… Smart project tree visualization included in docs -* βœ… Outputs all documentation to a single folder (`--output`) -* βœ… Powered by Google Gemini AI (clean & readable Markdown) +βœ… Auto-generates structured `README.md` +βœ… Respects original files unless `--overwrite` +βœ… Fine-grained include/exclude control +βœ… Generates a visual folder tree +βœ… Clean output in a dedicated `--output` folder +βœ… Backed by Google Gemini for high-quality results --- -## πŸ—οΈ Example Output (Generated) - -Here’s a sample snippet of what the generated README might look like: - -``` -# Cool Dev Tool - -This is a CLI tool for generating clean README.md files using Google Gemini. - -## Folder Structure -your-project/ -β”œβ”€β”€ src/ -β”‚ β”œβ”€β”€ main.py -β”‚ └── utils.py -β”œβ”€β”€ README.md -... +## 🧱 Tech Stack -## Usage -... -``` - ---- - -## 🧱 Technologies Used - -* `Python 3.8+` +* Python 3.8+ * [`google-genai`](https://pypi.org/project/google-generativeai/) -* `argparse`, `os`, `logging`, `time` – for CLI and system interaction +* Built-in: `argparse`, `os`, `logging`, `time` --- -## 🧰 Developer Notes - -If you're contributing or extending this project: +## πŸ› οΈ Dev Notes -### Core Files +### Workflow -| File | Purpose | -| ------------------ | ----------------------------------------------- | -| `cli.py` | CLI interface + core logic | -| `README.md` | The README template output (can be regenerated) | -| `LookFolder()` | Recursive folder/file scanner | -| `GenerateReadMe()` | Sends data to Gemini and processes results | -| `print_tree()` | Generates folder structure view in tree format | - -### Data Flow - -1. CLI parses args β†’ -2. Filters folders/files β†’ -3. Reads source + existing docs β†’ -4. Calls `GenerateReadMe()` β†’ -5. Writes Markdown to output +``` +CLI args β†’ Filter files β†’ Extract context β†’ Call Gemini β†’ Write docs +``` -### API Instruction Logic (Simplified) +### API Prompt Template ```python system_instruction = ''' -You are Gantavya Bansal, a senior engineer and tech writer. -Generate clean, professional Markdown documentation using code + structure context. +You are Gantavya Bansal, a senior engineer and technical writer. +Generate professional Markdown documentation using context from code and folder structure. Include: - Title - Folder Tree @@ -193,25 +148,24 @@ Include: --- -## ⚠️ Known Limitations +## ⚠️ Limitations -* πŸ“‘ Needs an internet connection for Gemini API -* πŸ” Limited retry logic for failed API calls -* βš™οΈ Include/exclude filters don't yet support regex -* πŸ“„ Only supports `.md` output format +* πŸ“Ά Requires internet (for Gemini API) +* πŸ” Retry logic for failed API calls is minimal +* ❌ Regex not yet supported in filters +* πŸ“„ Only outputs `.md` format (Markdown) --- ## πŸ“œ License -**MIT License** – You’re free to use, modify, and share. -Attribution is appreciated! +Released under the **MIT License**. Use, modify, and share freely β€” attribution appreciated. --- -## πŸ’¬ Contributing +## 🀝 Contribute -Feel free to open issues, suggest improvements, or contribute directly. -Pull requests are always welcome! +Found a bug or have an idea? +Open an issue or submit a PR β€” contributions are always welcome! ---- +--- \ No newline at end of file diff --git a/devDocs.egg-info/PKG-INFO b/devDocs.egg-info/PKG-INFO index f15f120..d30d931 100644 --- a/devDocs.egg-info/PKG-INFO +++ b/devDocs.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: devDocs -Version: 1.0.3 +Version: 2.0.7 Summary: AI-powered CLI tool that builds professional '*.md' documentation files of a project for internal teams using the Google Gemini API. Author: Gantavya Bansal Author-email: Gantavya Bansal @@ -34,21 +34,21 @@ Dynamic: requires-python --- -# PKG NAMEπŸ“˜: `devDocs` – AI-powered automated project documentation writer +# πŸ“˜ `devDocs` – AI-Powered README Generator -`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. +`devDocs` is a command-line tool that automatically generates clean, professional `README.md` files by analyzing your **project structure**, **source code**, and any **existing documentation**. -Perfect for: +Powered by the **Google Gemini API**, it's ideal for: -* Open-source contributors πŸ’‘ -* Developers maintaining internal tools πŸ› οΈ -* Hackathon projects needing clean docs fast πŸš€ +* πŸ’‘ Open-source contributors +* πŸ› οΈ Internal dev tools +* πŸš€ Hackathon projects needing docs fast --- -## πŸ“‚ Example Project Structure +## πŸ“‚ Example Project Layout -Here’s how your project might look before and after using `devDocs`: +Before and after running `devDocs`: ```bash your-project/ @@ -58,30 +58,29 @@ your-project/ β”œβ”€β”€ tests/ β”œβ”€β”€ requirements.txt β”œβ”€β”€ LICENSE -└── README.md <-- Generated/Overwritten by devDocs +β”œβ”€β”€ docs/ # ← Generated by devDocs +└── README.md # ← Overwritten by devDocs (if chosen) ``` --- -## βš™οΈ How It Works (Behind the Scenes) +## βš™οΈ How It Works -Here's what happens when you run `devDocs`: +1. **Scans** project directory and source files +2. **Parses** content (code, comments, old README) +3. **Generates** documentation via Google Gemini +4. **Saves** output in Markdown format -1. **Scans your project** – Analyzes directory structure, code files, and existing README files. -2. **Parses content** – Gathers code and documentation from each relevant file/folder. -3. **Generates documentation** – Sends context to Google Gemini API to craft a structured `README.md`. -4. **Saves output** – Writes the generated Markdown into your project (or into a custom output folder). +### Optional Features -πŸ” Optional features: - -* Preserves your original README unless you use `--overwrite`. -* Includes/excludes specific files or folders with filters. +* Preserve existing README (unless `--overwrite` is set) +* Include/exclude specific files or folders via filters --- ## πŸ“¦ Installation -Install from PyPI: +Install via pip: ```bash pip install devDocs @@ -91,128 +90,84 @@ pip install devDocs ## πŸ”‘ Requirements -* **Python 3.8+** -* **Google Gemini API Key** - Get one from [Google AI Studio](https://aistudio.google.com/). +* Python 3.8+ +* Google Gemini API Key (get one at [Google AI Studio](https://aistudio.google.com/)) --- ## πŸš€ Usage -Inside the root folder of your project, run: +Run inside your project’s root: ```bash devDocs [OPTIONS] ``` -The CLI will prompt for your **Google Gemini API key**. Paste it once when asked. +Paste your **Gemini API key** when prompted. ### CLI Options -| Option | Description | -| --------------- | ------------------------------------------------------------- | -| `--path` | Root path to scan (default: current directory) | -| `--name` | Project name to display in the README | -| `--description` | Short description for the project | -| `--authors` | Comma-separated list of authors | -| `--keywords` | Comma-separated list of keywords (e.g., cli, docs, auto) | -| `--overwrite` | Overwrite existing `README.md` files (default: False) | -| `--output` | Output folder to save generated docs (default: `docs/`) | -| `--exclude` | Comma-separated folders/files/extensions to **exclude** | -| `--include` | Comma-separated folders/files/extensions to **force include** | +| Option | Description | +| --------------- | ------------------------------------------------- | +| `--path` | Root folder to scan (default: `.`) | +| `--name` | Project name to display in the README | +| `--description` | Short project summary | +| `--authors` | Comma-separated list of authors | +| `--keywords` | Comma-separated keywords (e.g., cli, docs, ai) | +| `--overwrite` | Overwrite existing `README.md` (default: False) | +| `--output` | Output folder (default: `docs/`) | +| `--exclude` | Comma-separated paths/extensions to exclude | +| `--include` | Comma-separated paths/extensions to force include | --- -### βœ… Example Command +### βœ… Example ```bash devDocs --path . \ --name "Cool Dev Tool" \ --description "Generate AI-based READMEs effortlessly" \ --authors "Gantavya Bansal" \ - --keywords "cli, docs, automation, openai" \ + --keywords "cli, docs, automation" \ --output docs \ --overwrite ``` -This will: - -* Walk through all folders from current directory -* Create a `docs/README.md` and other structured markdowns -* Overwrite existing README if one exists - --- -## 🧠 Features - -* βœ… Generates structured, professional `README.md` files automatically -* βœ… Preserves original docs unless `--overwrite` is set -* βœ… Supports **include/exclude** filtering for granular control -* βœ… Smart project tree visualization included in docs -* βœ… Outputs all documentation to a single folder (`--output`) -* βœ… Powered by Google Gemini AI (clean & readable Markdown) - ---- - -## πŸ—οΈ Example Output (Generated) - -Here’s a sample snippet of what the generated README might look like: - -``` -# Cool Dev Tool - -This is a CLI tool for generating clean README.md files using Google Gemini. +## 🧠 Key Features -## Folder Structure -your-project/ -β”œβ”€β”€ src/ -β”‚ β”œβ”€β”€ main.py -β”‚ └── utils.py -β”œβ”€β”€ README.md -... - -## Usage -... -``` +βœ… Auto-generates structured `README.md` +βœ… Respects original files unless `--overwrite` +βœ… Fine-grained include/exclude control +βœ… Generates a visual folder tree +βœ… Clean output in a dedicated `--output` folder +βœ… Backed by Google Gemini for high-quality results --- -## 🧱 Technologies Used +## 🧱 Tech Stack -* `Python 3.8+` +* Python 3.8+ * [`google-genai`](https://pypi.org/project/google-generativeai/) -* `argparse`, `os`, `logging`, `time` – for CLI and system interaction +* Built-in: `argparse`, `os`, `logging`, `time` --- -## 🧰 Developer Notes +## πŸ› οΈ Dev Notes -If you're contributing or extending this project: +### Workflow -### Core Files - -| File | Purpose | -| ------------------ | ----------------------------------------------- | -| `cli.py` | CLI interface + core logic | -| `README.md` | The README template output (can be regenerated) | -| `LookFolder()` | Recursive folder/file scanner | -| `GenerateReadMe()` | Sends data to Gemini and processes results | -| `print_tree()` | Generates folder structure view in tree format | - -### Data Flow - -1. CLI parses args β†’ -2. Filters folders/files β†’ -3. Reads source + existing docs β†’ -4. Calls `GenerateReadMe()` β†’ -5. Writes Markdown to output +``` +CLI args β†’ Filter files β†’ Extract context β†’ Call Gemini β†’ Write docs +``` -### API Instruction Logic (Simplified) +### API Prompt Template ```python system_instruction = ''' -You are Gantavya Bansal, a senior engineer and tech writer. -Generate clean, professional Markdown documentation using code + structure context. +You are Gantavya Bansal, a senior engineer and technical writer. +Generate professional Markdown documentation using context from code and folder structure. Include: - Title - Folder Tree @@ -226,25 +181,24 @@ Include: --- -## ⚠️ Known Limitations +## ⚠️ Limitations -* πŸ“‘ Needs an internet connection for Gemini API -* πŸ” Limited retry logic for failed API calls -* βš™οΈ Include/exclude filters don't yet support regex -* πŸ“„ Only supports `.md` output format +* πŸ“Ά Requires internet (for Gemini API) +* πŸ” Retry logic for failed API calls is minimal +* ❌ Regex not yet supported in filters +* πŸ“„ Only outputs `.md` format (Markdown) --- ## πŸ“œ License -**MIT License** – You’re free to use, modify, and share. -Attribution is appreciated! +Released under the **MIT License**. Use, modify, and share freely β€” attribution appreciated. --- -## πŸ’¬ Contributing +## 🀝 Contribute -Feel free to open issues, suggest improvements, or contribute directly. -Pull requests are always welcome! +Found a bug or have an idea? +Open an issue or submit a PR β€” contributions are always welcome! --- diff --git a/devDocs.egg-info/entry_points.txt b/devDocs.egg-info/entry_points.txt index 8f786ac..fa5e6cd 100644 --- a/devDocs.egg-info/entry_points.txt +++ b/devDocs.egg-info/entry_points.txt @@ -1,2 +1,2 @@ [console_scripts] -devDocs = devDocs.cli:x +devDocs = devDocs.cli:y diff --git a/devDocs/cli.py b/devDocs/cli.py index d66c622..89853fa 100644 --- a/devDocs/cli.py +++ b/devDocs/cli.py @@ -1,112 +1,119 @@ -i='docs' -V='utf-8' -U='README' -T=any -S=open -C='.md' -M='.' +k='docs' +Y='utf-8' +X='README' +W=any +V=open +Q='.md' +N='.' G=str F=print -E=Exception -A='' -from logging import basicConfig as j,info as H,WARNING as W,INFO,getLogger as X,exception as D -from os import listdir as k,getcwd as J,chdir as O,scandir as l,curdir as m,makedirs as P -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 -from google.genai import Client as p -from google.genai.types import GenerateContentConfig as q -from argparse import ArgumentParser as r +B='' +A=Exception +from logging import basicConfig as l,info as H,WARNING as Z,INFO,getLogger as a,exception as E +from os import listdir as m,getcwd as J,chdir as R,scandir as n,curdir as o,makedirs as S +from os.path import isdir as O,join as C,splitext as p,exists as b,getsize as q,dirname as c,abspath as d +from google.genai import Client as r +from google.genai.types import GenerateContentConfig as D +from argparse import ArgumentParser as s from time import sleep -j(level=INFO) -X('google_genai').setLevel(W) -X('httpx').setLevel(W) -def s(file,code,readme): - A=file - 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() - except E as C:D(f"Error generating README for {A}: {C}");return f"# {A}\n\n⚠️ Failed to generate documentation GEMINI SERVER ERROR." -def b(start_path=M,prefix=A): - L=prefix;C=start_path +l(level=INFO) +a('google_genai').setLevel(Z) +a('httpx').setLevel(Z) +P='\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 ' +def t(file,code,readme): + J='```';I='```markdown';G=readme;F=code;C=file + try:B=M.models.generate_content(model='gemini-2.0-flash-lite',config=D(system_instruction=P),contents=[f"Filename: {C}",f"Code:\n{F}",f"Existing README (if any):\n{G}"]);return B.text.removeprefix(I).removesuffix(J).strip() + except A as H: + try:B=M.models.generate_content(model='gemini-2.0-flash',config=D(system_instruction=P),contents=[f"Filename: {C}",f"Code:\n{F}",f"Existing README (if any):\n{G}"]);return B.text.removeprefix(I).removesuffix(J).strip() + except A as H: + try:B=M.models.generate_content(model='gemini-2.5-flash-lite',config=D(system_instruction=P),contents=[f"Filename: {C}",f"Code:\n{F}",f"Existing README (if any):\n{G}"]);return B.text.removeprefix(I).removesuffix(J).strip() + except A as H: + try:B=M.models.generate_content(model='gemini-2.5-flash',config=D(system_instruction=P),contents=[f"Filename: {C}",f"Code:\n{F}",f"Existing README (if any):\n{G}"]);return B.text.removeprefix(I).removesuffix(J).strip() + except A as H:E(f"Error generating README for {C}: {H}");return f"# {C}\n\n⚠️ Failed to generate documentation GEMINI SERVER ERROR." +def e(start_path=N,prefix=B): + L=prefix;D=start_path try: - I=A;J=[];F=[] - if not N(C): - if N(Z(a(C))):C=Z(a(C)) - else:return A - with l(C)as G: + I=B;J=[];F=[] + if not O(D): + if O(c(d(D))):D=c(d(D)) + else:return B + with n(D)as G: for H in G: - if e(H.name): + if h(H.name): if H.is_dir():F.append(H.name) else:J.append(H.name) F.sort();J.sort();G=F+J - for(O,K)in enumerate(G): - P=B(C,K);M=O==len(G)-1;Q='└── 'if M else'β”œβ”€β”€ ';I+=L+Q+K+'\n' - if K in F:R=' 'if M else'β”‚ ';I+=b(P,L+R) + for(N,K)in enumerate(G): + P=C(D,K);M=N==len(G)-1;Q='└── 'if M else'β”œβ”€β”€ ';I+=L+Q+K+'\n' + if K in F:R=' 'if M else'β”‚ ';I+=e(P,L+R) return I - except E as S:D(f"Error generating Tree for {C} dir: {S}");return f"# {C}\n\n⚠️ Failed to generate documentation tree." -def t(base,folders,files): - I=files;G=folders;C=base + except A as S:E(f"Error generating Tree for {D} dir: {S}");return f"# {D}\n\n⚠️ Failed to generate documentation tree." +def u(base,folders,files): + I=files;G=folders;D=base try: - F=K(C);F+=f"\n {b(start_path=C)} \n" + F=K(D);F+=f"\n {e(start_path=D)} \n" if G: - for L in G:O=B(J(),L);F+=f"\n readme for folder:{L} \n content inside: \n {K(O)} \n" + for L in G:O=C(J(),L);F+=f"\n readme for folder:{L} \n content inside: \n {K(O)} \n" if I: - for N in I:F+=f"\n readme for file:{N} \n content inside: {K(N)} \n" - c(U if C==M else C,F,K(U if C==M else C));H(A) - except E as P:D(f"Error generating README for {C}: {P}") + for M in I:F+=f"\n readme for file:{M} \n content inside: {K(M)} \n" + f(X if D==N else D,F,K(X if D==N else D));H(B) + except A as P:E(f"Error generating README for {D}: {P}") def K(file): - B=file + C=file try: - if Y(B+C): - with S(B+C,'r',encoding=V)as F:return F.read() - else:return A - except E as G:D(f"Error reading README for {B}: {G}");return f"# {B}\n\n⚠️ Failed to read {B}.md" -def u(file): - A=file + if b(C+Q): + with V(C+Q,'r',encoding=Y)as D:return D.read() + else:return B + except A as F:E(f"Error reading README for {C}: {F}");return f"# {C}\n\n⚠️ Failed to read {C}.md" +def v(file): + B=file try: - with S(A,'r',encoding=V)as B:return B.read() - except E as C:D(f"Error reading code in {A}: {C}");return f"# {A}\n\n⚠️ Failed to read {A}" -def c(file,code,readme): - O='README.md';K=readme;G=file + with V(B,'r',encoding=Y)as C:return C.read() + except A as D:E(f"Error reading code in {B}: {D}");return f"# {B}\n\n⚠️ Failed to read {B}" +def f(file,code,readme): + N='README.md';G=readme;D=file try: - Q=J().replace(R,A).lstrip('\\/').replace('\\','/');L=B(R,I,Q);P(L,exist_ok=True);M=n(G)[0]+C - if U in M.upper(): - if not h:H('skipping overwriting README');N=B(L,O) - else:N=B(O) - else:N=B(L,M) - K=g+K - with S(N,'w',encoding=V)as T:T.write(s(G,code,K)) - F(f"Written to: {M}") - except E as W:D(f"Error writing README for {G}: {W}") -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'] -v=[M,'-','_','~'] -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'] -def d(base): + O=J().replace(U,B).lstrip('\\/').replace('\\','/');K=C(U,I,O);S(K,exist_ok=True);L=p(D)[0]+Q + if X in L.upper(): + if not j:H('skipping overwriting README');M=C(K,N) + else:M=C(N) + else:M=C(K,L) + G=i+G + with V(M,'w',encoding=Y)as P:P.write(t(D,code,G)) + F(f"Written to: {L}") + except A as R:E(f"Error writing README for {D}: {R}") +L=['cache','node','module','pkg','package','@','$','#','&','util','hook','component','python','compile','dist','build','env',k,'lib','bin','obj','out','__pycache__','.next','.turbo','.expo','.idea','.vscode','coverage','test','tests','fixtures','migrations','assets','static','logs','debug','config','style'] +w=[N,'-','_','~'] +T=['.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',Q,'.css'] +def g(base): I=base try: - 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))] + R(I);F(f"Reading Folder: {I}");N=[A for A in m()if h(A)];L=[A for A in N if O(C(J(),A))] if L: F('Folders found:') - for C in L:H(C) - for C in L:H(A);F(f"Opening Folder: {C}");d(C);F(f"Closing Folder: {C}");H(A) - M=[A for A in P if not N(B(J(),A))and o(A)<1000000] + for D in L:H(D) + for D in L:H(B);F(f"Opening Folder: {D}");g(D);F(f"Closing Folder: {D}");H(B) + M=[A for A in N if not O(C(J(),A))and q(A)<1000000] if M: F('Files found:') for G in M:H(G) - for G in M:Q=u(G);R=K(G);c(G,Q,R) - t(I,L,M);O('..') - except E as S:D(f"Failed to read {I} folder.") -def w(include,exclude): - C=exclude;B=include + for G in M:P=v(G);Q=K(G);f(G,P,Q) + u(I,L,M);R('..') + except A as S:E(f"Failed to read {I} folder.") +def x(include,exclude): + D=exclude;C=include try: - B=[A.strip()for A in B.split(',')if A.strip()];C=[A.strip()for A in C.split(',')if A.strip()] - for F in B:L.append(F.strip()) - for A in C: - if A in L:L.remove(A.strip()) - if A in Q:Q.remove(A.strip()) - except E as G:D('Error in use with args --include || --exclude') -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) -def x(): + C=[A.strip()for A in C.split(',')if A.strip()];D=[A.strip()for A in D.split(',')if A.strip()] + for F in C:L.append(F.strip()) + for B in D: + if B in L:L.remove(B.strip()) + if B in T:T.remove(B.strip()) + except A as G:E('Error in use with args --include || --exclude') +def h(entry):A=entry.lower();return not W(A.startswith(B)for B in w)and not W(A.endswith(B)for B in T)and not W(B in A for B in L) +def y(): try: - 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) - if not Y(I):P(I) - 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.') - except E as H:D('Error during execution. Try using --help.') -if __name__=='__main__':x() \ No newline at end of file + C=s(description='Auto-generate documentation from source code and folder structure.');C.add_argument('-p','--path',type=G,default=N,help='Root path to scan (default: current directory)');C.add_argument('--name',type=G,default='My Project',help='Project name to include in README');C.add_argument('--description',type=G,default='No description provided.',help='Short description of the project');C.add_argument('--authors',type=G,default='Anonymous',help='Comma-separated list of author names');C.add_argument('--keywords',type=G,default=B,help='Comma-separated keywords (e.g., cli, docs, auto)');C.add_argument('--overwrite',action='store_true',help='Overwrite existing README files (default: False)');C.add_argument('--output',type=G,default=k,help='Output dir where docs to be stored (default: docs)');C.add_argument('--exclude',type=G,default=B,help='Folders, files, extensionse to exclude ((e.g., docs, ext, setting, config)');C.add_argument('--include',type=G,default=B,help='Folders, files, extensionse to include ((e.g., docs, ext, setting, config)');global M;global U;global I;global i;global j;D=C.parse_args();U=J();j=D.overwrite;I=D.output;x(include=D.include,exclude=D.exclude) + if not b(I):S(I) + L.append(I);i=f"name: {D.name}\ndescription: {D.description}\nauthors: {D.authors}\nkeywords: {D.keywords}";M=r(api_key=input('Paste your Google Gemini API Key here:').strip());F(f"πŸ“ Starting in: {D.path}");S(I,exist_ok=True);R(D.path);g(o);F('βœ… Documentation generated successfully.') + except A as H:E('Error during execution. Try using --help.') +if __name__=='__main__':y() \ No newline at end of file diff --git a/dist/devdocs-1.0.3-py3-none-any.whl b/dist/devdocs-1.0.3-py3-none-any.whl deleted file mode 100644 index 16f24bd..0000000 Binary files a/dist/devdocs-1.0.3-py3-none-any.whl and /dev/null differ diff --git a/dist/devdocs-1.0.3.tar.gz b/dist/devdocs-1.0.3.tar.gz deleted file mode 100644 index d3c9f85..0000000 Binary files a/dist/devdocs-1.0.3.tar.gz and /dev/null differ diff --git a/dist/devdocs-2.0.7-py3-none-any.whl b/dist/devdocs-2.0.7-py3-none-any.whl new file mode 100644 index 0000000..e1f947c Binary files /dev/null and b/dist/devdocs-2.0.7-py3-none-any.whl differ diff --git a/dist/devdocs-2.0.7.tar.gz b/dist/devdocs-2.0.7.tar.gz new file mode 100644 index 0000000..24929b3 Binary files /dev/null and b/dist/devdocs-2.0.7.tar.gz differ diff --git a/pyproject.toml b/pyproject.toml index 2cd8e1d..300701c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "devDocs" -version = "1.0.3" +version = "2.0.7" description = "AI-powered CLI tool that builds professional '*.md' documentation files of a project for internal teams using the Google Gemini API." readme = "README.md" requires-python = ">=3.8" @@ -49,7 +49,7 @@ Issues = "https://github.com/bgantavya/devDocs/issues" Documentation = "https://github.com/bgantavya/devDocs#readme" [project.scripts] -devDocs = "devDocs.cli:x" +devDocs = "devDocs.cli:y" [tool.setuptools] packages = ["devDocs"] diff --git a/secret b/secret index aca2be0..3504d71 100644 --- a/secret +++ b/secret @@ -20,4 +20,4 @@ pkg/shared β”œβ”€β”€ README.md └── LICENSE -AIzaSyBSqYXDmaSVTTT6N9Qn_oBlbzFtyIGQ4vQ +freekey = 'AIzaSyBSqYXDmaSVTTT6N9Qn_oBlbzFtyIGQ4vQ' diff --git a/setup.py b/setup.py index c5c9d42..c3e4c98 100644 --- a/setup.py +++ b/setup.py @@ -1,2 +1,2 @@ from setuptools import setup,find_packages as A -setup(name='devDocs',version='1.0.3',packages=A(),install_requires=['google-generativeai'],entry_points={'console_scripts':['devDocs=devDocs.cli:x']},author='Gantavya Bansal',description="Auto-generate Project's markdown documentation using Gemini AI for Internal teams.",long_description=open('README.md',encoding='utf-8').read(),long_description_content_type='text/markdown',license='MIT',python_requires='>=3.8',classifiers=['Programming Language :: Python :: 3','License :: OSI Approved :: MIT License']) \ No newline at end of file +setup(name='devDocs',version='2.0.7',packages=A(),install_requires=['google-generativeai'],entry_points={'console_scripts':['devDocs=devDocs.cli:y']},author='Gantavya Bansal',description="Auto-generate Project's markdown documentation using Gemini AI for Internal teams.",long_description=open('README.md',encoding='utf-8').read(),long_description_content_type='text/markdown',license='MIT',python_requires='>=3.8',classifiers=['Programming Language :: Python :: 3','License :: OSI Approved :: MIT License']) \ No newline at end of file