From aff2ceb758a8daf2a645516dfe708d5830ec48e0 Mon Sep 17 00:00:00 2001 From: Clay Reimann Date: Tue, 11 Oct 2016 11:17:44 -0500 Subject: [PATCH] Docs: update the readme based Updates are based on https://github.com/noffle/art-of-readme travis skip --- README.md | 110 ++++++++++++++++++++++++------------------------------ 1 file changed, 48 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index a7828852..4cce90c1 100644 --- a/README.md +++ b/README.md @@ -3,49 +3,17 @@ [![Downloads per month](https://img.shields.io/npm/dm/github-api.svg?maxAge=2592000)][npm-package] [![Latest version](https://img.shields.io/npm/v/github-api.svg?maxAge=3600)][npm-package] [![Gitter](https://img.shields.io/gitter/room/michael/github.js.svg?maxAge=2592000)][gitter] -[![Travis](https://img.shields.io/travis/michael/github.svg?maxAge=60)][travis-ci] -Github.js provides a minimal higher-level wrapper around Github's API. It was concieved in the context of -[Prose][prose], a content editor for GitHub. +Github.js provides a minimal higher-level wrapper around Github's API. -## [Read the docs][docs] - -## Installation -Github.js is available from `npm` or [unpkg][unpkg]. - -```shell -npm install github-api -``` - -```html - - - - - -``` - -## Compatibility -Github.js is tested on Node: -* 6.x -* 5.x -* 4.x -* 0.12 - -## GitHub Tools - -The team behind Github.js has created a whole organization, called [GitHub Tools](https://github.com/github-tools), -dedicated to GitHub and its API. In the near future this repository could be moved under the GitHub Tools organization -as well. In the meantime, we recommend you to take a look at other projects of the organization. - -## Samples +## Usage ```javascript /* Data can be retrieved from the API either using callbacks (as in versions < 1.0) - or using a new promise-based API. For now the promise-based API just returns the - raw HTTP request promise; this might change in the next version. + or using a new promise-based API. The promise-based API returns the raw Axios + request promise. */ import GitHub from 'github-api'; @@ -62,52 +30,70 @@ gist.create({ } }).then(function({data}) { // Promises! - let gistJson = data; - gist.read(function(err, gist, xhr) { - // if no error occurred then err == null - - // gistJson === httpResponse.data - - // xhr === httpResponse - }); + let createdGist = data; + return gist.read(); +}).then(function({data}) { + let retrievedGist = data; + // do interesting things }); ``` ```javascript -import GitHub from 'github-api'; +var GitHub = require('github-api'); // basic auth -const gh = new GitHub({ +var gh = new GitHub({ username: 'FOO', password: 'NotFoo' + /* also acceptable: + token: 'MY_OAUTH_TOKEN' + */ }); -const me = gh.getUser(); +var me = gh.getUser(); // no user specified defaults to the user for whom credentials were provided me.listNotifications(function(err, notifications) { // do some stuff }); -const clayreimann = gh.getUser('clayreimann'); -clayreimann.listStarredRepos() - .then(function({data: reposJson}) { - // do stuff with reposJson - }); +var clayreimann = gh.getUser('clayreimann'); +clayreimann.listStarredRepos(function(err, repos) { + // look at all the starred repos! +}); ``` -```javascript -var GitHub = require('github-api'); +## API Documentation -// token auth -var gh = new GitHub({ - token: 'MY_OAUTH_TOKEN' -}); +[API documentation][docs] is hosted on github pages, and is generated from JSDoc; any contributions +should include updated JSDoc. -var yahoo = gh.getOrganization('yahoo'); -yahoo.listRepos(function(err, repos) { - // look at all the repos! -}) +## Installation +Github.js is available from `npm` or [unpkg][unpkg]. + +```shell +npm install github-api ``` +```html + + + + + +``` + +## Compatibility +Github.js is tested on Node: +* 6.x +* 5.x +* 4.x +* 0.12 + +## GitHub Tools + +The team behind Github.js has created a whole organization, called [GitHub Tools](https://github.com/github-tools), +dedicated to GitHub and its API. In the near future this repository could be moved under the GitHub Tools organization +as well. In the meantime, we recommend you to take a look at other projects of the organization. + [codecov]: https://codecov.io/github/michael/github?branch=master [docs]: http://michael.github.io/github/ [gitter]: https://gitter.im/michael/github