8000 Generators · jag-k/pydantic-settings-export Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Generators

Jag_k edited this page Feb 18, 2025 · 1 revision

Generators

This document describes all available generators and their configuration options in pydantic-settings-export.

Overview

Generators are the core components responsible for creating documentation from your Pydantic settings. Each generator:

  • Has 8000 a unique name and purpose
  • Implements specific formatting rules
  • Handles nested settings gracefully
  • Supports custom configuration
  • Produces consistent output

The generator system is extensible, allowing you to create custom generators for your specific needs.

Available Generators

Markdown Generator

The Markdown generator creates formatted documentation with tables and sections.

Keyword: markdown
Class: MarkdownGenerator or pydantic_settings_export.generators.MarkdownGenerator

Features

  • Customizable table headers
  • Support for nested settings
  • Environment variable prefixes
  • Optional region-based content insertion
  • Markdown formatting with headers and sections

Configuration

[[tool.pydantic_settings_export.generators.markdown]]
# Output file paths
paths = [
    "docs/settings.md",
    "wiki/configuration"
]

# Document formatting
table_headers = ["Name", "Type", "Default", "Description"]  # Optional headers
table_only = false     # Generate full documentation with headers
file_prefix = "# Application Settings\n\n"  # Optional prefix text

# Advanced options
to_upper_case = true   # Convert field names to uppercase
region = false         # Region for content insertion (requires 'regions' extra)

DotEnv Generator

The DotEnv generator creates .env example files with environment variables.

Keyword: dotenv
Class: DotEnvGenerator or pydantic_settings_export.generators.DotEnvGenerator

Features

  • Multiple export modes
  • Optional grouping by settings class
  • Example value inclusion
  • Support for aliases
  • Comment-based documentation

Configuration

[[tool.pydantic_settings_export.generators.dotenv]]
# Output file paths
paths = [
    ".env.example",
    ".env.sample"
]

# Generation options
split_by_group = true   # Group variables by settings class
add_examples = true     # Include example values
mode = "all"           # Export mode: "all", "only-optional", or "only-required"

Simple Generator

The Simple generator creates plain text documentation with basic formatting.

Keyword: simple
Class: SimpleGenerator or pydantic_settings_export.generators.SimpleGenerator

Features

  • Basic text formatting
  • Section headers with underlines
  • Field descriptions
  • Default values
  • Example inclusion

Configuration

[[tool.pydantic_settings_export.generators.simple]]
# Output file paths
paths = [
    "docs/simple-settings.txt"
]

# The Simple generator has minimal configuration
enabled = true  # Enable/disable generation

Best Practices

  1. File Organization

    • Use consistent file paths
    • Group related settings files
    • Use descriptive file names
  2. Configuration

    • Keep configuration in pyproject.toml
    • Use environment variables for sensitive values
    • Document generator options
  3. Generation

    • Test output with different settings types
    • Validate generated documentation
    • Keep formatting consistent

For common issues and solutions, see Troubleshooting.

Related Topics

Clone this wiki locally
0