grove docgen grove docgen
Grove Docgen Overview
grove-docgen is a command-line tool for generating documentation for software projects using Large Language Models (LLMs). It integrates with the Grove ecosystem to create documentation from source code and project structure.
Key Features
- Section-Based Architecture: Documentation is defined in a
docgen.config.ymlfile, organized into logical sections. Each section is configured with its own prompt, output file, and can override global settings like the LLM model. - Customizable Prompts: The
docgen initcommand creates adocs/prompts/directory containing starter prompt files. These markdown files can be modified to direct the LLM’s content generation. - Interactive Customization: The
docgen customizecommand creates agrove-flowplan, using AI agents or structured prompts to interactively customize and generate documentation. - Multi-Model Support: The tool leverages
grove llm, which allows the use of different LLM providers and models (e.g., Gemini, Claude, OpenAI) for different documentation sections. - Workspace-Aware Context: It uses
grove cxto analyze project files based on configurable rules. This context is provided to the LLM during generation. - README Synchronization: A
sync-readmecommand updates the project’s rootREADME.mdby injecting content from a specified documentation section into a template file. - Documentation Aggregation: The
aggregatecommand discovers all enabled packages in a workspace, copies their documentation into an output directory, and creates amanifest.jsonfile. - Schema Tools: Includes commands to generate JSON schemas from Go types (
schema generate) and enrich them with LLM-generated descriptions (schema enrich).
Ecosystem Integration
grove-docgen functions as a component within the Grove developer tool ecosystem.
- It uses
grove cxto build context from source code. - It uses
grove llmto send requests to language models. - It uses
grove-flowto create interactive documentation plans. - It recognizes the workspace structure defined in the ecosystem’s
grove.ymlfile. - Prompts can be stored and resolved from a central
grove-notebooklocation, with amigrate-promptscommand to assist in moving them.
This design allows docgen to operate with an understanding of the project and its related components.
How It Works
The documentation generation process consists of the following steps:
- Configuration Load:
docgenreads thedocs/docgen.config.ymlfile to determine which sections to generate. - Context Generation: It executes
grove cx generate, which reads project files according to patterns in a rules file and prepares context for the LLM. - Prompt Resolution: It locates and reads the specified prompt file for the section, checking first in the associated
grove-notebookand then falling back to the localdocs/prompts/directory. - LLM Invocation: It calls
grove llm request, sending the generated context and the prompt content to the configured language model. - Output Writing: The markdown response from the LLM is written to the section’s specified output file.
- JSON Regeneration (Optional): If configured, it parses the generated markdown files to create a structured JSON representation of the documentation.
Installation
Install via the Grove meta-CLI:
bash
grove install docgenVerify installation:
bash
docgen versionRequires the grove meta-CLI. See the Grove Installation Guide if you don’t have it installed.