aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2020-09-20 16:55:36 +0200
committerRuben Beltran del Rio <ruben@unlimited.pizza>2020-09-20 16:55:36 +0200
commite4c7bafd276049c805039b240e0a83346c31f41b (patch)
tree4c8788909ed67710a1628b9e4ae51c1a45b3b3ce /doc
Initial release
Diffstat (limited to 'doc')
-rw-r--r--doc/COVERAGE.md52
-rw-r--r--doc/README.md85
-rw-r--r--doc/images/graph-post-exec.svg59
-rw-r--r--doc/images/graph-pre-exec.svg95
4 files changed, 291 insertions, 0 deletions
diff --git a/doc/COVERAGE.md b/doc/COVERAGE.md
new file mode 100644
index 0000000..43cf0e4
--- /dev/null
+++ b/doc/COVERAGE.md
@@ -0,0 +1,52 @@
+# TOC
+ - [test/graph.js](#testgraphjs)
+ - [It colorizes the graph based on execution results](#it-colorizes-the-graph-based-on-execution-results)
+
+
+<a name="testgraphjs"></a>
+# test/graph.js
+It throws an error if you try to run a non-existing vertex.
+
+
+It runs a vertex if no dependencies are defined.
+
+
+It does not run a vertex if it has unfulfilled dependencies.
+
+
+It runs dependent vertices on completion of a vertex's action.
+
+
+It ensures dependencies state is available before running dependents.
+
+
+It gives dependent vertices a state including their dependencies' results.
+
+
+It throws an error if a vertex throws an error.
+
+
+It runs a vertex only once.
+
+
+It can convert to a string representing the graph in graphviz format.
+
+
+<a name="it-colorizes-the-graph-based-on-execution-results"></a>
+## It colorizes the graph based on execution results
+It throws an error if a sub-step fails.
+
+
+It adds the right colors according to execution.
+
+
+
+ok - It colorizes the graph based on execution results
+
+ok - test/graph.js
+----------|----------|----------|----------|----------|-------------------|
+File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
+----------|----------|----------|----------|----------|-------------------|
+All files | 100 | 100 | 100 | 100 | |
+ graph.js | 100 | 100 | 100 | 100 | |
+----------|----------|----------|----------|----------|-------------------|
diff --git a/doc/README.md b/doc/README.md
new file mode 100644
index 0000000..44ae3f8
--- /dev/null
+++ b/doc/README.md
@@ -0,0 +1,85 @@
+## Classes
+
+<dl>
+<dt><a href="#Grafn">Grafn</a></dt>
+<dd></dd>
+</dl>
+
+## Typedefs
+
+<dl>
+<dt><a href="#tVertex">tVertex</a> : <code>object</code></dt>
+<dd><p>The definition of a vertex that can be executed in the graph.</p>
+</dd>
+</dl>
+
+<a name="Grafn"></a>
+
+## Grafn
+**Kind**: global class
+
+* [Grafn](#Grafn)
+ * [new Grafn()](#new_Grafn_new)
+ * [.run(vertexName)](#Grafn+run)
+ * [.vertex(vertex)](#Grafn+vertex)
+ * [.toString()](#Grafn+toString) ⇒ <code>string</code>
+
+<a name="new_Grafn_new"></a>
+
+### new Grafn()
+Represents a graph of functions. You can call run on any specific vertex,
+which will trigger execution of it and its dependencies.
+
+It guarantees that each vertex will only run once.
+
+It can be represented in graphviz format, highlighting fulfilled and
+rejected vertices.
+
+<a name="Grafn+run"></a>
+
+### grafn.run(vertexName)
+Executes the named vertex and all its dependents
+
+**Kind**: instance method of [<code>Grafn</code>](#Grafn)
+**Throws**:
+
+- Will throw an error if a requested vertex does not exist
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| vertexName | <code>string</code> | the name of the vertex to run |
+
+<a name="Grafn+vertex"></a>
+
+### grafn.vertex(vertex)
+Adds a vertex to the graph.
+
+**Kind**: instance method of [<code>Grafn</code>](#Grafn)
+
+| Param | Type | Description |
+| --- | --- | --- |
+| vertex | [<code>tVertex</code>](#tVertex) | the definition of the vertex to add |
+
+<a name="Grafn+toString"></a>
+
+### grafn.toString() ⇒ <code>string</code>
+Converts the graph to a graphviz digraph. If vertices have been executed,
+they will be highlighted depending on whether they fulfilled or rejected.
+
+**Kind**: instance method of [<code>Grafn</code>](#Grafn)
+**Returns**: <code>string</code> - The graphviz digraph representation
+<a name="tVertex"></a>
+
+## tVertex : <code>object</code>
+The definition of a vertex that can be executed in the graph.
+
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| name | <code>string</code> | | The name of the vertex |
+| [dependencies] | <code>Array.&lt;string&gt;</code> | <code>[]</code> | The names of vertices that need to run before this one |
+| action | <code>function</code> | | The action to execute |
+
diff --git a/doc/images/graph-post-exec.svg b/doc/images/graph-post-exec.svg
new file mode 100644
index 0000000..557ef42
--- /dev/null
+++ b/doc/images/graph-post-exec.svg
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.40.1 (20161225.0304)
+ -->
+<!-- Title: %0 Pages: 1 -->
+<svg width="360pt" height="188pt" viewBox="0.00 0.00 360.40 188.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 184)">
+<title>%0</title>
+<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-184 356.3975,-184 356.3975,4 -4,4"/>
+<!-- root -->
+<g id="node1" class="node">
+<title>root</title>
+<ellipse fill="none" stroke="#00ff00" cx="184.5479" cy="-162" rx="27" ry="18"/>
+<text text-anchor="middle" x="184.5479" y="-157.8" font-family="Times,serif" font-size="14.00" fill="#000000">root</text>
+</g>
+<!-- successfulDependent -->
+<g id="node2" class="node">
+<title>successfulDependent</title>
+<ellipse fill="none" stroke="#00ff00" cx="92.5479" cy="-90" rx="92.5958" ry="18"/>
+<text text-anchor="middle" x="92.5479" y="-85.8" font-family="Times,serif" font-size="14.00" fill="#000000">successfulDependent</text>
+</g>
+<!-- root&#45;&gt;successfulDependent -->
+<g id="edge1" class="edge">
+<title>root-&gt;successfulDependent</title>
+<path fill="none" stroke="#000000" d="M166.8094,-148.1177C154.5005,-138.4846 137.7837,-125.402 123.3273,-114.0883"/>
+<polygon fill="#000000" stroke="#000000" points="125.1594,-111.0776 115.1272,-107.6708 120.8452,-116.5902 125.1594,-111.0776"/>
+</g>
+<!-- failedDependent -->
+<g id="node3" class="node">
+<title>failedDependent</title>
+<ellipse fill="none" stroke="#ff0000" cx="277.5479" cy="-90" rx="74.6995" ry="18"/>
+<text text-anchor="middle" x="277.5479" y="-85.8" font-family="Times,serif" font-size="14.00" fill="#000000">failedDependent</text>
+</g>
+<!-- root&#45;&gt;failedDependent -->
+<g id="edge2" class="edge">
+<title>root-&gt;failedDependent</title>
+<path fill="none" stroke="#000000" d="M202.4792,-148.1177C215.1273,-138.3256 232.3794,-124.9692 247.1555,-113.5296"/>
+<polygon fill="#000000" stroke="#000000" points="249.3002,-116.2955 255.0648,-107.4062 245.0149,-110.7605 249.3002,-116.2955"/>
+</g>
+<!-- final -->
+<g id="node4" class="node">
+<title>final</title>
+<ellipse fill="none" stroke="#000000" cx="184.5479" cy="-18" rx="28.9696" ry="18"/>
+<text text-anchor="middle" x="184.5479" y="-13.8" font-family="Times,serif" font-size="14.00" fill="#000000">final</text>
+</g>
+<!-- successfulDependent&#45;&gt;final -->
+<g id="edge3" class="edge">
+<title>successfulDependent-&gt;final</title>
+<path fill="none" stroke="#000000" d="M115.2895,-72.2022C128.3327,-61.9945 144.7616,-49.1371 158.3446,-38.5069"/>
+<polygon fill="#000000" stroke="#000000" points="160.6605,-41.1389 166.3785,-32.2195 156.3463,-35.6264 160.6605,-41.1389"/>
+</g>
+<!-- failedDependent&#45;&gt;final -->
+<g id="edge4" class="edge">
+<title>failedDependent-&gt;final</title>
+<path fill="none" stroke="#000000" d="M255.0352,-72.5708C241.7689,-62.3002 224.9157,-49.2525 211.0153,-38.4909"/>
+<polygon fill="#000000" stroke="#000000" points="212.8502,-35.4852 202.8003,-32.1309 208.565,-41.0202 212.8502,-35.4852"/>
+</g>
+</g>
+</svg> \ No newline at end of file
diff --git a/doc/images/graph-pre-exec.svg b/doc/images/graph-pre-exec.svg
new file mode 100644
index 0000000..e739550
--- /dev/null
+++ b/doc/images/graph-pre-exec.svg
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.40.1 (20161225.0304)
+ -->
+<!-- Title: %0 Pages: 1 -->
+<svg width="470pt" height="188pt" viewBox="0.00 0.00 469.85 188.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 184)">
+<title>%0</title>
+<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-184 465.8451,-184 465.8451,4 -4,4"/>
+<!-- root -->
+<g id="node1" class="node">
+<title>root</title>
+<ellipse fill="none" stroke="#000000" cx="225.6881" cy="-162" rx="27" ry="18"/>
+<text text-anchor="middle" x="225.6881" y="-157.8" font-family="Times,serif" font-size="14.00" fill="#000000">root</text>
+</g>
+<!-- addition -->
+<g id="node2" class="node">
+<title>addition</title>
+<ellipse fill="none" stroke="#000000" cx="42.6881" cy="-90" rx="42.8771" ry="18"/>
+<text text-anchor="middle" x="42.6881" y="-85.8" font-family="Times,serif" font-size="14.00" fill="#000000">addition</text>
+</g>
+<!-- root&#45;&gt;addition -->
+<g id="edge1" class="edge">
+<title>root-&gt;addition</title>
+<path fill="none" stroke="#000000" d="M202.1387,-152.7347C172.1868,-140.9503 119.9802,-120.41 83.4913,-106.0537"/>
+<polygon fill="#000000" stroke="#000000" points="84.6999,-102.7681 74.1128,-102.3638 82.137,-109.2821 84.6999,-102.7681"/>
+</g>
+<!-- subtraction -->
+<g id="node3" class="node">
+<title>subtraction</title>
+<ellipse fill="none" stroke="#000000" cx="157.6881" cy="-90" rx="53.8905" ry="18"/>
+<text text-anchor="middle" x="157.6881" y="-85.8" font-family="Times,serif" font-size="14.00" fill="#000000">subtraction</text>
+</g>
+<!-- root&#45;&gt;subtraction -->
+<g id="edge2" class="edge">
+<title>root-&gt;subtraction</title>
+<path fill="none" stroke="#000000" d="M211.2671,-146.7307C202.483,-137.4299 191.0542,-125.3288 181.0094,-114.6931"/>
+<polygon fill="#000000" stroke="#000000" points="183.4082,-112.1357 173.9974,-107.2687 178.3191,-116.942 183.4082,-112.1357"/>
+</g>
+<!-- multiplication -->
+<g id="node4" class="node">
+<title>multiplication</title>
+<ellipse fill="none" stroke="#000000" cx="294.6881" cy="-90" rx="65.444" ry="18"/>
+<text text-anchor="middle" x="294.6881" y="-85.8" font-family="Times,serif" font-size="14.00" fill="#000000">multiplication</text>
+</g>
+<!-- root&#45;&gt;multiplication -->
+<g id="edge3" class="edge">
+<title>root-&gt;multiplication</title>
+<path fill="none" stroke="#000000" d="M240.3212,-146.7307C249.1708,-137.4964 260.6658,-125.5015 270.8052,-114.9213"/>
+<polygon fill="#000000" stroke="#000000" points="273.4994,-117.1685 277.8915,-107.5269 268.4455,-112.3251 273.4994,-117.1685"/>
+</g>
+<!-- division -->
+<g id="node5" class="node">
+<title>division</title>
+<ellipse fill="none" stroke="#000000" cx="419.6881" cy="-90" rx="42.3145" ry="18"/>
+<text text-anchor="middle" x="419.6881" y="-85.8" font-family="Times,serif" font-size="14.00" fill="#000000">division</text>
+</g>
+<!-- root&#45;&gt;division -->
+<g id="edge4" class="edge">
+<title>root-&gt;division</title>
+<path fill="none" stroke="#000000" d="M249.4763,-153.1714C281.4694,-141.2977 338.8662,-119.9958 378.0863,-105.4399"/>
+<polygon fill="#000000" stroke="#000000" points="379.482,-108.6552 387.6394,-101.8944 377.0464,-102.0926 379.482,-108.6552"/>
+</g>
+<!-- tally -->
+<g id="node6" class="node">
+<title>tally</title>
+<ellipse fill="none" stroke="#000000" cx="225.6881" cy="-18" rx="28.4069" ry="18"/>
+<text text-anchor="middle" x="225.6881" y="-13.8" font-family="Times,serif" font-size="14.00" fill="#000000">tally</text>
+</g>
+<!-- addition&#45;&gt;tally -->
+<g id="edge5" class="edge">
+<title>addition-&gt;tally</title>
+<path fill="none" stroke="#000000" d="M74.1469,-77.6228C107.0728,-64.6683 158.5697,-44.4072 192.2259,-31.1655"/>
+<polygon fill="#000000" stroke="#000000" points="193.612,-34.3813 201.6362,-27.463 191.0491,-27.8674 193.612,-34.3813"/>
+</g>
+<!-- subtraction&#45;&gt;tally -->
+<g id="edge6" class="edge">
+<title>subtraction-&gt;tally</title>
+<path fill="none" stroke="#000000" d="M174.149,-72.5708C183.0445,-63.1521 194.1457,-51.3978 203.7648,-41.213"/>
+<polygon fill="#000000" stroke="#000000" points="206.4488,-43.4685 210.7705,-33.7951 201.3597,-38.6621 206.4488,-43.4685"/>
+</g>
+<!-- multiplication&#45;&gt;tally -->
+<g id="edge7" class="edge">
+<title>multiplication-&gt;tally</title>
+<path fill="none" stroke="#000000" d="M277.9851,-72.5708C268.9588,-63.1521 257.6944,-51.3978 247.9339,-41.213"/>
+<polygon fill="#000000" stroke="#000000" points="250.2712,-38.5934 240.8251,-33.7951 245.2172,-43.4367 250.2712,-38.5934"/>
+</g>
+<!-- division&#45;&gt;tally -->
+<g id="edge8" class="edge">
+<title>division-&gt;tally</title>
+<path fill="none" stroke="#000000" d="M387.653,-78.1107C352.3376,-65.0039 295.7599,-44.006 259.6811,-30.616"/>
+<polygon fill="#000000" stroke="#000000" points="260.6763,-27.2521 250.0834,-27.0539 258.2407,-33.8147 260.6763,-27.2521"/>
+</g>
+</g>
+</svg> \ No newline at end of file