Introduction to doc-comments-ai
doc-comments-ai is an innovative project designed to revolutionize how developers handle code documentation. The traditional process of writing detailed documentation can be labor-intensive and time-consuming. doc-comments-ai leverages the power of large language models (LLMs) to automatically generate documentation, allowing developers to focus more on coding. This capability is perfect for those who want their code commented efficiently without worrying about data leaks, as it supports both cloud-based OpenAI models and 100% local LLM solutions.
Built leveraging powerful tools such as langchain, treesitter, lama.cpp and ollama, this project is a robust solution for modern development needs.
Features
Documentation Generation
doc-comments-ai can generate comprehensive documentation comment blocks for all methods in a file. It supports various documentation standards such as Javadoc, JSDoc, Docstring, Rustdoc, etc. Additionally, inline documentation comments can be generated within the method bodies, providing context right where it's needed.
Integration and Support
This tool includes the integration of Treesitter and offers support for local LLMs, making the tool versatile and flexible whether the infrastructure is simple or complex. Additionally, doc-comments-ai supports Azure OpenAI, expanding its reach and capabilities.
Model Options
For documentation generation, users can choose between different models, including GPT-3.5-Turbo, GPT-4, and more specific configurations like GPT-3.5-Turbo-16k for larger, more detailed documentation needs. Users can also opt for local models, offering both the convenience and assurance of processing data locally.
Usage
To utilize doc-comments-ai for automatic documentation:
- Run
aicomment <RELATIVE_FILE_PATH>
to generate documentation for a specified file. - Use
--inline
to generate inline comments within methods. - The
--guided
option allows users to confirm each piece of documentation before it's generated. - To engage different models, commands such as
--gpt4
for GPT-4 or--local_model <MODEL_PATH>
for local Llama.cpp models are available.
Supported Languages
This project is versatile, supporting a wide array of programming languages including:
- Python
- Typescript
- Javascript
- Java
- Rust
- Kotlin
- Go
- C++
- C
- C#
- Haskell
Installation
To get started with doc-comments-ai, installation via pipx
is recommended for isolated environments:
pipx install doc-comments-ai
Alternatively, it can be installed directly using:
pip install doc-comments-ai
OpenAI and Azure Setup
Doc-comments-ai requires setup of OpenAI or Azure API keys in the user's environment to authenticate and enable documentation generation through cloud-based LLMs.
Local LLM Usage
For a completely local setup, no API keys are required. The system provides step-by-step instructions on downloading models from huggingface for local use. This ensures complete control over data and processing.
Troubleshooting and Contribution
In case of installation issues, particularly related to building tiktoken
, ensure that the Rust compiler is correctly installed. The doc-comments-ai community encourages contributions, inviting users to submit issues or improvements to enhance functionality.
By integrating such sophisticated automation, doc-comments-ai represents a significant step forward in easing the documentation burden, thus boosting productivity and allowing developers to direct their focus back to what they do best—coding.