This repository showcases the use of OpenAI's GPT-3.5 language model for generating documentation for code automatically. The generated documentation is then turned into a "doc as code" site for easy access and sharing.
To use this repository, you will need to have the following:
- A valid OpenAI API key for GPT-3.5 language model.
- A codebase that you want to generate documentation for.
- Clone or download this repository to your local machine.
- Set up your OpenAI API key by creating a
.env
file in the root directory and adding the following line, you can rename the example.env:
OPENAI_API_KEY=<your-api-key>
- Install the required dependencies, python, then once installed use the following command:
cd ./MKAutoDocs/
pip install -r requirements.txt
- Edit the configuration file to point to your code repository.
- docs_path: relative path to the desired doc folder (should match with mkdocs in config file).
- root_dir: absolute path or relative path to the desired project root directory.
- source_to_document:
- Absolute path or relative path to the folders you want parsed and documented in your root directory.
- requirements: A list of python dependencies to run your doc as code site.
- mkdocs: 1.4.2
- pymdown-extensions: 9.11
- ignore_folders: A list of regex of folders/subfolders to ignore. Remove any or all if you like.
- .+.git
- .pytest
- Include
- Lib
- Scripts
- ignore_files: A list of regex of files to ignore. Remove any or all if you like.
- .*
- ^(?!..py$).
- use_state: A boolean value, this will keep files from being regenerated on each run. Feel free to turn off if you want to update the docs.
- Run the following command to generate documentation for your code:
python Auto_Doc.py
This will use the GPT-3.5 language model to generate documentation for
your codebase and output the generated documentation as Markdown files
in the configured docs
directory.
- Run The static site generator MkDocs to turn the generated documentation into a "doc as code" site.
For example, to use MkDocs, run the following command in the root directory to preview the site:
mkdocs serve
Or use MkDocs, to build a site:
mkdocs build
This will generate a static website in the site
directory,
which you can host on a server or a service like GitHub Pages.
If you want to host on GitHub Pages. You can set up github actions to autodeploy your doc as code site mkdocs how to or deploy manually using:
mkdocs gh-deploy
If you want to contribute to this repository, please feel free to open a pull request or an issue. We welcome any feedback, suggestions, or improvements to the code.
This repository is licensed under the MIT License. See the
LICENSE
file for more information.