This package consumes the electron/electron repo in search of markdown files, and returns an array of file objects with stringified file contents.
It is used by Electron's docs linter.
npm install electron-docs --save
Require the function and call it with any of the following:
master1.4.4v, like v1.7.076375a83eb3a97e7aed14d37d8bdc858c765e564~/my/path/to/electron/const electronDocs = require('electron-docs')
electronDocs('master').then(function(docs) {
// docs is an array of objects, one for each markdown file in /docs
})
Each object in the docs array looks like this:
{
slug: "windows-store-guide",
filename: "docs/tutorial/windows-store-guide.md",
markdown_content: "# Windows Store Guide\n\n..."
}
When fetching docs from a local directory, be sure to use a full path:
const path = require('path')
const docsPath = path.join(__dirname, 'docs')
electronDocs(docsPath).then(function(docs) {
// ...
})
If you prefer node-style callbacks instead of promises, those are supported too:
electronDocs('1.0.0', function(err, docs) {
console.log(err, docs)
})
Add this to your package.json file:
{
"scripts": {
"docs": "electron-docs > docs.json"
}
}
When you run npm run docs, the module writes the stringified JSON object to
stdout, and the output is piped into a file.
stdout ftw!
npm i && npm t
MIT