Skip to content

dnnrly/layli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

layli

This tools produces diagrams and has 2 simple aims:

  1. Define components and connections as code
  2. Look pretty

GitHub release (latest SemVer) Build Status codecov godoc Go Report Card

GitHub watchers GitHub stars Twitter URL

ko-fi

Using layli

Installation

$ go install github.com/dnnrly/layli/cmd/layli

A simple examples

Your first layli file:

node: "Hello World"
$ layli hello-world.layli

layli principles

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:

  1. Edge paths must travel across a "path grid"
  2. Node borders must be on the "path grid"
  3. Edges must meet nodes at "ports"
  4. Ports must sit on the "path grid"
  5. Where a port is not specified, layli may select a "default" port on any side of the node
  6. Nodes must be layed out so that the total area marked by the outside bounds of every node is as small as possible
  7. Nodes must be seperated by at least 1 space on the "path grid"
  8. Edges must must not cross!
  9. Edges must follow a grid path (ie. not curved or diagonal)
  10. Edges must be as short as possible
  11. Edges must have as few corners as possible
  12. Edge paths may sit on top of each other at the beginning or at the end

Defining nodes

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 page
  • topo-sort - nodes are sorted in order of the edges, all in a single row
  • tarjan - uses Tarjan's Algorithm to arrange the nodes an a 'pleasing' way
  • absolute - lets you specify where you want nodes to appear on the diagram

An example diagram

Here's an image that is generated by this command layli ./demo.layli --show-grid:

Demonstration image

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

Developing layli

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.

Running Unit Tests

$ make test

Running Acceptance tests

$ make acceptance-test

Important make targets

  • deps - downloads all of the deps you need to build, test, and release
  • install - installs your application
  • build - builds your application
  • test - runs unit tests
  • ci-test - run tests for CI validation
  • acceptance-test - run the acceptance tests
  • coverage-report - merge coverage statistics from all sources
  • mocks - generate mocks for interface
  • lint - run linting
  • clean - clean project dependencies
  • clean-deps - remove all of the build dependencies too

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Pascal Dennerly - Initial work - dnnrly

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details

Acknowledgments

  • 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.