File tree Expand file tree Collapse file tree 13 files changed +99
-20
lines changed
Expand file tree Collapse file tree 13 files changed +99
-20
lines changed Original file line number Diff line number Diff 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
7371The ` export ` function gives back the JSON array for the flow.
Original file line number Diff line number Diff line change 11{
2- "plugins" :[" jsdoc/include-parent.js" ]
2+ "plugins" : [
3+ " jsdoc/include-parent.js" ,
4+ " plugins/markdown"
5+ ]
36}
Original file line number Diff line number Diff line change 11
2+ const doclets = { } ;
23const propertyMap = { } ;
34
45exports . 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+ }
Original file line number Diff line number Diff 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 */
77class NRContainer extends NRObject {
88 /**
Original file line number Diff line number Diff 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 */
1112class NRFlow extends NRContainer {
Original file line number Diff line number Diff 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 ) ) ;
Original file line number Diff line number Diff 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 */
912class NRGroup extends NRContainer {
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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 */
1010class NRObject {
1111 /**
@@ -65,7 +65,7 @@ class NRObject {
6565 callback ( this ) ;
6666 }
6767 }
68-
68+
6969 walkContents ( callback ) {
7070
7171 }
Original file line number Diff line number Diff 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 */
917class NRSubflow extends NRFlow {
You can’t perform that action at this time.
0 commit comments