• Stars
    star
    141
  • Rank 251,416 (Top 6 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created about 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Render graphs using a declarative markup.

DataFlow

Render graphs using a declarative markup. Currently supports DFD (http://en.wikipedia.org/wiki/Data_flow_diagram) and sequence diagrams (http://plantuml.sourceforge.net/sequence.html).

DFD Output

Installation

  • To install using cabal run:

    $ cabal install dataflow
  • There are some binaries available in Releases.

  • If you want to use Docker there are images available on Docker Hub.

  • For build instructions see BUILD.md.

Usage

The following forms are supported by DataFlow.

IDs

An ID can contain letters, numbers and underscores. It must start with a letter.

my_id_contain_4_words

Strings

String literals are written using double quotes.

"this is a string and it can contain everything but double quotes and newlines"

NOTE! Escaping characters inside strings is not supported at the moment.

Text Blocks

Text blocks are special strings, enclosed in backticks, that are can span multiple lines in the source document. The space characters before the first non-space characters on each line are trimmed, regardless of the indentation.

`this is
      a
  textblock`

... is converted to:

this is
a
textblock

Arrays

Arrays can contain other values (arrays, strings, text blocks).

["hello", "world", ["I", "am", `nested
                                here`]]

Attributes

Attributes are key-value pairs for diagrams and nodes that are used by output renderers. Attributes are enclosed by curly brackets. For nodes that can contain other nodes, attributes must appear before nodes.

Keys have the same rules as IDs. Values can be strings or text blocks.

{
  key1 = "attr value"
  key2 = `attr
          value`
  key3 = ["value1", "value2"]
}

diagram

diagram is the top-level form and must appear exactly once in a DataFlow document. It can contain attributes and nodes.

diagram {
  title = "My diagram"
}

boundary

The boundary form declares a TrustBoundary node that can contain attributes and other nodes. Boundaries are only allowed in the top-level diagram and they must have unique IDs.

diagram {
  boundary my_boundary {
    title = "My System"
  }
}

nodes: io, function, database

The io, function and database forms declare InputOutput, Function and Database nodes, respectively. The nodes have IDs and they can contain attributes. Empty attribute brackets can be omitted.

diagram {
  io thing1

  io thing2 {
    title = "Thing 2"
  }
}

->

The -> form declares a Flow between the nodes referenced by their IDs. It can contain attributes. Empty attribute brackets can be omitted. Flows must be declared after all nodes.

Note that the arrow can be reversed as well (<-).

diagram {
  thing1 -> thing2

  thing1 <- thing2 {
    operation = "Greet"
    data = "A nice greeting"
  }
}

Comment

Comments are written using /* and */ and are ignored by the Reader. They're only used for human consumption.

diagram {
  /* I can write
   * whatever I
   * want in here! */
}

Example

The image from the top of this README is rendered from the following DataFlow document.

diagram {
  title = "Webapp"

  /* Some comment about this... */
  threats = `
    No particular threats at this point.

    It's **extremely** safe.`

  boundary browser {
    title = "Browser"

    function client {
      title = "Client"
    }
  }

  boundary aws {
    title = "Amazon AWS"

    function server {
      title = "Web Server"
    }
    database logs {
      title = "Logs"
    }
  }
  io analytics {
    title = "Google Analytics"
  }

  client -> server {
    operation = "Request /"
    description = `User navigates with a browser to see some content.`
  }
  server -> logs {
    operation = "Log"
    data = `The user
            IP address.`
    description = `Logged to a ELK stack.`
  }
  server -> client {
    operation = "Response"
    data = "User Profile"
    description = `The server responds with some HTML.`
  }
  analytics <- client {
    operation = "Log"
    data = "Page Navigation"
    description = `The Google Analytics plugin sends navigation
                   data to Google.`
  }
}

Run DataFlow

The dataflow executable takes an output format and a DataFlow source document and writes the output to stdout.

dataflow (dfd|seq) FILE

DFD

DFD Legend

To use the DFD output you need Graphviz installed.

dataflow dfd webapp.flow | dot -Tpng > webapp.png

Output

DFD Output

Sequence Diagram

Sequence Diagram Legend

You can use PlantUML to generate a sequence diagram.

dataflow seq webapp.flow | java -Djava.awt.headless=true -jar plantuml.jar -tpng -pipe > webapp.png

Output

Sequence Diagram Output

Templating

You can use Mustache to output arbitrary text.

dataflow template template.ha webapp.flow > webapp.html

Built-in Functions and Values

  • markdown - Convert the attribute at the given key from Markdown to HTML.

    {{#markdown}}my_markdown_attr{{/markdown}}
  • html_linebreaks - Replace \n with <br/> elements in the attribute at the given key, to retain linebreaks in HTML output.

    {{#html_linebreaks}}my_formatted_attr{{/html_linebreaks}}
  • filename_without_extension - The input .flow file name with no path and no extension. Useful when generating graphics and text/HTML with matching filenames (e.g. my-flow.html includes my-flow.png).

    <img src="{{filename_without_extension}}.png" />
  • flows - a list of all the Flow nodes in the diagram. Attributes of the flow is accessible inside the iteration scope, including a number.

    <ol>
    {{#flows}}
      <li>{{number}} - {{description}}</li>
    {{/flows}}
    </ol>

For an example see template.ha and the output HTML in webapp.html.

Output

Sequence Diagram Output

Makefile Example

The following Makefile finds .flow sources in src and generates DFDs, in SVG format, in dist.

SOURCES=$(shell find src/*.flow)
TARGETS=$(SOURCES:src/%.flow=dist/%.dfd.svg)

K := $(if $(shell which dataflow),,$(error "No dataflow executable in PATH. See https://github.com/SonyMobile/dataflow for install instructions)))"))

dist/%.dfd.svg: src/%.flow
	@dataflow dfd $< | dot -Tsvg > $@

dfd: $(TARGETS)

clean:
  rm -f $(TARGETS)

License

BSD-3, see LICENSE.

More Repositories

1

ApkAnalyser

Java
1,002
star
2

ChkBugReport

A command line tool which parses and converts android bugreport files into more human readable html reports.
Java
922
star
3

kernel

C
346
star
4

kernel-copyleft

Copyleft archives for Xperia kernels
C
138
star
5

WebGL

WebGL for Android Browser
C++
119
star
6

XAppDbg

Extra application debugging interface
Java
105
star
7

amazon-custom-resources

JavaScript
99
star
8

MultimediaForAndroidLibrary

Java
88
star
9

device-sony-yuga

Makefile
79
star
10

DASH

The Dynamic Android Sensor HAL
C
77
star
11

device-sony-lt26

Android device configuration for Xperia S
C
70
star
12

device-sony-common

Makefile
61
star
13

bug_tracker

Empty repository that is used as a bugtracker for Open Devices project
52
star
14

pygerrit

Python
52
star
15

gerrit-events

Java
46
star
16

device-sony-aries

C
45
star
17

BacklogTool

This tool keeps track of the backlog for software development teams
JavaScript
43
star
18

local_manifests

42
star
19

device-sony-leo

C
40
star
20

device-sony-maple

Makefile
40
star
21

device-sony-lilac

Makefile
36
star
22

Folding-home

C
35
star
23

DrmLicenseService

Java
35
star
24

device-sony-suzuran

Makefile
33
star
25

device-sony-honami

Makefile
27
star
26

device-sony-pioneer

Makefile
25
star
27

device-sony-c2105

Ruby
24
star
28

device-sony-amami

Makefile
22
star
29

device-sony-shinano

C
22
star
30

CDB-Assist

C
21
star
31

camera

C++
21
star
32

thermanager

Sony Xperia AOSP thermal manager service
C
21
star
33

device-sony-kagura

Makefile
20
star
34

device-sony-yoshino

Makefile
19
star
35

device-sony-kugo

Makefile
19
star
36

WebSDK

WebSDK packager with PhoneGap
19
star
37

device-sony-suzu

Makefile
18
star
38

home-badge

Java
18
star
39

device-sony-loire

Makefile
17
star
40

UnderwaterApps

Java
17
star
41

device-sony-togari

Makefile
16
star
42

device-sony-apollo

Makefile
15
star
43

device-sony-sumire

Makefile
15
star
44

device-sony-kumano

Makefile
15
star
45

device-sony-poplar

Makefile
15
star
46

device-sony-akari

Makefile
14
star
47

ave

Python
14
star
48

device-sony-tama

Makefile
14
star
49

device-sony-edo

Makefile
13
star
50

device-sony-sirius

C
13
star
51

lumber-mill

Where logs are cut into lumber
Java
12
star
52

device-sony-pdx206

Makefile
12
star
53

kernel-defconfig

Shell
12
star
54

EvolutionUI

Java
12
star
55

device-sony-discovery

Makefile
12
star
56

vendor-qcom-opensource-fm

Java
12
star
57

device-sony-pdx201

Makefile
12
star
58

device-sony-mermaid

Makefile
11
star
59

device-sony-griffin

Makefile
11
star
60

device-sony-akatsuki

Makefile
11
star
61

device-sony-lena

Makefile
10
star
62

device-sony-sgp321

Shell
10
star
63

device-sony-bahamut

Makefile
10
star
64

device-sony-tone

Makefile
10
star
65

mkqcdtbootimg

C
10
star
66

device-sony-kitakami

Makefile
10
star
67

device-sony-keyaki

Makefile
10
star
68

device-sony-satsuki

Makefile
9
star
69

device-sony-sagami

Makefile
9
star
70

vendor-sony-kernel

Makefile
9
star
71

device-sony-nile

Makefile
8
star
72

vendor-qcom-opensource-wlan-qcacld-3.0

C
8
star
73

CameraTest

Java
8
star
74

device-sony-kirin

Makefile
8
star
75

repo_update

Shell
8
star
76

device-sony-tulip

Makefile
7
star
77

device-sony-pdx215

Makefile
7
star
78

device-sony-pdx203

Makefile
7
star
79

vendor-sony-oss-simdetect

Kotlin
7
star
80

prima

Mirror of git://codeaurora.org/external/wlan/prima.git
C
7
star
81

device-sony-yukon

Makefile
7
star
82

device-sony-pdx223

Makefile
7
star
83

device-sony-rhine

Makefile
7
star
84

timekeep

C
7
star
85

device-sony-castor

Makefile
7
star
86

device-sony-pdx213

Makefile
6
star
87

kernel-techpack-audio

C
6
star
88

device-sony-eagle

Makefile
6
star
89

device-sony-sepolicy

Makefile
6
star
90

device-sony-c6503

Shell
6
star
91

kernel-sony-msm-4.9-common

Shell
5
star
92

device-qcom-sepolicy

Makefile
5
star
93

device-sony-pdx214

Makefile
5
star
94

device-sony-flamingo

Makefile
5
star
95

device-sony-kanuti

Makefile
5
star
96

vendor-qcom-opensource-audio-hal-primary-hal

C
5
star
97

device-sony-tianchi

Makefile
5
star
98

device-sony-pdx225

Makefile
5
star
99

vendor-broadcom-wlan

Makefile
5
star
100

device-sony-seine

Makefile
5
star