Skip to main content

Generate draw.io icon libraries from AsciiDoc-based descriptions.

Project description

a2dl | (A)sciidoc(2D)rawio(L)ibrary

This script generates a draw.io library from AsciiDoc-based descriptions and updates diagrams that use icons from these libraries.

  • It recursively searches for adoc files in a specified folder and scans for particular lines within these files.
  • These lines are then integrated into HTML tooltips of draw.io icons.
  • The icons are bundled into a draw.io / diagrams.net library.

I needed to visualize the relationship within previously written content. I wrote this script to extract relevant information from these articles into tooltips for draw.io icons. This allows me to concentrate on connecting the information and provide contextual information during a presentation.

Install

python3 -m pip install a2dl

Prepare Asciidoc files

To use this script, simply add the identifiers to any adoc file.

Set these variables at the top of the file

  • :icon_image_rel_path: images/generated/3.png -> Path to an Icon Image PNG

  • :icon_name: Icon3 -> Name for the Icon

  • :read_more: #sec-icon3 -> Link for more info, to be appended to the tooltips end

These two lines form the start of a Tooltips content, while the first line will also work as a stop sign for the content extraction:

  • == or === up to =====

  • :variable_name: short_description -> choose any name for your variable, but do not include whitespace

Example Adoc

:toc:
:icon_image_rel_path: images/generated/3.png
:icon_name: Icon3
:read_more: #sec-icon3

[[sec-icon3]]
== Icon 3

image::{icon_image_rel_path}[The Icon 3s Alternative Text,160,160,float="right"]

=== Short Description
:variable_name: short_description

This is short Text to Describe the icon
A short abstract of the Topic

WARNING: Not Safe For Work


=== XML Attribute 1
:variable_name: xml_attribute_1

Some part of the text to add to the icons data 

Use

Use in CLI

python3 -m a2dl --library path/to/folder-to-scan path/to/library-file-to-write.xml
# OR
python3 -m a2dl --diagram path/to/folder-to-scan path/to/file-to-update
# OR
python3 -m a2dl --example path/to/folder-to-write

or

a2dl --library path/to/folder-to-scan path/to/library-file-to-write.xml
# OR
a2dl --diagram path/to/folder-to-scan path/to/file-to-update
# OR
a2dl --example path/to/folder-to-write

Use in python script

A basic example.

import a2dl.a2dl

# Overwrite some constants
a2dl.a2dl.ICON_STYLE = "rounded=1;whiteSpace=wrap;html=1;"
a2dl.a2dl.IMAGE_STYLE = 'fillColor=none;rounded=1;shape=image;verticalLabelPosition=bottom;labelBackgroundColor=default;verticalAlign=top;aspect=fixed;imageAspect=0;image=data:image/{},{};'

a2dl.a2dl.logging.getLogger('a2dl').addHandler(a2dl.a2dl.logging.NullHandler())

# create icon
DI = a2dl.a2dl.Diagicon()
DI.from_adoc('./data/exampleDocument.adoc')
# write the icon to a Diagram file
DI.write_diagram('./data/test-generated-icon-from-exampleDocument.drawio')

# create a library
DL = a2dl.a2dl.Diaglibrary()
DL.from_folder('./data')
DL.write('./data/test-generated-library.xml')

#  update a diagram
DG = a2dl.a2dl.Diagdiagram()
DG.from_file('./data/exampleDiagramFromLibrary-old.drawio')
DG.update(libraries=[DL])

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

a2dl-0.1.2.tar.gz (35.0 MB view details)

Uploaded Source

Built Distribution

a2dl-0.1.2-py3-none-any.whl (35.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: a2dl-0.1.2.tar.gz
  • Upload date:
  • Size: 35.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for a2dl-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b90f2863aee8c3d0a1bf0f363c411afc71fc563bb1f844a7c6aa4bb4221dd7e9
MD5 a22cb2aa30d0581d9dd1c38e28965b64
BLAKE2b-256 d6818b7d4d6788ddf3900da95f601e4cb8ade3c8ab888b4a9cf97e30e7499f03

See more details on using hashes here.

File details

Details for the file a2dl-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: a2dl-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 35.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for a2dl-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5d914f44e8970a297e44c856ebaa46177f9162f3bb6e51323886ef98eecdbb47
MD5 94df5b0b2619b270a56b9cb79a874119
BLAKE2b-256 49f0791d0c20139e7d2caee4d154efa413a0bb1e2f920616c0c0f2abf9816086

See more details on using hashes here.

Supported by

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