Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate docs #8

Merged
merged 2 commits into from
Jun 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# HelloWorld

Main class, called HelloWorld

**Examples**

```javascript
var HelloWorld = require('index.js');
var HW = new HelloWorld();
```

## wave

Say howdy to the world

**Examples**

```javascript
var wave = HW.wave();
console.log(wave); // => 'howdy world!'
```

Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a happy-go-lucky string saying hi

## shout

Shout a phrase really loudly by adding an exclamation to the end, asynchronously

**Parameters**

- `phrase` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** to shout
- `different` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** ways to shout
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** from whence the shout comes, returns a string

**Examples**

```javascript
var HW = new HelloWorld();
HW.shout('rawr', {}, function(err, shout) {
if (err) throw err;
console.log(shout); // => 'rawr!'
});
```
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
default:
npm install --build-from-source
npm install --build-from-source

docs:
npm run docs
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "./lib/index.js",
"scripts": {
"test": "tape test/*.test.js",
"install": "node-pre-gyp install --fallback-to-build"
"install": "node-pre-gyp install --fallback-to-build",
"docs": "documentation build src/*.cpp --polyglot -f md -o API.md"
},
"author": "Mapbox",
"license": "ISC",
Expand All @@ -14,6 +15,7 @@
"node-pre-gyp": "^0.6.28"
},
"devDependencies": {
"documentation": "^4.0.0-beta5",
"tape": "^4.5.1"
},
"binary": {
Expand Down
23 changes: 13 additions & 10 deletions src/hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include <iostream>

/**
* Main method, called HelloWorld
*
* Main class, called HelloWorld
* @class HelloWorld
* @example
* var HelloWorld = require('index.js');
* var HW = new HelloWorld();
*/
NAN_METHOD(HelloWorld::New)
Expand Down Expand Up @@ -39,14 +40,14 @@ Nan::Persistent<v8::Function> &HelloWorld::constructor()
}

/**
* Say hello to the world
*
* @returns {String} howdy world
* Say howdy to the world
*
* @name wave
* @memberof HelloWorld
* @returns {String} a happy-go-lucky string saying hi
* @example
* var HW = new HelloWorld();
* var wave = HW.wave();
* console.log(wave); // => 'howdy world'
*
* console.log(wave); // => 'howdy world!'
*/
NAN_METHOD(HelloWorld::wave)
{
Expand All @@ -56,8 +57,10 @@ NAN_METHOD(HelloWorld::wave)
}

/**
* Shout a phrase really loudly, by adding an exclamation to the end
* Shout a phrase really loudly by adding an exclamation to the end, asynchronously
*
* @name shout
* @memberof HelloWorld
* @param {String} phrase to shout
* @param {Object} different ways to shout
* @param {Function} callback - from whence the shout comes, returns a string
Expand All @@ -70,7 +73,7 @@ NAN_METHOD(HelloWorld::wave)
*
*/

// this is the cpp object that will be passed around in our method and callbacks
// this is the cpp object that will be passed around in 'shout' and callbacks
// referred to as a "baton"
class AsyncBaton
{
Expand Down