Skip to main content

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  |
  +-------+                             +-----+                 +-----------+
                                                                             

Release files for adia 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adia 0.1.2
File Size Uploaded
adia-0.1.2.tar.gz 20.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adia 0.1.2
File Interpreter ABI Platform
adia-0.1.2-py3.8.egg Legacy Egg format - - Details

Total release size:72.3 kB

Release files / adia-0.1.2.tar.gz

Download URL adia-0.1.2.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d5cdfd41c471c6e6567bc0ae5b87012868d9c9bafd04f60e044603d2832e3bbd
BLAKE2b-256 checksum
How to use checksums
e7f7b33beac705d1d21a09876fae5e726faeac8522416fd650cdd7bd1582d0c9
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / adia-0.1.2-py3.8.egg

Download URL adia-0.1.2-py3.8.egg
Size 51.6 kB
Tags Egg
SHA-256 checksum
How to use checksums
5fd05438bc64a2ed2b50eb258842b22b50965f4248e6928c6b909e71897b4b89
BLAKE2b-256 checksum
How to use checksums
1f9f789a4daf260cc6b579fb5d4751062d184e925d0e40dd9ba55d0aa6a24ea7
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

4.1.0

2 release files

4.0.4

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page