Convert pydantic classes to markdown mermaid class charts
Project description
To convert Pydantic models to Mermaid charts, you can use the pydantic-mermaid library. This library allows you to generate Mermaid charts from your Pydantic models. Here are the steps to install and use pydantic-mermaid:
- Install the pydantic-mermaid library using pip:
pip install pydantic-mermaid
- Import your Pydantic models into your Python script.
- Create an instance of the MermaidGenerator class from the pydantic_mermaid module and pass in your Pydantic models as arguments.
from pydantic_mermaid import MermaidGenerator
from my_module import MyPydanticModel
generator = MermaidGenerator(MyPydanticModel)
- Call the generate_chart() method of the MermaidGenerator instance to generate the Mermaid chart.
chart = generator.generate_chart()
- Use the chart variable to display or save the Mermaid chart.
print(chart)
This will print the Mermaid chart as a string. You can also save the chart to a file by writing the chart string to a file:
with open("chart.mmd", "w") as f:
f.write(chart)
This will save the Mermaid chart to a file called chart.mmd. You can then use a tool like the Mermaid Live Editor to visualize and edit the chart.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydantic_mermaid-0.1.0.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for pydantic_mermaid-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 980297bb34f2dfef979ae9eb2a6fe182153fa442c1e12c7b61b05184564ac152 |
|
MD5 | e58f5ed2f84268f8688a4b138902c59d |
|
BLAKE2b-256 | 888b44766cead44d6159262090c01b3afc326ebc8a42abbc2d985045463348c9 |