docAider
leverages Semantic Kernel and Autogen to automate the process of generating and reviewing code documentation for your repository through a multi-agent approach. Additionally, with its integrated workflows, docAider
streamlines the documentation update process, ensuring it is both efficient and user-friendly.
Add the following Dockerfile
to your repository:
version: "3.8"
services:
docAider:
image: zenawang/docaider:v1
container_name: docAider
volumes:
- .:/workspace
working_dir: /workspace
env_file:
- .env
Create a .env
file in your repository with the following variables:
GLOBAL_LLM_SERVICE="AzureOpenAI"
CHAT_DEPLOYMENT_NAME="GPT-4"
AZURE_OPENAI_API_KEY="YOUR_AZURE_OPENAI_API_KEY"
AZURE_OPENAI_ENDPOINT="YOUR_AZURE_OPENAI_ENDPOINT"
AZURE_OPENAI_API_VERSION="2023-03-15-preview"
API_TYPE="azure"
BASE_URL="YOUR_BASE_URL"
GITHUB_ACCESS_TOKEN="YOUR_GITHUB_ACCESS_TOKEN"
ROOT_FOLDER="/workspace"
To activate the docAider
Docker image and ensure it continues running (do not terminate it), use the following command:
docker compose up --build
This command will build and start the docAider
container. It will keep running in the foreground, so you can interact with it as needed.
To generate documentation for your repository, run the following command. This process is typically done once to create initial documentation:
docker exec docAider python3 /docAider/repo_documentation/multi_agent_app.py
During execution, you can observe the interaction between multiple agents in the terminal output. The CodeContextAgent
provides explanations for code contexts, the documentation_generation_agent
generates documentation for specified code files, and the review_agent
reviews and enhances the generated documentation. The agent_manager
orchestrates the interactions between these agents, ensuring a seamless workflow from context explanation to documentation generation and review.
The generated documentation can be found in the docs_output
folder. The prompt_debug
folder contains the prompts for each source code file, which are fed to the agents.
Additionally, the call_graph.json,
cache.json
, and graph.png
files are generated by the code2flow project. These files help in:
- Untangling spaghetti code
- Identifying orphaned functions
- Getting new developers up to speed
To set up workflows (update-docs.yml and update-comments.yml) for automatic documentation updates, run:
docker exec docAider python3 /docAider/setup_workflows.py
Note: Remember to manually push the generated documentation and workflows to the repository, preferably to the main branch.
Create an environment named "GPT" and add the variables from the .env file as secrets (excluding GITHUB_ACCESS_TOKEN and ROOT_FOLDER). This can be done in your repository settings under Settings > Security > Secrets and Variables > Actions.
This workflow triggers when a pull request is opened against the main branch and updates the documentation based on the changes between the pull request branch and the main branch.
Use this workflow to modify the documentation further if the initial update is not satisfactory. You can request changes by commenting in the following format:
Documentation {file_path}: {comment}
file_path
: Path to the source code file for which you want to update the documentation.
comment
: Prompt or instructions to guide the agent in updating the documentation.
This project includes features and improvements from a custom fork of the code2flow project licensed under the MIT license. The code2flow project generate call graphs for dynamic programming languages and can be found here. This fork is tailored to support Python only.