Export your Pydantic settings to Markdown and .env.example files!
This package provides a way to use pydantic (and pydantic-settings) models to generate a Markdown file with the settings and their descriptions, and a .env.example
file with the settings and their default values.
pip install pydantic-settings-export
# or
pipx install pydantic-settings-export # for a global installation and using as a CLI
# or
uv tool install pydantic-settings-export
You can see the usage examples of this package in the ./docs/Configuration.md and .env.example.
from pydantic import BaseSettings
from pydantic_settings_export import Exporter, MarkdownSettings, Settings as PSESettings
class Settings(BaseSettings):
my_setting: str = "default value"
another_setting: int = 42
# Export the settings to a Markdown file `docs/Configuration.md` and `.env.example` file
Exporter(
PSESettings(
markdown=MarkdownSettings(
save_dirs=["docs"],
),
),
).run_all(Settings)
pydantic-settings-export --help
You can add a pydantic_settings_export
section to your pyproject.toml
file to configure the exporter.
[tool.pydantic_settings_export]
project_dir = "."
default_settings = [
"pydantic_settings_export.settings:Settings",
]
dotenv = { "name" = ".env.example" }
[tool.pydantic_settings_export.markdown]
name = "Configuration.md"
save_dirs = [
"docs",
"wiki",
]
- Add tests
- Add more configuration options
- Add more output formats
- TOML (and
pyproject.toml
) - JSON
- YAML
- TOML (and