Package: pydantic-2-mermaid
Pydantic 2 MermaidTo convert Pydantic 2 models to Mermaid charts, you can use thepydantic-2-mermaidlibrary. This library allows you to generate Mermaid charts from your Pydantic models. Here are the steps to install and use pydantic-mermaid:If you are using pydantic 1, please visithttps://github.com/EricWebsmith/pydantic_mermaidUse in terminalInstall thepydantic-2-mermaidlibrary using pip:pipinstallpydantic-2-mermaidUse command linepydantic-mermaid--modulemodels.py--outputmodels.mdYou can run the following comamand get help for the command.pydantic-mermaid--helpUse in codeImport your Pydantic models into your Python script.Create an instance of the MermaidGenerator class from thepydantic-2-mermaidmodule and pass in your Pydantic models as arguments.frompydantic_mermaidimportMermaidGeneratorimportmy_modulegenerator=MermaidGenerator(my_module)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:withopen("chart.mmd","w")asf: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.examplesInheritance:classDiagram
    class Animal {
    }

    class Fish {
        gill: str
    }

    class Beast {
        lags: int
    }

    class Bird {
        winds: int
    }

    class Dog {
    }

    class Cat {
    }

    class Salmon {
    }

    class Eagle {
    }


    Animal <|-- Fish
    Animal <|-- Bird
    Animal <|-- Beast
    Beast <|-- Cat
    Beast <|-- Dog
    Fish <|-- Salmon
    Bird <|-- Eagledependencies:Administrative Divisions of the United States of AmericaclassDiagram
    class Municipality {
        name: str
        population: int
    }

    class MinorCivilDivision {
        name: str
        population: int
    }

    class County {
        name: str
        population: int
        municipalities: list[Municipality]
        minor_civil_divisions: list[MinorCivilDivision]
    }

    class CountyEquivalant {
        name: str
        population: int
    }

    class State {
        name: str
        population: int
        counties: list[County]
        county_equivalants: list[CountyEquivalant]
    }

    class FederalDistrict {
        name: str
        population: int
    }

    class InhabitedTerritory {
        name: str
        population: int
    }

    class HabitedTerritory {
        name: str
        population: int
    }

    class Federal {
        name: str
        population: int
        federal_distric: FederalDistrict
        states: list[State]
        Inhabited_territories: list[InhabitedTerritory]
        Habited_territories: list[HabitedTerritory]
    }


    County ..> MinorCivilDivision
    County ..> Municipality
    State ..> CountyEquivalant
    State ..> County
    Federal ..> InhabitedTerritory
    Federal ..> HabitedTerritory
    Federal ..> State
    Federal ..> FederalDistrictFor details, check examples/ folder.