Skip to content

Commit 7b7e678

Browse files
author
Carol Hansen
authored
Update API Docs (#47)
Update API docs
1 parent 49bffd3 commit 7b7e678

File tree

6 files changed

+94
-15
lines changed

6 files changed

+94
-15
lines changed

API.md

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
# HelloWorld
1+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2+
3+
### Table of Contents
4+
5+
- [HelloWorld](#helloworld)
6+
- [shout](#shout)
7+
- [wave](#wave)
8+
- [hello_async](#hello_async)
9+
- [hello](#hello)
10+
11+
## HelloWorld
212

313
Main class, called HelloWorld
414

@@ -7,9 +17,32 @@ Main class, called HelloWorld
717
```javascript
818
var HelloWorld = require('index.js');
919
var HW = new HelloWorld();
20+
OR
21+
var HW = new HelloWorld('yo');
22+
```
23+
24+
### shout
25+
26+
Shout a phrase really loudly by adding an exclamation to the end, asynchronously
27+
28+
**Parameters**
29+
30+
- `string` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** phrase to shout
31+
- `args` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** different ways to shout
32+
- `args.louder` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** adds exclamation points to the string
33+
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** from whence the shout comes, returns a string
34+
35+
**Examples**
36+
37+
```javascript
38+
var HW = new HelloWorld();
39+
HW.shout('rawr', { louder: true }, function(err, shout) {
40+
if (err) throw err;
41+
console.log(shout); // => 'rawr!'
42+
});
1043
```
1144

12-
## wave
45+
### wave
1346

1447
Say howdy to the world
1548

@@ -22,22 +55,38 @@ console.log(wave); // => 'howdy world!'
2255

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

25-
## shout
58+
## hello_async
2659

27-
Shout a phrase really loudly by adding an exclamation to the end, asynchronously
60+
This is a standalone function (async) that logs a string.
2861

2962
**Parameters**
3063

31-
- `phrase` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** to shout
32-
- `different` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** ways to shout
33-
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** from whence the shout comes, returns a string
64+
- `args` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** different ways to alter the string
65+
- `args.louder` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** adds exclamation points to the string
66+
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** from whence the hello comes, returns a string
3467

3568
**Examples**
3669

3770
```javascript
38-
var HW = new HelloWorld();
39-
HW.shout('rawr', {}, function(err, shout) {
71+
var module = require('./path/to/lib/index.js');
72+
module.hello_async({ louder: true }, function(err, result) {
4073
if (err) throw err;
41-
console.log(shout); // => 'rawr!'
74+
console.log(result); // => "...threads are busy async bees...world!!!!"
4275
});
4376
```
77+
78+
Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** an ever-so-slightly customizable string
79+
80+
## hello
81+
82+
This is a standalone function (sync) that logs a string.
83+
84+
**Examples**
85+
86+
```javascript
87+
var module = require('./path/to/lib/index.js');
88+
var check = module.hello();
89+
console.log(check); // => "world"
90+
```
91+
92+
Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** "world"

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ make clean
3737
# This is useful if you want to nuke everything and start from scratch.
3838
# For example, it's super useful for making sure everything works for Travis, production, someone else's machine, etc
3939
make disclean
40+
41+
# This skel uses documentation.js to auto-generate API docs.
42+
# If you'd like to generate docs for your code, you'll need to install documentation.js,
43+
# and then add your subdirectory to the docs command in package.json
44+
npm install -g documentation
4045
```
4146

4247
Note: by default the build errors on compiler warnings. To disable this do:
@@ -80,7 +85,8 @@ var module = require('./path/to/lib/index.js');
8085

8186
module.hello_async({ louder: true }, function(err, result) {
8287
if (err) throw err;
83-
console.log(hi); // => ...threads are busy async bees...world!!!!
88+
89+
console.log(result); // => "...threads are busy async bees...world!!!!""
8490
});
8591
```
8692

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test": "tape test/*.test.js",
1313
"prepublish": "npm ls",
1414
"install": "node-pre-gyp install --fallback-to-build",
15-
"docs": "npm install ^4.0.0-beta5 && documentation build src/*.cpp --polyglot -f md -o API.md"
15+
"docs": "documentation build src/*.cpp src/standalone_async/*.cpp src/standalone/*.cpp --polyglot -f md -o API.md"
1616
},
1717
"author": "Mapbox",
1818
"license": "ISC",

src/hello_world.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,13 @@ NAN_METHOD(HelloWorld::wave)
104104
*
105105
* @name shout
106106
* @memberof HelloWorld
107-
* @param {String} phrase to shout
108-
* @param {Object} different ways to shout
107+
* @param {String} string - phrase to shout
108+
* @param {Object} args - different ways to shout
109+
* @param {boolean} args.louder - adds exclamation points to the string
109110
* @param {Function} callback - from whence the shout comes, returns a string
110111
* @example
111112
* var HW = new HelloWorld();
112-
* HW.shout('rawr', {}, function(err, shout) {
113+
* HW.shout('rawr', { louder: true }, function(err, shout) {
113114
* if (err) throw err;
114115
* console.log(shout); // => 'rawr!'
115116
* });

src/standalone/hello.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#include "hello.hpp"
22

3+
/**
4+
* This is a standalone function (sync) that logs a string.
5+
* @name hello
6+
* @returns {string} "world"
7+
* @example
8+
* var module = require('./path/to/lib/index.js');
9+
* var check = module.hello();
10+
* console.log(check); // => "world"
11+
*/
312
namespace standalone {
413

514
// hello is a "standalone function" because it's not a class.

src/standalone_async/hello_async.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
#include <iostream>
66
#include <map>
77

8+
/**
9+
* This is a standalone function (async) that logs a string.
10+
* @name hello_async
11+
* @param {Object} args - different ways to alter the string
12+
* @param {boolean} args.louder - adds exclamation points to the string
13+
* @param {Function} callback - from whence the hello comes, returns a string
14+
* @returns {string} an ever-so-slightly customizable string
15+
* @example
16+
* var module = require('./path/to/lib/index.js');
17+
* module.hello_async({ louder: true }, function(err, result) {
18+
* if (err) throw err;
19+
* console.log(result); // => "...threads are busy async bees...world!!!!"
20+
* });
21+
*/
822
namespace standalone_async {
923

1024
/*

0 commit comments

Comments
 (0)