repo_guide
The repo_guide
directory contains the core logic for the repo-guide
tool. It includes the command-line interface definition and the documentation generation process.
The entry point for the application is the __main__.py
file. It imports the cli
function from the cli.py
module and executes it when the script is run directly.
The cli.py
file defines the command-line interface using the click
library. It defines options like --model
, --serve
, --output-dir
, and --ignore
to configure the documentation generation process. It also contains the DocGenerator
class, which handles the core logic of generating the documentation.
The DocGenerator
class is responsible for:
- Crawling the input directory.
- Filtering files based on ignore patterns and binary file detection.
- Constructing prompts for the LLM.
- Generating documentation using the LLM.
- Writing the generated documentation to the output directory.
- Creating a basic
mkdocs.yml
configuration file.
The _build_prompt
method is particularly important. It takes a directory and a list of files, and it constructs an XML prompt that is sent to the LLM. The prompt includes the relative path of the current directory, a list of subdirectories with links to their generated README files, and a list of files with their contents. The LLM uses this information to generate a description of the directory.
The cli
function in cli.py
orchestrates the entire process. It parses the command-line arguments, initializes the DocGenerator
, generates the documentation, and optionally starts a local documentation server using mkdocs
. It also handles building and deploying the static site to GitHub Pages.