diff --git a/API.md b/API.md
new file mode 100644
index 000000000..4de2a8421
--- /dev/null
+++ b/API.md
@@ -0,0 +1,35 @@
+
+
+
+## IpfsAPI
+**Kind**: global class
+
+* [IpfsAPI](#IpfsAPI)
+ * [new IpfsAPI(host_or_multiaddr, port)](#new_IpfsAPI_new)
+ * [.add(files, opts, cb)](#IpfsAPI+add)
+
+
+### new IpfsAPI(host_or_multiaddr, port)
+Create a ipfs api
+
+
+| Param | Type |
+| --- | --- |
+| host_or_multiaddr | string
|
+| port | number
|
+
+
+### ipfsAPI.add(files, opts, cb)
+Add a file/many files to IPFS returning the hash and name. The
+name value will only be set if you are actually sending a file.
+
+**Kind**: instance method of [IpfsAPI](#IpfsAPI)
+**Access:** public
+
+| Param | Type |
+| --- | --- |
+| files | |
+| opts | object
|
+| cb | function
|
+
+
diff --git a/package.json b/package.json
index 51bba7808..10be4aa12 100644
--- a/package.json
+++ b/package.json
@@ -32,7 +32,10 @@
"eslint-config-standard": "^4.4.0",
"eslint-plugin-standard": "^1.3.1",
"gulp": "^3.9.0",
+ "gulp-concat": "^2.6.0",
"gulp-eslint": "^1.0.0",
+ "gulp-gh-pages": "^0.5.4",
+ "gulp-jsdoc-to-markdown": "^1.1.1",
"gulp-load-plugins": "^1.0.0",
"gulp-mocha": "^2.1.3",
"gulp-size": "^2.0.0",
diff --git a/src/index.js b/src/index.js
index f13ed9efd..a805ce5ad 100644
--- a/src/index.js
+++ b/src/index.js
@@ -6,8 +6,14 @@ const getRequestAPI = require('./request-api')
const Wreck = require('wreck')
const ndjson = require('ndjson')
-exports = module.exports = IpfsAPI
-
+module.exports = IpfsAPI
+
+/**
+ * Create a ipfs api
+ * @constructor
+ * @param {string} host_or_multiaddr
+ * @param {number} port
+ */
function IpfsAPI (host_or_multiaddr, port) {
const self = this
const config = getConfig()
@@ -35,8 +41,7 @@ function IpfsAPI (host_or_multiaddr, port) {
const requestAPI = getRequestAPI(config)
- // -- Internal
-
+ /** @private */
function command (name) {
return (opts, cb) => {
if (typeof (opts) === 'function') {
@@ -47,6 +52,7 @@ function IpfsAPI (host_or_multiaddr, port) {
}
}
+ /** @private */
function argCommand (name) {
return (arg, opts, cb) => {
if (typeof (opts) === 'function') {
@@ -59,9 +65,19 @@ function IpfsAPI (host_or_multiaddr, port) {
// -- Interface
+ /** @public */
self.send = requestAPI
- self.add = (files, opts, cb) => {
+ /**
+ * Add a file/many files to IPFS returning the hash and name. The
+ * name value will only be set if you are actually sending a file.
+ *
+ * @public
+ * @param {} files
+ * @param {object} opts
+ * @param {function} cb
+ */
+ this.add = (files, opts, cb) => {
if (typeof (opts) === 'function' && cb === undefined) {
cb = opts
opts = {}
diff --git a/tasks/docs.js b/tasks/docs.js
new file mode 100644
index 000000000..2941dcece
--- /dev/null
+++ b/tasks/docs.js
@@ -0,0 +1,15 @@
+'use strict'
+
+const gulp = require('gulp')
+const $ = require('gulp-load-plugins')()
+
+
+gulp.task('docs', () => {
+ return gulp.src('src/*.js')
+ .pipe($.jsdocToMarkdown())
+ .pipe($.concat('API.md'))
+ .on('error', err => {
+ $.util.log($.util.colors.red('jsdoc2md failed'), err.message)
+ })
+ .pipe(gulp.dest('.'))
+})