Describe¶
Configuration documentation and description utilities.
describe ¶
Configuration description and documentation utilities.
Public API
- describe_single: Generate docs for a single config class
- describe_configs: Generate docs for multiple config classes
- generate_env_example: Convenience wrapper for .env.example generation
OutputFormat
module-attribute
¶
describe_single ¶
describe_single(
config_cls: type[DotEnvConfig],
output_format: OutputFormat = "table",
output: str | Path | None = None,
line_ending: str | None = None,
) -> str
Generate documentation for a single config class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_cls
|
type[DotEnvConfig]
|
The DotEnvConfig subclass to describe |
required |
output_format
|
OutputFormat
|
Output format - "table" (default), "markdown", "json", "html", or "dotenv" |
'table'
|
output
|
str | Path | None
|
Optional file path to save the output to |
None
|
line_ending
|
str | None
|
Line ending to use. If None, uses platform default (os.linesep) |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string describing the configuration |
Raises:
| Type | Description |
|---|---|
ValueError
|
If output_format is not recognized |
Example
Source code in dotenvmodel/describe/__init__.py
describe_configs ¶
describe_configs(
config_classes: list[type[DotEnvConfig]],
output_format: OutputFormat = "table",
output: str | Path | None = None,
line_ending: str | None = None,
) -> str
Generate documentation for multiple config classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_classes
|
list[type[DotEnvConfig]]
|
List of DotEnvConfig subclasses to describe |
required |
output_format
|
OutputFormat
|
Output format - "table", "markdown", "json", "html", or "dotenv" |
'table'
|
output
|
str | Path | None
|
Optional file path to save the output to |
None
|
line_ending
|
str | None
|
Line ending to use. If None, uses platform default |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string describing all configurations |
Example
Source code in dotenvmodel/describe/__init__.py
generate_env_example ¶
Generate a .env.example file for onboarding.
Convenience wrapper around describe_single with output_format="dotenv".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_cls
|
type[DotEnvConfig]
|
The DotEnvConfig subclass to generate example for |
required |
output
|
str | Path | None
|
Optional file path to save the .env.example to |
None
|
Returns:
| Type | Description |
|---|---|
str
|
.env.example file content as a string |