Skip to content

CLI to generate API documentation in MarkDown based on the models and api handlers for a given project using ChatGPT.

License

Notifications You must be signed in to change notification settings

marco-rosner/genDocsGPT

Repository files navigation

genDocsGPT Python Versions Test workflow License: MIT

genDocsGPT

Generate Docs using ChatGPT

CLI to generate API documentation in MarkDown based on the models and api handlers for given project using ChatGPT.

genDocsGPT badge

genDocsGPT

ChatGPT API Key

The genDosGPT demand a ChatGPT API Key that you can generate after create your free account in OpenAI. Tutorial here. After this, create a .env file in the following format:

API_KEY="chatgpt_api_Key"

Usage

usage: genDocsGPT [-h] [-v, --verbose] -m / --model <model_paths> -a / --api <api_paths> 
[-o / --output <filename>] [-t / --token <token>] [--env <filename>] [--gpt_model <model>]

CLI to generate API documentation in MarkDown based on the models and api handlers for 
given project using ChatGPT.

options:
  -h, --help            show this help message and exit
  -v, --verbose         Show all the messages to debug
  -m / --model <model_paths>
                        Model paths. If more than one, separate with a comma
  -a / --api <api_paths>
                        API paths. If more than one, separate with a comma
  -o / --output <filename>
                        Filename to the documentation generated. Default: ./api.md
  -t / --token <token>  ChatGPT API KEY
  --env <filename>      Env file that MUST and ONLY have API_KEY="chatgpt_api_key". 
                        Default: ./.env
  --gpt_model <model>   Model that will be used by ChatGPT. Default: gpt-3.5-turbo

We do not recommend using it in non-open-source projects.

Standalone

genDocsGPT

The genDocsGPT.sh, the bash script above, should be used in projects where the documentation should be generated not frequently. You only need to copy this file, change the configuration (models, API handlers…), paste it into your project, create the .env file with the ChatGPT API Key, and run this bash script.

I am using this standalone version in the DadosJusBr’s GraphQL project which is a Node/ExpressJS using Apollo Server. So, I created a script in the package.json to run it only using: npm run genDocsGPT or yarn genDocsGPT

GitHub Action

genDocsGPT

This GitHub Action will run after every commit in the main/master branch and create a pull request that you only need to approve (or not) and the documentation will be updated.

For genDocsGPT.yml works fine in your project, you should set the model, API handlers paths, and other options (line 30), create, in the GitHub, the secret ChatGPT_API_KEY (tutorial here), and change the workflow permissions (tutorial here) to “Read and Write permissions” and use the “Allow GitHub Action to create and approve pull requests”.

genDocsGPT

For more detail, I integrated this GitHub Action in the Lightweight Go Server project, a Go servers benchmark between Echo, Gin, and Fiber.

About

CLI to generate API documentation in MarkDown based on the models and api handlers for a given project using ChatGPT.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published