Default Output Directory for Litho Documentation: Configuration and Customization
Litho generates documentation in the ./litho.docs directory by default, as defined in the Config::default() implementation in src/config.rs.
When working with the sopaco/deepwiki-rs repository, understanding where Litho stores its generated files is essential for workflow integration. The default output directory for Litho documentation is hardcoded in the configuration layer, though it can be overridden through CLI arguments or configuration files.
Where Litho Stores Generated Documentation by Default
Litho writes all generated markdown documentation to a directory named litho.docs in the project root. This path is established through the Config::default() method, which initializes the output_path field with a PathBuf pointing to the relative path ./litho.docs.
When the DiskOutlet implementation executes, it reads this configuration value and creates (or clears) the directory before writing each file. If the directory already exists from a previous run, Litho clears its contents to ensure a clean documentation build.
How the Default Output Path is Implemented
The default output directory is defined across two primary components in the codebase: the configuration struct and the file system outlet.
Configuration Layer in src/config.rs
The default value originates in src/config.rs, specifically within the Default trait implementation for the Config struct. The code explicitly sets the output_path field:
output_path: PathBuf::from("./litho.docs")
This implementation ensures that any Config instance created without explicit field assignments will default to generating documentation in the litho.docs subdirectory.
File System Outlet in src/generator/outlet/mod.rs
The DiskOutlet struct in src/generator/outlet/mod.rs handles the actual file operations. This component reads the output_path from the configuration and manages the directory lifecycle:
// Creates or clears the output directory before writing
// Located in src/generator/outlet/mod.rs lines 76-83
The outlet ensures the directory exists and is empty before writing each markdown file, preventing stale documentation from previous runs.
Overriding the Default Output Directory
While ./litho.docs serves as the fallback, Litho provides multiple mechanisms to specify custom output locations.
Using the CLI Flag
The most direct method is using the --output-path flag when invoking Litho from the command line:
# Run with default output directory
litho run
# Specify custom output directory
litho run --output-path ./my-docs
This flag is parsed in src/cli.rs and merged with the default configuration, taking precedence over the hardcoded default.
Using the Configuration File
For persistent customization, create a litho.toml file in your project root. The example configuration in litho-example.toml demonstrates the output_path key:
# litho.toml
output_path = "./custom-documentation"
When present, this configuration file overrides the default values defined in src/config.rs.
Summary
- Default Location: Litho stores generated documentation in
./litho.docsrelative to the project root. - Source Definition: The default path is hardcoded in
src/config.rswithin theConfig::default()implementation asPathBuf::from("./litho.docs"). - File Operations: The
DiskOutletinsrc/generator/outlet/mod.rscreates and manages this directory during the generation process. - Customization: Override the default using the
--output-pathCLI flag or theoutput_pathkey inlitho.toml.
Frequently Asked Questions
What is the default output directory for Litho documentation?
The default output directory is ./litho.docs, a folder created in the project root when Litho runs. This value is defined in the Config::default() method in src/config.rs and is used whenever no custom output path is specified via CLI or configuration file.
How do I change where Litho saves generated files?
You can change the output location by either passing the --output-path flag when running Litho from the command line, or by setting the output_path key in a litho.toml configuration file. Both methods override the default ./litho.docs directory.
Does Litho create the output directory automatically?
Yes, the DiskOutlet implementation in src/generator/outlet/mod.rs automatically creates the output directory if it does not exist. If the directory already exists from a previous run, Litho clears its contents to ensure a clean build of the documentation.
Where is the default output path defined in the source code?
The default output path is defined in src/config.rs within the Default trait implementation for the Config struct. Specifically, the code sets output_path: PathBuf::from("./litho.docs"), which establishes the fallback location used when no custom path is provided.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →