Skip to main content

Language for ASCII diagrams.

Project description

PyPI Build Coverage Status Python Documentation

ADia

ADia is a language specially designed to render ASCII diagrams.

Currently, only sequence diagrams are supported, but the roadmap is to support two more types of diagrams: fork and class, check out the TODO.md to figure out what I talking about.

The ADia can also run flawlessly inside the browsers using the awesome project: Brython. check out the Web Interface section below for more info.

diagram: Foo
sequence:
foo -> bar: Hello World!

Output:

 DIAGRAM: Foo                             

 +-----+             +-----+
 | foo |             | bar |
 +-----+             +-----+
    |                   |
    |~~~Hello World!~~~>|
    |                   |
    |<------------------|
    |                   |
 +-----+             +-----+
 | foo |             | bar |
 +-----+             +-----+

Command line

adia << EOF
diagram: Foo
sequence:
foo -> bar: Hello
EOF

Or feed one or more filename(s):

adia file1 file2 fileN

Use adia --help for more info.

Python API

from adia import Diagram

diagram = Diagram('''
  diagram: Foo
  sequence:
  foo -> bar: Hello World!
''')

print(diagram.renders())

Web interface

The adia package should be compatible with the Brython too. So, you can use it on every browser which supports ECMA6.

To build and check the demo, run:

make clean
make www
make serve

Or just one line to do all the above commands in order:

make clean serve

then open http://localhost:8000 in your favorite browser to use adia wihtout the CPython.

Isn't that nice?

Setup development environment

Use your favorite virtual environment tool such as https://pypi.org/project/virtualenvwrapper/.

Then:

make env

Running tests

CPython Tests

make test

CPython Coverage

make cover

Brython Tests

make clean serve

Then open the browser and point http://localhost:8000/check.html to run tests.

Update Brython runtime

Run make cleanall to force download and update brython*.js files.

make cleanall
make www

Complete example

diagram: Authentication
version: 1.0
author: pylover

sequence: Login/Logout
alice.title: Alice
bob.title: Bob
db.title: Database

# Login
@alice ~ bob: Alice tries to authenticate herself
alice -> bob: authenticate(email, password) -> token
  if: db is null
    bob -> db: initialize() -> db
  elif: db.is_connected()
    bob -> db: keepalive()
  else:
    while: not db.is_connected()
      bob -> db: connect()
  
  bob -> bob: create_token() -> token
  
@alice: |
  Alice decides to 
  store the newly 
  received Token 
  in a safe place. 
alice -> alice: store(token)

# Logout
@alice ~ bob: Alice tries to logout
alice -> bob: logout(token)
  bob -> db: delete(token)
  for: each token in db
    bob -> db: delete(token)

Generated diagram:

  DIAGRAM: Authentication                                                    
  author: pylover                                                            
  version: 1.0                                                               
                                                                             
                                                                             
  SEQUENCE: Login/Logout                                                     
                                                                             
  +-------+                             +-----+                 +-----------+
  | Alice |                             | Bob |                 | Database  |
  +-------+                             +-----+                 +-----------+
      |                                    |                          |      
  ---------------------------------------------                       |      
  | Alice tries to authenticate herself       |                       |      
  ---------------------------------------------                       |      
      |                                    |                          |      
      |~~~authenticate(email, password)~~~>|                          |      
      |                                    |                          |      
      |                                 *************************************
      |                                 * if db is null                     *
      |                                 *************************************
      |                                    |                          |      
      |                                    |~~~initialize()~~~~~~~~~~>|      
      |                                    |                          |      
      |                                    |<--db---------------------|      
      |                                    |                          |      
      |                                 *************************************
      |                                 * elif db.is_connected()            *
      |                                 *************************************
      |                                    |                          |      
      |                                    |~~~keepalive()~~~~~~~~~~~>|      
      |                                    |                          |      
      |                                    |<-------------------------|      
      |                                    |                          |      
      |                                 *************************************
      |                                 * else                              *
      |                                 *************************************
      |                                 *************************************
      |                                 * while not db.is_connected()       *
      |                                 *************************************
      |                                    |                          |      
      |                                    |~~~connect()~~~~~~~~~~~~~>|      
      |                                    |                          |      
      |                                    |<-------------------------|      
      |                                    |                          |      
      |                                 *************************************
      |                                 * end while                         *
      |                                 *************************************
      |                                 *************************************
      |                                 * end if                            *
      |                                 *************************************
      |                                    |                          |      
      |                                    |~~~create_token()~~~+     |      
      |                                    |                    |     |      
      |                                    |<--token------------+     |      
      |<--token----------------------------|                          |      
      |                                    |                          |      
  --------------------                     |                          |      
  | Alice decides to |                     |                          |      
  | store the newly  |                     |                          |      
  | received Token   |                     |                          |      
  | in a safe place. |                     |                          |      
  --------------------                     |                          |      
      |                                    |                          |      
      |~~~store(token)~~~+                 |                          |      
      |                  |                 |                          |      
      |<-----------------+                 |                          |      
      |                                    |                          |      
  ---------------------------------------------                       |      
  | Alice tries to logout                     |                       |      
  ---------------------------------------------                       |      
      |                                    |                          |      
      |~~~logout(token)~~~~~~~~~~~~~~~~~~~>|                          |      
      |                                    |~~~delete(token)~~~~~~~~~>|      
      |                                    |                          |      
      |                                    |<-------------------------|      
      |                                    |                          |      
      |                                 *************************************
      |                                 * for each token in db              *
      |                                 *************************************
      |                                    |                          |      
      |                                    |~~~delete(token)~~~~~~~~~>|      
      |                                    |                          |      
      |                                    |<-------------------------|      
      |                                    |                          |      
      |                                 *************************************
      |                                 * end for                           *
      |                                 *************************************
      |                                    |                          |      
      |<-----------------------------------|                          |      
      |                                    |                          |      
  +-------+                             +-----+                 +-----------+
  | Alice |                             | Bob |                 | Database  |
  +-------+                             +-----+                 +-----------+
                                                                             

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

adia-0.1.2.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

adia-0.1.2-py3.8.egg (51.6 kB view details)

Uploaded Egg

File details

Details for the file adia-0.1.2.tar.gz.

File metadata

  • Download URL: adia-0.1.2.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for adia-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d5cdfd41c471c6e6567bc0ae5b87012868d9c9bafd04f60e044603d2832e3bbd
MD5 0d69b109d452fb250a4d3d1037abc7f3
BLAKE2b-256 e7f7b33beac705d1d21a09876fae5e726faeac8522416fd650cdd7bd1582d0c9

See more details on using hashes here.

File details

Details for the file adia-0.1.2-py3.8.egg.

File metadata

  • Download URL: adia-0.1.2-py3.8.egg
  • Upload date:
  • Size: 51.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for adia-0.1.2-py3.8.egg
Algorithm Hash digest
SHA256 5fd05438bc64a2ed2b50eb258842b22b50965f4248e6928c6b909e71897b4b89
MD5 c2d415a961da6822229cfa50e5c372ac
BLAKE2b-256 1f9f789a4daf260cc6b579fb5d4751062d184e925d0e40dd9ba55d0aa6a24ea7

See more details on using hashes here.

Supported by

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