This tools produces diagrams and has 2 simple aims:
- Define components and connections as code
- Look pretty
$ go install github.com/dnnrly/layli/cmd/layli
Your first layli file:
node: "Hello World"
$ layli hello-world.layli
layli aims to let you specify nodes and edges (boxes and lines) and looks after arranging them in a pleasing way. If you've ever used plantuml you'll be familiar with describing the diagrams in a simple to understand text file to generate a pretty diagram. Well, perhaps not as pretty as you would hope. This tool aims to solve this.
Here are some principles that hope to tackle this problem head on:
- Edge paths must travel across a "path grid"
- Node borders must be on the "path grid"
- Edges must meet nodes at "ports"
- Ports must sit on the "path grid"
- Where a port is not specified, layli may select a "default" port on any side of the node
- Nodes must be layed out so that the total area marked by the outside bounds of every node is as small as possible
- Nodes must be seperated by at least 1 space on the "path grid"
- Edges must must not cross!
- Edges must follow a grid path (ie. not curved or diagonal)
- Edges must be as short as possible
- Edges must have as few corners as possible
- Edge paths may sit on top of each other at the beginning or at the end
Specifying a simple node:
Complex nodes:
nodes:
- id: node-1
contents: "A\nwith formatting"
Connecting nodes:
edges:
- from: node-1
to: "The node name"
Defining the layout style:
layout: flow-square
There are currently 3 different layout styles:
flow-square
- nodes are arranged into rows and columns, much the way you read words on a pagetopo-sort
- nodes are sorted in order of the edges, all in a single rowtarjan
- uses Tarjan's Algorithm to arrange the nodes an a 'pleasing' wayabsolute
- lets you specify where you want nodes to appear on the diagram
Here's an image that is generated by this command layli ./demo.layli --show-grid
:
Layli definition for this file
layout: flow-square
nodes:
- id: a
contents: Node A
- id: b
contents: Node B
- id: c
contents: Node C
- id: d
contents: Node D
- id: e
contents: Node E
- id: f
contents: Node F
- id: g
contents: Node G
- id: h
contents: Node H
- id: i
contents: Node J
edges:
- from: a
to: b
- from: b
to: c
- from: c
to: d
- from: d
to: e
- from: c
to: e
- from: e
to: d
- from: d
to: f
- from: f
to: g
- from: f
to: h
- from: g
to: i
width: 7
height: 4
border: 2
margin: 2
# You can also add comments to your file, like so.
You can see further examples here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
$ make test
$ make acceptance-test
deps
- downloads all of the deps you need to build, test, and releaseinstall
- installs your applicationbuild
- builds your applicationtest
- runs unit testsci-test
- run tests for CI validationacceptance-test
- run the acceptance testscoverage-report
- merge coverage statistics from all sourcesmocks
- generate mocks for interfacelint
- run lintingclean
- clean project dependenciesclean-deps
- remove all of the build dependencies too
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Pascal Dennerly - Initial work - dnnrly
See also the list of contributors who participated in this project.
This project is licensed under the Apache 2.0 License - see the LICENSE file for details
- There is a blog that I read a couple of years ago that described solving a similar problem. For the life of me, I can't remember find it anywhere to give the appropriate credit. But believe me when I say that a lot of the ideas are based on this blog and a lot of credit belongs to the author.