Auto Document Codebase Changes in LaTeX, Markdown, or Word
Project description
Adhoc: Auto-Documenting Codebase Changes
Adhoc is a command-line tool designed to automatically document changes in your codebase. By integrating with local language models, it generates detailed explanations of code modifications and compiles them into professional documentation formats such as LaTeX, Markdown, or Word. This tool streamlines the documentation process, making it effortless for developers to maintain up-to-date records of their code evolution.
Table of Contents
Features
- Automatic Documentation: Generates explanations for code changes using a Language Learning Model (LLM).
- Multiple Output Formats: Supports documentation in LaTeX, Markdown, and Word formats.
- Version Control Integration: Detects code changes and commits through simple commands.
- Configurable Settings: Allowr:
- Consistent Naming Conventions: The function names and variable names should follow con- sistent naming conventions. For example, in ‘classify eeg files‘, all variables start with lowercase letters except for the function name which starts with uppercase. Consider making the function name start with lowercase to match the variable naming convention. 2. Constant Values: There are a few constant values like ‘image size‘ and ‘noise threshold‘ that could be defined as named constants. This makes the code more readable and maintainable. 3. Comments: While there is some commenting in the code, adding more comments will make it easier for other developers to understand your thought process and any potential issues. 4. Error Handling: The code assumes that all files can be processed correctly. Adding some error handling mechanisms will ensure robustness against unexpected input or exceptions.
- Type Hints: Although the function parameters in ‘classify spectra images‘ and ‘classify eeg files‘ have type hints, the return types are not specified. Adding return types where applicable can make the code more self-explanatory. 6. Function Signatures: The functions have generic names that may not be descriptive enough to understand their purpose from the function signature alone. Consider renaming them to something more descriptive. 7. Global Variables: Although not necessary in this case, avoid using global variables if possible. They can sometimes lead to confusion and harder-to-debug code. 8. Code Organization: The ‘compute eeg spectra‘ function is called from within the loop where images are being processed. Consider moving it outside of the loop for better code organization. 9. Optimize I/O Operations: There are multiple file operations like reading and writing files in a loop. Consider using efficient methods to read/write files, such as using ‘with open‘ context manager or batching multiple file operations together. 10. Documentation: Adding documentation for the functions can be helpful for other developers who may not be familiar with the codebase. This can include descriptions of the function parameters and return values where applicable. 3s customization of output formats and author information via a configuration file.
- Extensible Design: Modular structure makes it easy to extend functionalities.
Installation
To install Adhoc, you can use pip:
pip install adhoc-python
Ensure you have the necessary dependencies listed in the requirements.txt file.
Usage
Adhoc provides a set of commands to initialize your project, commit changes, generate documentation, and configure settings. Below is an explanation of each command and how to use it.
Initialization
Before using Adhoc, you need to initialize your project:
adhoc init --model "your ollama model"
What it does:
- Creates a
.Adhocdirectory in your project root to store configurations and databases. - Initializes a SQLite database to track code changes.
- Initializes the whole code to work with your choice of LLM and then generates a codebase summary for context.
Committing Changes
After making changes to your codebase, use the following command to commit those changes and generate explanations:
adhoc commit -m "Your commit message"
Options:
-m, --message: (Optional) A commit message describing the changes.
What it does:
- Detects changes since the last commit by comparing snapshots.
- Generates explanations for the changes using the LLM, incorporating your commit message if provided.
- Stores the changes and explanations in the database for future reference.
Generating Documentation
To create documentation of your codebase and its changes, run:
adhoc generate
What it does:
- Retrieves the codebase summary and change explanations from the database.
- Generates a documentation file in the format specified in your configuration (latex, markdown, or word).
- The output file (
documentation.tex,documentation.md, ordocumentation.docx) is created in your project directory.
Configuration
Customize Adhoc settings using the adhoc config command:
adhoc config -d md -u "Your Name"
Options:
-d, --document-format: Sets the output document format. Acceptsmdfor Markdown,texfor LaTeX, orwordfor Word documents.-u, --username: Sets the author name to be used in the documentation.
What it does:
- Updates the configuration file (
config.jsonin the.Adhocdirectory) with your preferences. - The changes affect how documentation is generated and personalized.
Example:
adhoc config -d word -u "Shreyas"
- Sets the output format to Word.
- Sets the author name to "Shreyas".
Requirements
- Python 3.6 or higher
Dependencies:
jinja2requestswatchdogpython-docx(for Word document generation)
Additional dependencies are listed in requirements.txt.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.
A Reflective Note
"Life is an ad hoc affair. It has to be improvised all the time because of the hard fact that everything we do changes what is. This is distressing to people who would like to see things beautifully planned out and settled once and for all. That cannot be."
― Jane Jacobs
Happy coding!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adhoc_python-1.0.1.tar.gz.
File metadata
- Download URL: adhoc_python-1.0.1.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f32ec28ad25c323abe2bd5267d96690ef2d78335a90be3a4a4b8f9a53c0ad754
|
|
| MD5 |
092161d57e77d994865dbaf6a3daabec
|
|
| BLAKE2b-256 |
fc1087c21b53bde62dde98131d6184ff6f37c2d5c87c35fe1d7178e614c192e9
|
File details
Details for the file adhoc_python-1.0.1-py3-none-any.whl.
File metadata
- Download URL: adhoc_python-1.0.1-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15f7218fb826ebb6affb99fe9758071495c707381a995eb6a14e9f8312acedb4
|
|
| MD5 |
c3af08fe1ca6d3bd84719a3a3bbb8e17
|
|
| BLAKE2b-256 |
42cf7d070beedcc2803a27df33f4dbd3d1815c7733f041bd7195e29985bbce60
|