Skip to main content

CLI that creates a UML class diagram from classes in a Python module or subpackage.

Project description

touml

pronounced /ˈtoo͞m.əl/

A CLI to convert Python code to Mermaid diagrams.

Installation

pip install touml

# OR (better yet)
uv pip install touml

Usage

# Print help
touml --help

# Print output to stdout
touml path/to/python/files

# Generate an `out.mmd` file in the current directory
touml path/to/python/files -o .

# Print output, but exclude classes, files, and subdirectories matching globs.
touml path/to/python/files --exclude-files "**/__init__.py" "**/config.py" --exclude-dirs "tests" --exclude-classes "Base*"

Tips

# Pipe outputs to `less` to scroll outputs
$ touml path/to/python/files | less

# Pipe outputs to `mmdc` to generate images
$ touml path/to/python/files | mmdc -i -o out.png

# Copy outputs to clipboard
$ touml path/to/python/files | pbcopy

Examples

# Convert all Python files in the test directory to Mermaid diagrams
$ touml tests

classDiagram

    class StrClass {
        + some_other_values tuple[int, ...]
        + value str
        + yet_another_value set[int]
        + get_concatenated(self) str
    }

    Base <|-- StrClass
    StrMixin <|-- StrClass


    class IntClass {
        + value_1 int
        + value_2 list[int]
        + value_3 dict[str, int]
        + check_even(cls, v) int
    }

    Base <|-- IntClass
    IntMixin <|-- IntClass


    class Value {
        + VAL_1
        + VAL_2
        + VAL_3
    }

    `enum.StrEnum` <|-- Value


    class ClassicClass {
        + ANOTHER_CLS_VAR
        + A_CLS_VAR int
        + value
    }


    class Base {
        + id int
        + model_config
    }

    BaseModel <|-- Base


    class BaseMixin {
        + do_something(self)
    }

    `abc.ABC` <|-- BaseMixin


    class IntMixin {
        + do_something(self) int
    }

    BaseMixin <|-- IntMixin
    BaseModel <|-- IntMixin


    class StrMixin {
        + do_something(self) str
    }

    BaseMixin <|-- StrMixin
    BaseModel <|-- StrMixin

FAQs

What's Mermaid?

Mermaid is a diagramming and charting tool that produces neat diagrams from text. You can learn more about it here.

This tool doesn't generate images!

You're right, young padawan. This tool, intentionally, only generates Mermaid diagram code. To generate images, you can pipe the output to mmdc (the official Mermaid CLI). To download mmdc, take a look at their docs.

Once installed, you can try something like this:

$ touml path/to/python/files | mmdc -i -o out.png

I don't need images, I just want to see the diagrams!

You can copy the output to your clipboard and paste it in a Markdown file, Draw.io, or any other tool that supports Mermaid diagrams.

$ touml path/to/python/files | pbcopy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

touml-0.1.1.tar.gz (17.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

touml-0.1.1-py3-none-win_amd64.whl (1.6 MB view details)

Uploaded Python 3Windows x86-64

touml-0.1.1-py3-none-win32.whl (1.5 MB view details)

Uploaded Python 3Windows x86

touml-0.1.1-py3-none-musllinux_1_2_x86_64.whl (1.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

touml-0.1.1-py3-none-musllinux_1_2_i686.whl (1.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

touml-0.1.1-py3-none-musllinux_1_2_armv7l.whl (1.7 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

touml-0.1.1-py3-none-musllinux_1_2_aarch64.whl (1.7 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

touml-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

touml-0.1.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

touml-0.1.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

touml-0.1.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (1.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

touml-0.1.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

touml-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

touml-0.1.1-py3-none-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

touml-0.1.1-py3-none-macosx_10_12_x86_64.whl (1.7 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file touml-0.1.1.tar.gz.

File metadata

  • Download URL: touml-0.1.1.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.8

File hashes

Hashes for touml-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d18152ee0af01f5db72636564f3555a652077a73d84e4603421fedf8bfffe994
MD5 a471a76874fe1c591ff2fce73294565c
BLAKE2b-256 11d3f0e791bafe8d158491308c7fd6ab095e2aca6566cdc6dd7488c686b49d9e

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: touml-0.1.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.8

File hashes

Hashes for touml-0.1.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 523e20a356b10bb940e595733a81c5e38e896fc3e901ad3c7900c9fa8da12f86
MD5 ca3cb1cc59f2f6ac94789a301a708a19
BLAKE2b-256 593f6c3919936f3baac5e186838735ae51c63e9a48a2f0fadfbace1b437de69b

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-win32.whl.

File metadata

  • Download URL: touml-0.1.1-py3-none-win32.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.8

File hashes

Hashes for touml-0.1.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 1795837dedf5e37deafa10e2f44c74783375b33cc617eeae3380255ccb31399e
MD5 a9af1f69968276deab32e3c4b81be1d9
BLAKE2b-256 af89fda4741e3320f9a7c3b05828d49a7614e858130eeff21347bf01fddc6173

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9ee27187a11bd9487aec6a07afdd209d8e08c54acce2fffe3b56b43f0c64b06f
MD5 25aeb8318e9877940eb142b834236503
BLAKE2b-256 2ee2d9178a1934f927dcbbfc3982261cddbe978855f8afa7765dd50658f30fe9

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 6de1d369e5e16711b7541ab00a67770c0892513f2b903946fec48b6c649ce5c0
MD5 7c0f4c6c70957768af4098e81165e2ac
BLAKE2b-256 12801103f9e1c3a0d1e4ba6d0cfa3f79e35fc801621fe0bf8868412b78b83d4d

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 67afdd26e85c619dea36f35c85af362642f0b2fabb69399fe4e299810f8ef13c
MD5 616a98e5c512a1ad4bdf11395d7a753f
BLAKE2b-256 4423facde8c3464afa939f160124709c565833e85c524c1306e37b1a36d5128c

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 09cfa05ff55a49c86f368d738b28b501f46853c5679cc7009468c3b11fa980a7
MD5 c0123cd7440e395e01ebecae1d428ac1
BLAKE2b-256 f0ca6ff39d5d3fefcd2a6d4b9238cfdb148b668a2e797a5b7ec1e19112cd4d7a

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e60d7b8907488e8e34f521ca416166a3c49b8093a2d8809fdbde858c8d6a71d
MD5 967bf36bc5b4cbbcca65a6e17b7a9159
BLAKE2b-256 9d5f64d66f3ecea2e2ba521b901f279e4ea9ae9af35ceeb51c42b81264356eef

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 6b929c0cbf8dc54261b7b2e3fe89f49db1ffb2617617dd08099540c043680b3e
MD5 0d5043d61831e829a0383fa2b71d07c4
BLAKE2b-256 4c1ba9577e403521afea90d722a0935a26e635cc6b126911c2dd0b5f73b65b73

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 260836ac569ffff1ba851b492e482bf236782eb33d5a38e93abb8d2ccbd0a905
MD5 7a6ac4b5d15f8ba28796a43f5dab11cc
BLAKE2b-256 65093483d2dd1da3a3f04bfef2cb209f5ae63183926751b5e56de7d4caefa4df

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 f350a2bdd49634f9abd951f0aa7657848f829045b1c219df635f2723f536c5df
MD5 e200e3d3e23435ce6d6534d9792d6908
BLAKE2b-256 5a8eb64d67db155a02da986bf57ef18954e2251a91f8ef4f123719ed1c396fbc

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 d5d79c2384c08f21d8373506f4cdc8d6be5e68070f222956b4b986f7e7667cec
MD5 c0abd46cc528945f4667958f03648502
BLAKE2b-256 36a2deab74fd2ba03acc0cf0826d74853554f7960e1214c933e69d4a4d275a13

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2be3729ae1892589cd720cd9ff7feb9d25e86066fb4eb8a59b6b92e6cacbd342
MD5 8540cd78d5da869da6d85ed9f41cfc76
BLAKE2b-256 6e6f9613c413fd679c9e238b2f5581f4597467d56117b1ab25b30661312285b9

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed9f9a132a6bb3a88e05c9de962aea75eb638795708877ced6038b3d3fc1683d
MD5 9ee97376e70cf1ad884b04004f821f5b
BLAKE2b-256 2cd4037b49269a088429b91346e59ccb497f9085d4057d5d1b096d340cd06896

See more details on using hashes here.

File details

Details for the file touml-0.1.1-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for touml-0.1.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7d0ee87e8d74ab49d932c68850b60c2df1fd3affbc2b2029808daca71bdbe941
MD5 775d23cde8df2df4243f3f3bbf015be8
BLAKE2b-256 c28cd84c9c1bfbad98e53aeb60545e1fe9d9c863d948fa81ca331cdb8752d6ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page