Spaces:
Sleeping
Sleeping
Commit ·
5cd89db
1
Parent(s): 20f2724
deleted workflows
Browse files- .github/workflows/generate_docs_action.py +0 -136
- .github/workflows/update-docs.yml +0 -53
- README.md +7 -7
- backend/doc_generator.py +4 -4
- backend/main.py +1 -1
- fah.webp +0 -0
.github/workflows/generate_docs_action.py
DELETED
|
@@ -1,136 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
-
GitHub Actions script to call DocWizard API and generate documentation.
|
| 4 |
-
Checks OpenRouter rate limits and skips if approaching daily limit.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
import os
|
| 8 |
-
import json
|
| 9 |
-
import sys
|
| 10 |
-
import time
|
| 11 |
-
from pathlib import Path
|
| 12 |
-
import requests
|
| 13 |
-
|
| 14 |
-
# Environment variables
|
| 15 |
-
OPENROUTER_API_KEY = os.getenv('OPENROUTER_API_KEY')
|
| 16 |
-
DOCWIZARD_API_URL = os.getenv('DOCWIZARD_API_URL')
|
| 17 |
-
GITHUB_REPOSITORY = os.getenv('GITHUB_REPOSITORY')
|
| 18 |
-
GITHUB_SERVER_URL = os.getenv('GITHUB_SERVER_URL', 'https://github.com')
|
| 19 |
-
|
| 20 |
-
# Validate required vars
|
| 21 |
-
if not OPENROUTER_API_KEY:
|
| 22 |
-
print("❌ Error: OPENROUTER_API_KEY secret not set")
|
| 23 |
-
sys.exit(1)
|
| 24 |
-
|
| 25 |
-
if not DOCWIZARD_API_URL:
|
| 26 |
-
print("❌ Error: DOCWIZARD_API_URL secret not set")
|
| 27 |
-
sys.exit(1)
|
| 28 |
-
|
| 29 |
-
repo_url = f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}"
|
| 30 |
-
print(f"🔍 Generating docs for: {repo_url}")
|
| 31 |
-
|
| 32 |
-
# Step 1: Check rate limits before proceeding
|
| 33 |
-
print("\n📊 Checking OpenRouter API rate limits...")
|
| 34 |
-
headers = {
|
| 35 |
-
'Authorization': f'Bearer {OPENROUTER_API_KEY}',
|
| 36 |
-
'HTTP-Referer': 'https://github.com/actions',
|
| 37 |
-
'X-Title': 'DocWizard-GitHubAction'
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
# Make a minimal request to check headers
|
| 41 |
-
try:
|
| 42 |
-
check_response = requests.post(
|
| 43 |
-
f"{DOCWIZARD_API_URL}/health",
|
| 44 |
-
headers=headers,
|
| 45 |
-
timeout=10
|
| 46 |
-
)
|
| 47 |
-
except Exception as e:
|
| 48 |
-
print(f"⚠️ Could not reach DocWizard API: {e}")
|
| 49 |
-
print("Skipping documentation generation")
|
| 50 |
-
sys.exit(0)
|
| 51 |
-
|
| 52 |
-
# Check rate limit headers from OpenRouter
|
| 53 |
-
remaining = check_response.headers.get('x-ratelimit-remaining-requests')
|
| 54 |
-
if remaining:
|
| 55 |
-
try:
|
| 56 |
-
remaining = int(remaining)
|
| 57 |
-
print(f"✓ Rate limit remaining: {remaining} requests")
|
| 58 |
-
|
| 59 |
-
if remaining < 10:
|
| 60 |
-
print(f"⚠️ Rate limit warning: Only {remaining} requests remaining today!")
|
| 61 |
-
print("Skipping documentation generation to preserve rate limit")
|
| 62 |
-
sys.exit(1) # Exit with error to trigger the notification step
|
| 63 |
-
except ValueError:
|
| 64 |
-
pass
|
| 65 |
-
|
| 66 |
-
# Step 2: Call generate-docs endpoint
|
| 67 |
-
print(f"\n🚀 Calling {DOCWIZARD_API_URL}/generate-docs...")
|
| 68 |
-
try:
|
| 69 |
-
response = requests.post(
|
| 70 |
-
f"{DOCWIZARD_API_URL}/generate-docs",
|
| 71 |
-
json={"repo_url": repo_url},
|
| 72 |
-
headers=headers,
|
| 73 |
-
timeout=600,
|
| 74 |
-
stream=True
|
| 75 |
-
)
|
| 76 |
-
except Exception as e:
|
| 77 |
-
print(f"❌ API request failed: {e}")
|
| 78 |
-
sys.exit(1)
|
| 79 |
-
|
| 80 |
-
if response.status_code != 200:
|
| 81 |
-
print(f"❌ API returned status {response.status_code}")
|
| 82 |
-
error_data = response.text[:200]
|
| 83 |
-
print(f"Response: {error_data}")
|
| 84 |
-
sys.exit(1)
|
| 85 |
-
|
| 86 |
-
# Step 3: Process streaming response and build documentation
|
| 87 |
-
print("\n📝 Processing documentation stream...")
|
| 88 |
-
docs_folder = Path("docs")
|
| 89 |
-
docs_folder.mkdir(exist_ok=True)
|
| 90 |
-
|
| 91 |
-
api_ref_path = docs_folder / "API_REFERENCE.md"
|
| 92 |
-
file_count = 0
|
| 93 |
-
|
| 94 |
-
with open(api_ref_path, 'w') as f:
|
| 95 |
-
f.write("# API Reference\n\n")
|
| 96 |
-
f.write(f"Auto-generated by DocWizard for: {repo_url}\n")
|
| 97 |
-
f.write(f"Generated at: {time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime())}\n\n")
|
| 98 |
-
f.write("---\n\n")
|
| 99 |
-
|
| 100 |
-
try:
|
| 101 |
-
for line in response.iter_lines():
|
| 102 |
-
if not line:
|
| 103 |
-
continue
|
| 104 |
-
|
| 105 |
-
try:
|
| 106 |
-
data = json.loads(line)
|
| 107 |
-
|
| 108 |
-
if data.get('status') == 'file_processed':
|
| 109 |
-
file_info = data.get('file', {})
|
| 110 |
-
filename = file_info.get('filename')
|
| 111 |
-
doc = file_info.get('documentation')
|
| 112 |
-
|
| 113 |
-
if doc:
|
| 114 |
-
f.write(f"## 📄 {filename}\n\n")
|
| 115 |
-
f.write(doc)
|
| 116 |
-
f.write("\n\n---\n\n")
|
| 117 |
-
file_count += 1
|
| 118 |
-
print(f" ✓ Processed {filename}")
|
| 119 |
-
|
| 120 |
-
elif data.get('status') == 'rate_limit':
|
| 121 |
-
print(f" ⚠️ {data.get('message')}")
|
| 122 |
-
|
| 123 |
-
elif data.get('status') == 'error':
|
| 124 |
-
print(f" ❌ Error: {data.get('message')}")
|
| 125 |
-
sys.exit(1)
|
| 126 |
-
|
| 127 |
-
except json.JSONDecodeError:
|
| 128 |
-
continue
|
| 129 |
-
|
| 130 |
-
except requests.exceptions.RequestException as e:
|
| 131 |
-
print(f"❌ Stream error: {e}")
|
| 132 |
-
sys.exit(1)
|
| 133 |
-
|
| 134 |
-
print(f"\n✅ Documentation generated successfully!")
|
| 135 |
-
print(f"📁 Saved to: {api_ref_path}")
|
| 136 |
-
print(f"📊 Total files processed: {file_count}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.github/workflows/update-docs.yml
DELETED
|
@@ -1,53 +0,0 @@
|
|
| 1 |
-
name: Update Documentation
|
| 2 |
-
|
| 3 |
-
on:
|
| 4 |
-
push:
|
| 5 |
-
branches:
|
| 6 |
-
- main
|
| 7 |
-
|
| 8 |
-
jobs:
|
| 9 |
-
update-docs:
|
| 10 |
-
runs-on: ubuntu-latest
|
| 11 |
-
steps:
|
| 12 |
-
- uses: actions/checkout@v3
|
| 13 |
-
with:
|
| 14 |
-
fetch-depth: 0
|
| 15 |
-
|
| 16 |
-
- name: Set up Python
|
| 17 |
-
uses: actions/setup-python@v4
|
| 18 |
-
with:
|
| 19 |
-
python-version: '3.11'
|
| 20 |
-
|
| 21 |
-
- name: Install dependencies
|
| 22 |
-
run: |
|
| 23 |
-
pip install -r requirements.txt
|
| 24 |
-
pip install requests
|
| 25 |
-
|
| 26 |
-
- name: Generate and update API reference
|
| 27 |
-
env:
|
| 28 |
-
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
| 29 |
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 30 |
-
DOCWIZARD_API_URL: ${{ secrets.DOCWIZARD_API_URL }}
|
| 31 |
-
run: |
|
| 32 |
-
python .github/workflows/generate_docs_action.py
|
| 33 |
-
|
| 34 |
-
- name: Commit and push changes
|
| 35 |
-
if: success()
|
| 36 |
-
run: |
|
| 37 |
-
git config --local user.email "action@github.com"
|
| 38 |
-
git config --local user.name "GitHub Actions Bot"
|
| 39 |
-
git add docs/API_REFERENCE.md
|
| 40 |
-
git commit -m "docs: update API reference [skip ci]" || echo "No changes to commit"
|
| 41 |
-
git push
|
| 42 |
-
|
| 43 |
-
- name: Report rate limit issue
|
| 44 |
-
if: failure()
|
| 45 |
-
uses: actions/github-script@v6
|
| 46 |
-
with:
|
| 47 |
-
script: |
|
| 48 |
-
github.rest.issues.createComment({
|
| 49 |
-
issue_number: context.issue.number,
|
| 50 |
-
owner: context.repo.owner,
|
| 51 |
-
repo: context.repo.repo,
|
| 52 |
-
body: '⚠️ **DocWizard Rate Limit**: OpenRouter API rate limit is near threshold. Documentation generation skipped. Please try again tomorrow.'
|
| 53 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
> AI-powered code documentation and search agent — paste a GitHub URL, get professional docs in seconds.
|
| 4 |
|
|
@@ -6,7 +6,7 @@
|
|
| 6 |
|
| 7 |
## What It Does
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
**Core features:**
|
| 12 |
- Generates documentation for every file in a repo with one click
|
|
@@ -37,7 +37,7 @@ DocWizard takes any public GitHub repository, reads every Python file, and autom
|
|
| 37 |
## Project Structure
|
| 38 |
|
| 39 |
```
|
| 40 |
-
|
| 41 |
├── backend/
|
| 42 |
│ ├── main.py # FastAPI app, all API endpoints
|
| 43 |
│ ├── doc_generator.py # OpenRouter API calls, doc generation logic
|
|
@@ -73,8 +73,8 @@ Make sure these are installed on your machine before starting:
|
|
| 73 |
### 1. Clone the repository
|
| 74 |
|
| 75 |
```bash
|
| 76 |
-
git clone https://github.com/yourusername/
|
| 77 |
-
cd
|
| 78 |
```
|
| 79 |
|
| 80 |
### 2. Get your API keys
|
|
@@ -190,10 +190,10 @@ curl -X POST http://localhost:8000/generate-docs \
|
|
| 190 |
|
| 191 |
## Known Limitations
|
| 192 |
|
| 193 |
-
- **Free tier rate limits:** OpenRouter free tier allows 50 requests/day and 20 requests/minute.
|
| 194 |
- **Python only:** The AST parser currently supports Python files only. JavaScript and other languages are planned for a future update.
|
| 195 |
- **Public repos only:** Private repositories require additional GitHub token scopes.
|
| 196 |
-
- **Context window:** Very large repos (100+ files) may exceed the model's context window.
|
| 197 |
|
| 198 |
---
|
| 199 |
|
|
|
|
| 1 |
+
# RepoAnalyzer 🧙♂️
|
| 2 |
|
| 3 |
> AI-powered code documentation and search agent — paste a GitHub URL, get professional docs in seconds.
|
| 4 |
|
|
|
|
| 6 |
|
| 7 |
## What It Does
|
| 8 |
|
| 9 |
+
RepoAnalyzer takes any public GitHub repository, reads every Python file, and automatically generates clean human-readable documentation using AI. It also lets developers search the codebase in plain English — no more digging through files manually.
|
| 10 |
|
| 11 |
**Core features:**
|
| 12 |
- Generates documentation for every file in a repo with one click
|
|
|
|
| 37 |
## Project Structure
|
| 38 |
|
| 39 |
```
|
| 40 |
+
RepoAnalyzer/
|
| 41 |
├── backend/
|
| 42 |
│ ├── main.py # FastAPI app, all API endpoints
|
| 43 |
│ ├── doc_generator.py # OpenRouter API calls, doc generation logic
|
|
|
|
| 73 |
### 1. Clone the repository
|
| 74 |
|
| 75 |
```bash
|
| 76 |
+
git clone https://github.com/yourusername/repoanalyzer.git
|
| 77 |
+
cd repoanalyzer
|
| 78 |
```
|
| 79 |
|
| 80 |
### 2. Get your API keys
|
|
|
|
| 190 |
|
| 191 |
## Known Limitations
|
| 192 |
|
| 193 |
+
- **Free tier rate limits:** OpenRouter free tier allows 50 requests/day and 20 requests/minute. RepoAnalyzer batches all files into one request to stay within this limit.
|
| 194 |
- **Python only:** The AST parser currently supports Python files only. JavaScript and other languages are planned for a future update.
|
| 195 |
- **Public repos only:** Private repositories require additional GitHub token scopes.
|
| 196 |
+
- **Context window:** Very large repos (100+ files) may exceed the model's context window. RepoAnalyzer will document as many files as fit.
|
| 197 |
|
| 198 |
---
|
| 199 |
|
backend/doc_generator.py
CHANGED
|
@@ -136,7 +136,7 @@ Now write comprehensive documentation for each file following the structure abov
|
|
| 136 |
timeout=30,
|
| 137 |
extra_headers={
|
| 138 |
'HTTP-Referer': 'http://localhost:3000',
|
| 139 |
-
'X-Title': '
|
| 140 |
}
|
| 141 |
)
|
| 142 |
|
|
@@ -285,7 +285,7 @@ Format the output as proper Markdown. Make it professional and ready for GitHub.
|
|
| 285 |
timeout=30,
|
| 286 |
extra_headers={
|
| 287 |
'HTTP-Referer': 'http://localhost:3000',
|
| 288 |
-
'X-Title': '
|
| 289 |
}
|
| 290 |
)
|
| 291 |
|
|
@@ -382,7 +382,7 @@ Return ONLY the .gitignore content, no explanations."""
|
|
| 382 |
timeout=30,
|
| 383 |
extra_headers={
|
| 384 |
'HTTP-Referer': 'http://localhost:3000',
|
| 385 |
-
'X-Title': '
|
| 386 |
}
|
| 387 |
)
|
| 388 |
|
|
@@ -421,7 +421,7 @@ Return ONLY the .gitignore content, no explanations."""
|
|
| 421 |
"Authorization": f"Bearer {api_key}",
|
| 422 |
"Content-Type": "application/json",
|
| 423 |
"HTTP-Referer": "http://localhost:3000",
|
| 424 |
-
"X-Title": "
|
| 425 |
},
|
| 426 |
json={
|
| 427 |
"model": MODEL,
|
|
|
|
| 136 |
timeout=30,
|
| 137 |
extra_headers={
|
| 138 |
'HTTP-Referer': 'http://localhost:3000',
|
| 139 |
+
'X-Title': 'RepoAnalyzer'
|
| 140 |
}
|
| 141 |
)
|
| 142 |
|
|
|
|
| 285 |
timeout=30,
|
| 286 |
extra_headers={
|
| 287 |
'HTTP-Referer': 'http://localhost:3000',
|
| 288 |
+
'X-Title': 'RepoAnalyzer'
|
| 289 |
}
|
| 290 |
)
|
| 291 |
|
|
|
|
| 382 |
timeout=30,
|
| 383 |
extra_headers={
|
| 384 |
'HTTP-Referer': 'http://localhost:3000',
|
| 385 |
+
'X-Title': 'RepoAnalyzer'
|
| 386 |
}
|
| 387 |
)
|
| 388 |
|
|
|
|
| 421 |
"Authorization": f"Bearer {api_key}",
|
| 422 |
"Content-Type": "application/json",
|
| 423 |
"HTTP-Referer": "http://localhost:3000",
|
| 424 |
+
"X-Title": "RepoAnalyzer-Test"
|
| 425 |
},
|
| 426 |
json={
|
| 427 |
"model": MODEL,
|
backend/main.py
CHANGED
|
@@ -14,7 +14,7 @@ from vector_store import store_docs, search_docs, update_docs
|
|
| 14 |
from dotenv import load_dotenv
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
-
app = FastAPI(title="
|
| 18 |
|
| 19 |
# Add CORS middleware for React frontend
|
| 20 |
app.add_middleware(
|
|
|
|
| 14 |
from dotenv import load_dotenv
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
+
app = FastAPI(title="RepoAnalyzer")
|
| 18 |
|
| 19 |
# Add CORS middleware for React frontend
|
| 20 |
app.add_middleware(
|
fah.webp
DELETED
|
Binary file (23.2 kB)
|
|
|