michaelo/daya
Text based graphing service
Example usage of compiler:
// Generate a png
daya myfile.daya output.png
// Generate an svg
daya myfile.daya output.svg
// Generate only the intermediary dot
daya myfile.daya output.dot
daya is a tool and library to convert from the .daya format to regular .dot, .png or .svg.
The daya-format is intended to allow for rapid diagramming from text sources. Mostly relationship-like diagrams such as UML's activity- and component-diagrams etc. There are currently no plan to add features for sequence-diagrams and such.
It can be thought of as "a subset of dot with custom types" (*). "Type" here are, due to the visual nature of it all, more comparable to CSS classes than types from strictly typed programming languages: they provide templates for how different parts shall appear.
The subset of features, attributes and such is highly opiniated, and very much subject to change as we move toward v1.0.
(*): This is also to be read as; There are many, many diagram-situations which are not intended to be solved by daya.
Prerequisite: have graphviz (https://graphviz.org/download/) installed and dot available in path on your system.
Create a .daya file - e.g "gettingstarted.daya":
// Create one or more node types
node User;
node System;
// Create one or more edge types
edge controls;
// Create instances based on node types
emperor: User;
deathstar: System;
// Create relationships based on instances and edge types
emperor controls deathstar;
then run: daya gettingstarted.daya gettingstarted.png
to create a diagram and save it as output.png for your viewing pleasures:
file: common_types.daya:
// Define common node-types
node Interface {
label="<Interface>";
shape=diamond;
fgcolor=#666666;
bgcolor=#ffddaa;
}
node Module {
label="[Module]";
shape=box;
fgcolor=#000000;
bgcolor=#ffffff;
}
// Define edge-/relationship-types
edge implements {
label="Implements";
edge_style=dashed;
target_symbol=arrow_open;
}
edge depends_on; // rely on defaults
edge relates_to {
source_symbol=arrow_open;
target_symbol=arrow_open;
}
file: mygraph.daya
// imports the file as described above. Limitation: path can't contain newline
@common_types.daya
// Set title of diagram
label="My example diagram";
// Declare the module-instances, optionally grouped
IIterator: Interface {
note="You can add notes to instances";
}
group Core {
note="You can add notes to groups";
// Groups are by default label-less (for now)
label="Core";
MySomething: Module;
MyElse: Module;
}
SomeDependency: Module {
// An instantiation can override base-node fields
bgcolor="#ffdddd";
}
// Describe relationships between modules
MySomething implements IIterator;
MySomething depends_on SomeDependency;
MySomething relates_to MyElse {
// A relationship can override base-edge fields
target_symbol=arrow_filled;
}
Result:
Types of statements:
Declare a node-type:
// Using only default properties
node NodeType;
// or override particular properties
node OtherNodeType {
label="Custom label";
shape=diamond;
}
Declare an edge-type
// Using only default properties - a simple, one-directional arrow when used in a relationship
edge owns;
// or override particular properties - to render e.g a two-way arrow
edge twowaydataflow {
source_symbol=arrow_filled;
target_symbol=arrow_filled;
}
Create a specific instance of a node
// Will inherit the properties of the given node type
myinstance: NodeType;
// And optionally override particular ones for this given instance
otherinstance: OtherNodeType {
shape=circle;
}
Specify a relationship between two node-instances using an edge
// Using the default style of the particular edge
myinstance owns otherinstance;
// Or override particular properties for the edge used in this given relationship
otherinstance twowaydataflow myinstance {
label="Overridden label for edge";
}
For the different types there are a set of allowed parameters that can be specificed:
See releases in repo, or Build-section below.
To install a release, download the platform-appropriate archive, decompress it, and put the resident daya-binary somewhere in your path.
Development is done using quite recent zig 0.10.x builds.
Build and run (from /compiler):
$ zig build run -- --help
or (e.g.) for installation on Unix-like systems (from /compiler):
$ zig build -Drelease-safe --prefix /usr/local
Run tests for libdaya (from /libdaya):
$ zig build test
The system is split into the following components:
The main logic of the daya-compiler is organized as a library located under /libdaya. Then there's a simple executable-wrapper located under /compiler.
The core component of it all. Provides functionaly to parse .daya, validate the results, output valid .dot + eventually directly execute system-installed dot to generate a graphical representation of the diagram.
Two parts:
Minimal, single-page, input-form to provide daya data and desired output-format (dot, png, svg).
...