Metadata-Version: 2.3
Name: pydantic-settings-export
Version: 0.2.3
Summary: Export your Pydantic settings to a Markdown and .env.example files!
Project-URL: Homepage, https://github.com/jag-k/pydantic-settings-export
Project-URL: Bug Tracker, https://github.com/jag-k/pydantic-settings-export/issues
Project-URL: Documentation, https://github.com/jag-k/pydantic-settings-export#readme
Author-email: Jag_k <30597878+jag-k@users.noreply.github.com>
License: MIT License
        
        Copyright (c) 2024 Jag_k
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENCE
Keywords: config,dotenv,export,markdown,pydantic,settings
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Documentation
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Requires-Dist: pydantic-settings>=2
Requires-Dist: pydantic>=2
Description-Content-Type: text/markdown

# pydantic-settings-export

[![PyPI version](https://img.shields.io/pypi/v/pydantic-settings-export?logo=pypi&label=pydantic-settings-export)](https://pypi.org/project/pydantic-settings-export/)
![Pepy Total Downloads](https://img.shields.io/pepy/dt/pydantic-settings-export)

*Export your Pydantic settings to Markdown and .env.example files!*

This package provides a way to use [pydantic](https://docs.pydantic.dev/) (and [pydantic-settings](https://docs.pydantic.dev/latest/concepts/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.

## Installation

```bash
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
```

## Usage

You can see the usage examples of this package in the [./docs/Configuration.md](https://github.com/jag-k/pydantic-settings-export/blob/main/docs/Configuration.md) and [.env.example](https://github.com/jag-k/pydantic-settings-export/blob/main/.env.example).

### As code

```python
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)
```

### As CLI

```bash
pydantic-settings-export --help
```

## Configuration

You can add a `pydantic_settings_export` section to your `pyproject.toml` file to configure the exporter.

```toml

[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",
]
```

## Todo

- [ ] Add tests
- [ ] Add more configuration options
- [ ] Add more output formats
  - [ ] TOML (and `pyproject.toml`)
  - [ ] JSON
  - [ ] YAML


## License

[MIT](https://github.com/jag-k/pydantic-settings-export/blob/main/LICENCE)
