Skip to main content

library to generate seqeuence diagram for python code

Project description

Sequence Diagram Generator for Python

Overview

This Python library generates sequence diagrams for your Python code using the Mermaid.js format. It allows you to visualize the interactions between various parts of your code, aiding in better understanding and documentation.

Features

  • Mermaid.js Integration: Utilizes Mermaid.js for generating sequence diagrams.
  • HTML Generation: Generates an HTML file containing the sequence diagram.
  • Function Decoration: Decorate functions/methods with @sequenceDiagram to include them in the sequence diagram.

Installation

To install the library, you can use pip:

pip install sequenceDiagram

Usage

Importing the Library

from sequence_diagram_generator import sequenceDiagram, writehtml

Decorating Functions

Use the @sequenceDiagram decorator to mark the functions you want to include in the sequence diagram.

@sequenceDiagram
def function_a():
    print("Function A")

@sequenceDiagram
def function_b():
    function_a()
    print("Function B")

Generating the HTML

After decorating the desired functions, use the writehtml function to generate the HTML file with the sequence diagram.

html_path = "path/to/sequence_diagram.html"
writehtml(html_path)

Example

Here's a complete example:

from sequenceDiagram import sequenceDiagram, writehtml

@sequenceDiagram
def function_a():
    print("Function A")

@sequenceDiagram
def function_b():
    function_a()
    print("Function B")

@sequenceDiagram
def main():
    function_b()
    print("Main Function")

if __name__ == "__main__":
    main()
    writehtml("sequence_diagram.html")

This will generate an HTML file named sequence_diagram.html in the specified path, containing the sequence diagram of the interactions between main, function_b, and function_a.

Contact

For any questions or issues, please open an issue on the GitHub repository or connect with me at brijesh.kulkarni@gmail.com


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

sequencediagram-0.0.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

sequenceDiagram-0.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file sequencediagram-0.0.2.tar.gz.

File metadata

  • Download URL: sequencediagram-0.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.9

File hashes

Hashes for sequencediagram-0.0.2.tar.gz
Algorithm Hash digest
SHA256 7f5540357d399af3522554e596c8ed5a71fd80bd068659df0140fe03a36b2f22
MD5 78ef6b8e8e1c0b54cb6ef24be99fb7a0
BLAKE2b-256 f3269f63b2499e09d1687e18e06d28a1b3108aa82150bc9f3863c67566fec1c2

See more details on using hashes here.

File details

Details for the file sequenceDiagram-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sequenceDiagram-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4d8d54861004e021909913436e4ebd0f675dae7e1666639056e30b7b518052c8
MD5 c8585716b9833e2101c068f0070a4ad8
BLAKE2b-256 05c2ba027fbfaa93e17ec663b5a238ac9bb233337719e3e6127c61dd2019e32f

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