Skip to main content

Tool 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.0.tar.gz (16.7 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.0-py3-none-win_amd64.whl (1.6 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ i686

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

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

touml-0.1.0-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.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

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

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

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

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

touml-0.1.0-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.0.tar.gz.

File metadata

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

File hashes

Hashes for touml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 20851c6c2bc8214fa4cefb9644c0928182d2546c20d47083e1888b08b01cc9ed
MD5 065d632b3992a44f78c08c808b092d4b
BLAKE2b-256 aaaf3422224743947c261d681f9d5f5be298718090580d13229c72f5146eb6dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: touml-0.1.0-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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ddc2262fe106f225b798ae5a94cce6c1cdf3b6265b2fbba44eb333bdc06a2e38
MD5 3a0b720f7cc59686931d82b0a550ab2e
BLAKE2b-256 a70796aa7c7346597b2d071e9a108cfb1a839348776327db62ee4ad408812c0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: touml-0.1.0-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.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 4a061f22cdbcee62340fec586076ddb7e7e7e62b00fdcfed772e2bea9f40ae0e
MD5 aebf48953c631804fd030f9a86c325a3
BLAKE2b-256 ae919f34bdb66f255d049b8a6be6da46ef1264e6fdcfcb5f0c932982e7333916

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 525175f2cb75bcb8c556e4fc16e62a549c70fbb56ccaebc65239d79b65bce2f5
MD5 b56821a27ae381f6af4af3360be3fd4b
BLAKE2b-256 f59aafa812c48d78a58f6656df096b194381c29f1d54617cbab4cdb60402fd02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 75e383e6b15c46577395847182c4806236032526d58535a49dc38dad6f821cf5
MD5 e98b3c4198b2dae2f005471deed32a9c
BLAKE2b-256 5c4bbfd6edc456af64739b8edc5f9156d75d1aeb1def6ad211f575a13cbfdcaf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 138283cf31ad2162bc0b479061902ce3c4dfd3855703ef86ec991cc0f057ca36
MD5 43a384b337ad642f4078047c1b46ae5a
BLAKE2b-256 83ba0fbfc73ad3df9d64c7e95342c457cc8b4251059176f655a958fe37c83452

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 27c1c3a7bed9d2e00107b5551c51f2ee1981e3673a6bebd5dc60b2197445693d
MD5 787845562ee25fe011afcf2a08691f39
BLAKE2b-256 c3d3fdb6b872f31137ab77de969a27a09aa5f2d191ecb126a81cb78f3974e58e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea4d848e73b41f97ab2ee9db36c92cf8e3b239f94cecdbc6c95aaf422d038243
MD5 6f53b4de1e0b5f1c3fb09c9e78798085
BLAKE2b-256 1a88dd21956305892aff677c4bb244e9f2ab38f65b72159e1c2b8996b427abdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 5f1cf217263bfa36d44547d3897cb306393ddb45abb3fadf89b552f3763ad2b1
MD5 dcc90901367938392cc02b67791b081b
BLAKE2b-256 1e1560446f36d20a3898e872e956088e139521f8d624c7b43e4d65b20728e6e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 07cd25b0df872d6655a44623b1b2dc28240e90a7662d3d5ebea0373eb670288c
MD5 94491389aa7576c54c71a0fddc4925ac
BLAKE2b-256 ab465715bca9bba71c5883c980ea5ebad1a4beee78ff3f97c92fb9eb279db343

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 334bf927c1815dae08157f258bf52f06b182ff69a4e51e323ec64d0f1f283037
MD5 0c5ca929ec2c3851325e40b33fe52485
BLAKE2b-256 9db54802925c625ba93f27b3298826926b6407c63b89b340be64da5eada0b269

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 f10573a5103a6748b26fb18b730826d7383181fe0f25d9f73c0820cce6595145
MD5 d4afa47fef92337014ea3d6158b536d1
BLAKE2b-256 eedc13cea8c05bc01266e3949e70d591e2975438296174023f0245b47e178a59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1b3025e4d0f232ca5f4feff97f7540c6f5897dc1a5ba3f1da43f6034fd5a37f1
MD5 03bab28b59e58b5e9da07f3084f9879b
BLAKE2b-256 3aca6ab81a3f448b272b78712693c7fba5795c12f32877aaf3f6f9d582ed4477

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18b5b3a8e020e6dc0582ebb3fdc96786eb9c4b17afa9cd138a5f5fa55eb0a526
MD5 ffb5c94ce362d096a38d894b65490754
BLAKE2b-256 e50c5497009d9874446fd73bb584331158a5d5e5df3b724976d1d9e45d226b1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for touml-0.1.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c0162c967baa1e9eb32189beb2fc33d142264bda4b1652b6e75698279500535d
MD5 cba7270153d7f905bfd39037062cd576
BLAKE2b-256 3b100d6f485107753088e9e69f3d77e8a94ebc98194f34de4ca2aac6ebe3dc0d

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