Generate the plotly.js attribute schema with node.js.
- Clone this gist
cd
into it- Run
npm i
npm start
and see results in ./schema.json
🍻.
node_modules | |
npm-debug.log | |
schema.json |
var fs = require('fs'); | |
var jsdom = require('jsdom'); | |
var plotly = fs.readFileSync('./node_modules/plotly.js/dist/plotly-with-meta.js', 'utf-8'); | |
jsdom.env({ | |
html: '<html><body></body></html>', | |
src: [plotly], | |
done: main | |
}); | |
function main(err, window) { | |
var Plotly = window.Plotly; | |
var schema = Plotly.PlotSchema.get(); | |
fs.writeFile('./schema.json', format(schema), function(err) { | |
if(err) throw err; | |
}); | |
} | |
function format(schema) { | |
return JSON.stringify(schema, null, 2); | |
} |
{ | |
"name": "plotly.js-schema", | |
"version": "1.0.0", | |
"description": "generate plotly.js attribute schema", | |
"main": "index.js", | |
"scripts": { | |
"start": "node index.js" | |
}, | |
"author": "Étienne Tétreault-Pinard", | |
"license": "MIT", | |
"dependencies": { | |
"jsdom": "^9.0.0", | |
"plotly.js": "^1.10.2" | |
} | |
} |