Overview
The configuration manager handles loading and merging settings from multiple sources with a well-defined precedence order. It supports TOML configuration files, environment variables, and.env files.
Source: docugen/utils/config_manager.py
RuntimeConfig
Fields
Gemini API key for authentication. Must be set via environment variable or
.env file.Gemini model identifier (e.g.,
"gemini-2.0-flash-exp"). Falls back to DEFAULT_MODEL if not specified.Output file path for generated documentation. Defaults to
"README.md".Example
load_runtime_config()
Parameters
Model name from CLI argument (
--model). Takes highest precedence if provided.Output path from CLI argument (
--output). Takes highest precedence if provided.Explicit path to TOML config file. If provided, only this file is checked (skips automatic discovery).
Returns
Fully resolved configuration with all settings merged according to precedence rules.
Configuration Precedence
Settings are loaded in order from lowest to highest priority:- Default values - Hardcoded fallbacks (
DEFAULT_MODEL,"README.md") - TOML config files - Searched in order:
~/.docugen.toml~/.config/docugen/config.toml./.docugen.toml(current directory)$DOCUGEN_CONFIGenvironment variable path- Explicit
config_pathparameter
- Environment variables & .env files - For API key only:
.envin project root.envin current directory$DOCUGEN_DOTENVenvironment variable path$GEMINI_API_KEYenvironment variable
- CLI arguments - Highest priority (overrides all other sources)
Example
TOML Configuration Format
Basic Format
Nested Format (with [docugen] section)
[docugen] section override top-level settings.
Environment Variables
API Key Resolution
Gemini API key. Checked in environment first, then in
.env files.Configuration Paths
Path to custom TOML config file. Overrides automatic discovery.
Path to custom
.env file. If not set, searches current directory and project root.Example .env File
Configuration Discovery
TOML Config Search Order
config_pathparameter (if provided) - stops searching if found$DOCUGEN_CONFIGenvironment variable./.docugen.toml(current directory)~/.config/docugen/config.toml~/.docugen.toml(home directory)
.env File Search Order
$DOCUGEN_DOTENVenvironment variable./.env(current directory)<project-root>/.env
GEMINI_API_KEY is used; searching stops after first match.
Related
- CLI Reference - Command-line interface using this config
- Gemini Client - Uses
api_keyandmodelsettings - Template Engine - Uses
outputsetting
