Skip to content

Commit a69c59e

Browse files
committed
Update api docs
1 parent ea7b16b commit a69c59e

File tree

13 files changed

+99
-20
lines changed

13 files changed

+99
-20
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ flow.walk(function(obj) {
6666
6767
```
6868

69-
**TODO:** Add a better way to distinguish the object types
70-
7169
### Example - `export`
7270

7371
The `export` function gives back the JSON array for the flow.

jsdoc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"plugins":["jsdoc/include-parent.js"]
2+
"plugins": [
3+
"jsdoc/include-parent.js",
4+
"plugins/markdown"
5+
]
36
}

jsdoc/include-parent.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11

2+
const doclets = {};
23
const propertyMap = {};
34

45
exports.handlers = {
56
newDoclet: function(e) {
67
if (e.doclet.kind === "class" && e.doclet.properties) {
7-
propertyMap[e.doclet.name] = e.doclet.properties;
8+
doclets[e.doclet.name] = e.doclet;
9+
e.doclet.properties = e.doclet.properties || [];
810
}
911
},
1012
parseComplete: function(e) {
1113
e.doclets.forEach(doclet => {
12-
if (doclet.augments) {
13-
doclet.properties = doclet.properties || [];
14-
doclet.properties = propertyMap[doclet.augments[0]].concat(doclet.properties)
14+
if (doclet.kind === 'class' && doclet.augments) {
15+
augmentWithParent(doclet,doclets[doclet.augments[0]]);
1516
}
1617
})
1718
}
1819

1920
};
21+
22+
function augmentWithParent(doclet,parentDoclet) {
23+
doclet.properties = Array.from(new Set([...parentDoclet.properties, ...doclet.properties]))
24+
25+
if (!parentDoclet.augments || parentDoclet.augments.length === 0) {
26+
return;
27+
} else {
28+
augmentWithParent(doclet,doclets[parentDoclet.augments[0]])
29+
}
30+
31+
}

lib/NRContainer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const NRObject = require("./NRObject.js");
22

33
/**
44
* NRContainer - Description
5-
* @property {object} nodes - Flow nodes in this flow/subflow/group
5+
* @property {Set<NRNode>} nodes - Flow nodes in this flow/subflow/group
66
*/
77
class NRContainer extends NRObject {
88
/**

lib/NRFlow.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ const Symbols = require("./Symbols");
33

44
/**
55
* NRFlow - Description
6-
* @property {Set} configs - Configuration nodes in this flow/subflow
7-
* @property {Set} subflows - Subflows in this flow/subflow
8-
* @property {Set} groups - Groups in this flow/subflow
6+
* @property {Set<NRConfigNode>} configs - Configuration nodes in this flow/subflow
7+
* @property {Set<NRSubflow>} subflows - Subflows in this flow/subflow
8+
* @property {Set<NRGroups>} groups - Groups in this flow/subflow
9+
* @property {String} info - any documentation for this flow
910
* @extends NRContainer
1011
*/
1112
class NRFlow extends NRContainer {

lib/NRFlowSet.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ class NRFlowSet {
148148
addToParent(this.subflows);
149149
}
150150

151+
152+
/**
153+
* Export the flow as a Node Array that can be saves as JSON and loaded by Node-RED
154+
*
155+
* @return {Array} an array of node-red objects
156+
*/
151157
export() {
152158
let result = this.globals.exportContents();
153159
this.flows.forEach(n => {
@@ -158,6 +164,25 @@ class NRFlowSet {
158164
return result;
159165
}
160166

167+
168+
/**
169+
* Call the provided callback function for every object in the flow.
170+
* The objects are recursively visited in the following order:
171+
*
172+
* - Subflow definitions
173+
* - Config nodes scoped to this subflow
174+
* - Groups
175+
* - Nodes
176+
* - Global Config nodes
177+
* - Flows
178+
* - Config nodes scoped to this flow
179+
* - Groups
180+
* - Nodes
181+
*
182+
* @param {Function} callback - A function to call for every object in the flow.
183+
* The function will receive the object as its
184+
* first argument
185+
*/
161186
walk(callback) {
162187
this.globals.walk(callback);
163188
this.flows.forEach(n => n.walk(callback));

lib/NRGroup.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ const Symbols = require("./Symbols");
33

44
/**
55
* NRGroup - Description
6-
* @property {string} group - parent group, if set
6+
* @property {String} groupId - if set, the id of the parent group this group is in (from `node.g`)
7+
* @property {NRGroup} group - the parent group
8+
* @property {String} info - any documentation for this group
9+
* @property {object} style - style properties for this group
710
* @extends NRContainer
811
*/
912
class NRGroup extends NRContainer {

lib/NRNode.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ const Symbols = require("./Symbols");
55
* NRNode - Description
66
* @property {number} x - X location
77
* @property {number} y - Y location
8-
* @property {number} groupId - if set, the id of the group this node is in
8+
* @property {String} groupId - if set, the id of the group this node is in (from `node.g`)
9+
* @property {NRGroup} group - group this node is part of, if set
910
* @property {number} w - width (if known)
1011
* @property {number} h - height (if known)
11-
* @property {boolean} showLabel - whether the node displays its label
12-
* @property {string} group - group this node is part of, if set
12+
* @property {boolean} showLabel - whether the node displays its label (from `node.l`)
13+
* @property {String[][]} wires - the original `node.wires` property.
14+
* @property {number} outputCount - the number of outputs the node has (from `node.wires.length`)
15+
* @property {String} info - any documentation for this node
16+
* @property {String} icon - a custom icon for the node, if set
17+
* @property {String[]} inputLabels - array of custom labels for the node inputs
18+
* @property {String[]} outputLabels - array of custom labels for the node outputs
1319
* @property {NRWire[]} inboundWires - Array of wires connected to an input of this node
1420
* @property {NRWire[]} outboundWires - Array of wires connected to an output of this node
1521
* @extends NRObject

lib/NRObject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @property {string} type - the type of the object
66
* @property {boolean} disabled - whether the object is disabled
77
* @property {object} config - the item-specific configuration properties
8-
* @property {NRFlow|NRSubflow} parent - the parent object. This will be the NRFlow/NRSubflow that 'owns' this object
8+
* @property {NRFlow|NRSubflow} parent - the parent object. This will be the NRFlow/NRSubflow that 'owns' this object. As identified by `node.z`
99
*/
1010
class NRObject {
1111
/**
@@ -65,7 +65,7 @@ class NRObject {
6565
callback(this);
6666
}
6767
}
68-
68+
6969
walkContents(callback) {
7070

7171
}

lib/NRSubflow.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ const Symbols = require("./Symbols");
33

44
/**
55
* NRSubflow - Description
6-
* @property {object} instances - instances of the subflow
6+
* @property {Map<String,NRSubflowInstance>} instances - instances of the subflow
7+
* @property {String} category - if set, custom category this subflow is in
8+
* @property {String} color - if set, custom color for this subflow node
9+
* @property {String} icon - a custom icon for the subflow node, if set
10+
* @property {String[]} inputLabels - array of custom labels for the node inputs
11+
* @property {String[]} outputLabels - array of custom labels for the node outputs
12+
* @property {object} env - subflow properties definition
13+
* @property {object} meta - meta information about the subflow
14+
*
715
* @extends NRFlow
816
*/
917
class NRSubflow extends NRFlow {

0 commit comments

Comments
 (0)