Skip to content

Commit

Permalink
Issue #386 [Enhancement][WIP] Add reverseArrowDirection option to dep…
Browse files Browse the repository at this point in the history
…endency-graph to show dataflow instead of dependency
  • Loading branch information
t2ym committed Oct 4, 2020
1 parent 25da838 commit 7ad9821
Show file tree
Hide file tree
Showing 2 changed files with 2,818 additions and 2,817 deletions.
45 changes: 23 additions & 22 deletions demo-config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class TargetConfig extends Traceable(Configurable(GulpDefaultRegistry, 'thin-hoo
' edge [fontsize=10]\n' +
' \n',
footer: '\n}\n',
reverseArrowDirection: true, // true to show dataflow; false to show dependency
tooltip: (type, name) => {
let tooltip = '';
switch (type) {
Expand All @@ -55,24 +56,24 @@ class TargetConfig extends Traceable(Configurable(GulpDefaultRegistry, 'thin-hoo
log = log.replace(/"/g, '\\"');
let match;
if (match = log.match(/^(.*) r$/)) {
return `-> ${match[1]}`;
return `${this.trace.dot.reverseArrowDirection ? '<-' : '->'} ${match[1]}`;
}
else if (match = log.match(/^(.*) w$/)) {
return `<- ${match[1]}`;
return `${this.trace.dot.reverseArrowDirection ? '->' : '<-'} ${match[1]}`;
}
else if (match = log.match(/^(.*) set$/)) {
return `<- ${match[1]}`;
return `${this.trace.dot.reverseArrowDirection ? '->' : '<-'} ${match[1]}`;
}
else {
return `-> ${log}`;
return `${this.trace.dot.reverseArrowDirection ? '<-' : '->'} ${log}`;
}
})
.sort((a, b) => {
if (a.startsWith('<-') && b.startsWith('->')) {
return -1;
return this.trace.dot.reverseArrowDirection ? 1 : -1;
}
else if (a.startsWith('->') && b.startsWith('<-')) {
return 1;
return this.trace.dot.reverseArrowDirection ? -1 : 1;
}
else {
return a.localeCompare(b);
Expand Down Expand Up @@ -100,16 +101,16 @@ class TargetConfig extends Traceable(Configurable(GulpDefaultRegistry, 'thin-hoo
switch (type) {
default:
case '':
plugins.push(`<- ${plugin}`);
plugins.push(`${this.trace.dot.reverseArrowDirection ? '->' : '<-'} ${plugin}`);
break;
case ' set':
plugins.push(`-> ${plugin}`);
plugins.push(`${this.trace.dot.reverseArrowDirection ? '<-' : '->'} ${plugin}`);
break;
case ' r':
plugins.push(`<- ${plugin}`);
plugins.push(`${this.trace.dot.reverseArrowDirection ? '->' : '<-'} ${plugin}`);
break;
case ' w':
plugins.push(`-> ${plugin}`);
plugins.push(`${this.trace.dot.reverseArrowDirection ? '<-' : '->'} ${plugin}`);
break;
}
}
Expand All @@ -118,10 +119,10 @@ class TargetConfig extends Traceable(Configurable(GulpDefaultRegistry, 'thin-hoo
tooltip += plugins
.sort((a, b) => {
if (a.startsWith('<-') && b.startsWith('->')) {
return -1;
return this.trace.dot.reverseArrowDirection ? 1 : -1;
}
else if (a.startsWith('->') && b.startsWith('<-')) {
return 1;
return this.trace.dot.reverseArrowDirection ? -1 : 1;
}
else {
return a.localeCompare(b);
Expand Down Expand Up @@ -150,16 +151,16 @@ class TargetConfig extends Traceable(Configurable(GulpDefaultRegistry, 'thin-hoo
switch (type) {
default:
case '':
plugins.push(`<- ${plugin}`);
plugins.push(`${this.trace.dot.reverseArrowDirection ? '->' : '<-'} ${plugin}`);
break;
case ' set':
plugins.push(`-> ${plugin}`);
plugins.push(`${this.trace.dot.reverseArrowDirection ? '<-' : '->'} ${plugin}`);
break;
case ' r':
plugins.push(`<- ${plugin}`);
plugins.push(`${this.trace.dot.reverseArrowDirection ? '->' : '<-'} ${plugin}`);
break;
case ' w':
plugins.push(`-> ${plugin}`);
plugins.push(`${this.trace.dot.reverseArrowDirection ? '<-' : '->'} ${plugin}`);
break;
}
}
Expand All @@ -168,10 +169,10 @@ class TargetConfig extends Traceable(Configurable(GulpDefaultRegistry, 'thin-hoo
tooltip += plugins
.sort((a, b) => {
if (a.startsWith('<-') && b.startsWith('->')) {
return -1;
return this.trace.dot.reverseArrowDirection ? 1 : -1;
}
else if (a.startsWith('->') && b.startsWith('<-')) {
return 1;
return this.trace.dot.reverseArrowDirection ? -1 : 1;
}
else {
return a.localeCompare(b);
Expand All @@ -197,16 +198,16 @@ class TargetConfig extends Traceable(Configurable(GulpDefaultRegistry, 'thin-hoo
? ` "${propertyName}"[tooltip="${this.trace.dot.tooltip('property', propertyName)}"]\n`
: '',
writeProperty: (propertyName, pluginName) => this.trace.dot.focus(pluginName, propertyName, null)
? ` "${propertyName}" -> "${pluginName}"[color="0.002 0.999 0.999"]\n`
? ` "${this.trace.dot.reverseArrowDirection ? pluginName : propertyName}" -> "${this.trace.dot.reverseArrowDirection ? propertyName : pluginName}"[color="0.002 0.999 0.999"]\n`
: '',
readProperty: (propertyName, pluginName) => this.trace.dot.focus(pluginName, propertyName, null)
? ` "${pluginName}" -> "${propertyName}"\n`
? ` "${this.trace.dot.reverseArrowDirection ? propertyName : pluginName}" -> "${this.trace.dot.reverseArrowDirection ? pluginName : propertyName}"\n`
: '',
writeFile: (fileName, pluginName) => this.trace.dot.focus(pluginName, null, fileName)
? ` "${fileName}" -> "${pluginName}"[color="0.002 0.999 0.999"]\n`
? ` "${this.trace.dot.reverseArrowDirection ? pluginName : fileName}" -> "${this.trace.dot.reverseArrowDirection ? fileName : pluginName}"[color="0.002 0.999 0.999"]\n`
: '',
readFile: (fileName, pluginName) => this.trace.dot.focus(pluginName, null, fileName)
? ` "${pluginName}" -> "${fileName}"\n`
? ` "${this.trace.dot.reverseArrowDirection ? fileName : pluginName}" -> "${this.trace.dot.reverseArrowDirection ? pluginName : fileName}"\n`
: '',
},
})
Expand Down
Loading

0 comments on commit 7ad9821

Please sign in to comment.