postapl-mermaid-graph
v0.1.0
Published
PostAPL plugin to show AST or components as a Mermaid graph
Downloads
9
Maintainers
Readme
PostAPL Mermaid Graph
PostAPL Mermaid Graph is a PostAPL plugin that creates graph data for Mermaid Live Editor of the Component tree of your APL or of the AST.
Input / Output
The plugin is of type Reporter that does not transform the APL in any way.
Examples
You can find example reports here.
Usage
Step 1: Install plugin:
npm install --save-dev postapl postapl-mermaid-graph
Step 2: Use:
'use strict'
const { postapl } = require('postapl');
const graph = require('postapl-mermaid-graph');
const fs = require('fs');
fs.readFile('src/screen.json', (err, apl) => {
postapl([graph({ componentGraphPath: 'report/screen.componentTree.txt' })])
.process(apl, { from: 'src/screen.json', to: 'dest/screen.json' })
.then(result => {
fs.writeFile(result.opts.to, result.apl, () => true)
})
});
Options
componentGraphPath
- When set, the path to write the graph file for Components. When set to##messages:myComponentKey
no file is written but the data can be found inresult.messages
as:{ type: 'output', id: 'myComponentKey', plugin: 'postapl-mermaid-graph', value: string // the graph data }
treeGraphPath
- When set, the path to write the graph file for AST. When set to##messages:myTreeKey
no file is written but the data can be found inresult.messages
as:{ type: 'output', id: 'myTreeKey', plugin: 'postapl-mermaid-graph', value: string // the graph data }