ecodoc
v1.3.0
Published
Manage docs across multiple packages
Downloads
12
Maintainers
Readme
ecodoc
Manage docs across multiple packages
Ecodoc maps an array of GitHub repository names to their info, contributors, latest version, and readme.
Install
npm install --save ecodoc
Usage
Note: In order for this to work, you need to set GH_TOKEN
environment variable, or pass in opts.token
. Otherwise, GitHub rate limits to 60 requests per hour. This tool makes at least 1 request per repository to check if info is updated. It makes 4 more requests for the info, contributors, tags, and README.
If you are lazy, you can just put GH_TOKEN=...
in front of a command that runs ecodoc
:
GH_TOKEN=... npm run build
ecodoc(opts)
Create an ecodoc mapping function (called docs
) with some options
cache
(String
): Path to where to store leveldb cache. Requiredtoken
(String
): GitHub API Token. Defaults toGH_TOKEN
env var. RequiredcacheMap
(Function
): Map each project right before you cache it.map
(Function
): Map all project info before you receive it.
var docs = ecodoc({
cache: __dirname + '/cache',
token: ..., // GH token, or just use `GH_TOKEN`
})
docs(projects, done)
Map project names to their info, latest version, contributors, and readme. They come from either requests or leveldb cache.
You can provide projects
as an array of GitHub repos, as an object in groups of arrays.
docs([
'audiojs/audio',
'audiojs/audio-buffer'
], function (err, projects) {
console.log(projects)
// [ { repo: 'audiojs/audio', latest_version: 'v1.2.0' ... }
// { repo: 'audiojs/audio-buffer', latest_version: 'v1.0.0' ... } ]
})
Or in groups:
docs({
core: [
'audiojs/audio',
'audiojs/audio-buffer'
],
utility: [
'audiojs/is-audio-buffer'
]
}, function (err, projects) {
console.log(projects)
// [ { name: 'audio', group: 'core', ... },
// { name: 'audio-buffer', group: 'core' },
// { name: 'is-audio-buffer', group: 'utility' } ]
})
project
This object contains:
{
name: 'audio', // project name
repo: 'audiojs/audio', // project repo
desc: '...', // project description
group: 'core', // project group (or falsy)
latest_version: 'v1.2.0', // latest git tag version
latest_ref: ..., // latest git ref
readme: ..., // README contents base64 encoded
contributors: [
{
username: 'dfcreative', // contributor username
profile: 'https://github.com/dfcreative', // contributor profile
avatar: ..., // contributor avatar
id: 300067, // contributor id
contributions: 4 // contributions
}
// ...
]
}
License
MIT © Jamen Marz
[][package] [][package] [][package] [][package] [package]: https://npmjs.com/package/ecodoc