Fetch Electron documentation as raw markdown strings
Перейти к файлу
Zeke Sikelianos 944da9f484 add link to linter in readme 2016-09-09 10:48:15 -07:00
test enable docs to be read from disk 2016-06-24 16:40:53 -07:00
.travis.yml add travis config and badge 2016-06-16 15:38:17 -07:00
README.md add link to linter in readme 2016-09-09 10:48:15 -07:00
cli.js it works! 2016-06-16 15:32:27 -07:00
index.js improve error message 2016-09-09 10:47:19 -07:00
package.json better readme 2016-06-28 17:54:51 -07:00

README.md

electron-docs Build Status

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.

Installation

npm install electron-docs --save

Programmatic Usage

Require it and invoke the function with no arguments:

const electronDocs = require('electron-docs')

electronDocs().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..."
}

The latest version of Electron is fetched by default. If you need a different version, specify it as the first argument:

electronDocs('1.2.0').then(function(docs) {
  // ...
})

You can also point to a local directory instead of downloading a tarball:

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:

// latest
electronDocs(function(err, docs) {
  console.log(err, docs)
})

// a specific version
electronDocs('1.0.0', function(err, docs) {
  console.log(err, docs)
})

CLI Usage

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!

Tests

npm i && npm t

Dependencies

  • bluebird: Full featured Promises/A+ implementation with exceptionally good performance
  • github-latest-release: Get latest release information from github repository
  • got: Simplified HTTP requests
  • gunzip-maybe: Transform stream that gunzips its input if it is gzipped and just echoes it if not
  • node-dir: asynchronous file and directory operations for Node.js
  • ora: Elegant terminal spinner
  • tar-fs: filesystem bindings for tar-stream

Dev Dependencies

  • tap-spec: Formatted TAP output like Mocha's spec reporter
  • tape: tap-producing test harness for node and browsers

License

MIT