This application generates documentation websites from any public GitHub repository URL.
- Input: GitHub repository URL, optional documentation framework (mkdocs, pydoc, sphinx, mkdocs-material), output folder name, and MongoDB Atlas connection details.
- Process: Fetches/clones the repository, analyzes the codebase (languages, modules, APIs, etc.), stores/retrieves analysis results from MongoDB Atlas, generates Markdown documentation files, and builds a complete documentation website using the selected framework.
- Output: A complete folder containing the generated documentation website, fully buildable with
mkdocs serveorsphinx-build -b html source build.
- Python 3.11+
- FastAPI (for API & web UI)
- Jinja2 (for template generation)
- GitPython (clone repos)
- PyGithub (read GitHub repos without cloning)
- MkDocs, MkDocs-Material (default doc framework)
- Sphinx (optional)
- Uvicorn (local dev server)
- Rich (for CLI feedback)
- Pydantic (for structured models)
- PyMongo (for MongoDB Atlas integration)
- Dnspython (for MongoDB Atlas SRV records)
-
Clone the repository:
git clone <repository_url> cd doc-generator
-
Install dependencies (make sure to use Python 3.12 or below if encountering issues with pydantic-core):
python3 -m pip install -e .
This application uses MongoDB Atlas to cache analysis results. You need to provide your MongoDB Atlas connection URI and database name.
You can set these as environment variables:
export MONGO_URI="mongodb+srv://<username>:<password>@<cluster-url>/<database-name>?retryWrites=true&w=majority"
export MONGO_DB_NAME="doc_generator_db"Or pass them as command-line arguments to the CLI tool.
To use the web interface, start the FastAPI server:
uvicorn app.main:app --reloadThen, open your web browser and navigate to http://127.0.0.1:8000. You will see a form to enter the GitHub repository URL and other details.
python -m cli.generate <github_repo_url> \
--framework mkdocs \
--mongo-uri "mongodb+srv://<username>:<password>@<cluster-url>/<database-name>?retryWrites=true&w=majority" \
--mongo-db-name "doc_generator_db"Example:
python -m cli.generate https://github.com/encode/uvicorn \
--framework mkdocs-material \
--output-folder-name uvicorn_docs \
--mongo-uri "$MONGO_URI" \
--mongo-db-name "$MONGO_DB_NAME"Start the FastAPI server:
uvicorn app.main:app --reloadThen, send a POST request to /generate with a JSON body:
{
"repo_url": "https://github.com/user/repo",
"framework": "mkdocs",
"mongo_uri": "mongodb+srv://<username>:<password>@<cluster-url>/<database-name>?retryWrites=true&w=majority",
"mongo_db_name": "doc_generator_db"
}This application can use OpenAI's models for deeper code analysis and summary generation. To enable this, you need an OpenAI API key.
You can set your OpenAI API key as an environment variable:
export OPENAI_API_KEY="your_openai_api_key_here"Or pass it as a command-line argument to the CLI tool or in the web UI.