AutoDoc-ChatGPT Overview
AutoDoc-ChatGPT is an innovative Python script designed to streamline the process of creating documentation for programming code. By harnessing the capabilities of the ChatGPT model, this tool aids developers in generating detailed and comprehensible documentation across various programming languages.
Purpose and Functionality
At its core, AutoDoc-ChatGPT is engineered to automatically produce documentation for software code. The user simply needs to supply the path to the coding file they want documented. Once executed, the script analyzes the code and produces a natural language description that includes details about functionality, parameters, and return values. This automation simplifies the arduous task of manually writing documentation, especially for large codebases.
How to Get Started
Installation Steps
To begin using AutoDoc-ChatGPT, you must first clone the repository to your local machine:
git clone https://github.com/awekrx/AutoDoc-ChatGPT.git
After cloning, it's important to install the necessary packages by running:
pip install -r requirements.txt
Following these steps ensures your environment is ready to utilize the script efficiently.
Supported Programming Languages
AutoDoc-ChatGPT accommodates various programming languages, enhancing its utility across different development projects. Currently supported languages include:
- Python
- JavaScript (with some present bugs and under testing)
- TypeScript (also under testing)
There are potential plans to extend support to additional languages such as Go, C#, C++, PHP, Ruby, Rust, Java, and Kotlin, among others. Developers should note that TypeScript and JavaScript may exhibit some issues, particularly when dealing with files that include multiple classes with methods having identical names.
Usage Instructions
Configuration
Prior to running the script, users must update the config.ini
file. By adding either an email and password or obtaining a session token from ChatGPT, one can set up the necessary authorization credentials. The session token is an alternative method to bypass using email and password directly.
Starting the Script
To generate documentation, execute the following command:
py main.py -file "path to the file"
The path can be in either relative or absolute terms, offering flexibility in file selection. Post execution, a new file named yourfilename_commented.language
will be created, containing the annotated documentation.
Alternative Use
Besides direct operation, AutoDoc-ChatGPT can also be utilized as a function within a Python script. This allows for a more programmable approach, integrating documentation generation into existing workflows.
Here’s a brief example of using AutoDoc-ChatGPT as a Python function:
from modules.autodoc import AutoDoc
import configparser
config = configparser.ConfigParser()
config.read("config.ini")
auth = {
"email": config["ChatGPT"]["email"],
"password": config["ChatGPT"]["password"],
"session_token": config["ChatGPT"]["session_token"]
}
result = AutoDoc(
auth,
"Code for commenting",
"language code",
"example comment model (optional)"
).start()
print(result)
# out: Code with comments
Considerations
While AutoDoc-ChatGPT is a powerful tool, it does not guarantee error-free comments. The comments generated should be viewed as a draft and may require subsequent editing to fully capture the developer's intent or the nuances of the code.
License and Acknowledgments
AutoDoc-ChatGPT is open-source software, licensed under the MIT License, ensuring it is freely available for use and modification. The project gratefully acknowledges СhatGPT for its foundational model and acheong08 for their significant contributions to the development of ChatGPT resources.