Most of the parts of this README file is generated by this project.
Auto-Readme is a tool designed to automate the process of generating README files for your projects. It scans through your codebase, summarizes important files, and gathers information about dependencies, offering a concise overview of the project.
The main functionality of Auto-Readme is encapsulated in the main.py
script. It performs the following tasks:
-
Summarize Code Files: The script walks through the project directory, identifies code files with specific extensions (
.py
,.js
,.java
,.cpp
,.md
), and generates a summary for each file. It skips theREADME.md
file to prevent redundancy.def summarize_code_files(): summaries = "" for root, _, files in os.walk('.'): for file in files: if file.endswith(('.py', '.js', '.java', '.cpp', '.md')) and file != 'README.md': file_path = os.path.join(root, file) summary = summarize_code(file_path) summaries += summary + "\n\n" return summaries
-
Get Dependencies: This function checks for the presence of a
requirements.txt
file for Python projects or apackage.json
file for Node.js projects, and extracts the list of dependencies.def get_dependencies(): dependencies = "" if os.path.exists('requirements.txt'): with open('requirements.txt', 'r') as file: dependencies = file.read() elif os.path.exists('package.json'): import json with open('package.json', 'r') as file: ...
To use Auto-Readme, follow these steps:
-
Clone the Repository:
git clone <repository-url> cd auto-readme
-
Install Required Python Packages:
Ensure you have openai installed in your environment.
pip install openai
Also make sure you have a OPENAI api key in your environment variables. For MacOS:
echo "export OPENAI_API_KEY='yourkey'" >> ~/.zshrc
source ~/.zshrc
-
Run the Main Script:
Execute the
main.py
script to generate summaries of your code files and extract dependencies:python main.py
-
View Generated Summaries:
The script will output summaries of code files and list the dependencies found in your project. You can use this information to draft your README.md file.
Auto-Readme simplifies the task of documenting projects, making it easier for developers to maintain clear and informative documentation. Whether you are starting from scratch or updating an existing project, Auto-Readme provides a helpful starting point for your README needs.