Browse Source

Merge pull request #814 from braydonf/feature/jsdocs-to-markdown

Docs: Markdown API Reference
patch-2
Esteban Ordano 10 years ago
parent
commit
6171e670a6
  1. 6
      docs/config.json
  2. 0
      docs/guide/address.md
  3. 0
      docs/guide/block.md
  4. 0
      docs/guide/crypto.md
  5. 0
      docs/guide/ecies.md
  6. 0
      docs/guide/encoding.md
  7. 0
      docs/guide/examples.md
  8. 0
      docs/guide/hierarchical.md
  9. 0
      docs/guide/index.md
  10. 0
      docs/guide/jsonrpc.md
  11. 0
      docs/guide/navigation.md
  12. 0
      docs/guide/networks.md
  13. 0
      docs/guide/paymentprotocol.md
  14. 0
      docs/guide/peer.md
  15. 0
      docs/guide/pool.md
  16. 0
      docs/guide/privatekey.md
  17. 0
      docs/guide/publickey.md
  18. 0
      docs/guide/script.md
  19. 0
      docs/guide/transaction.md
  20. 0
      docs/guide/unit.md
  21. 0
      docs/guide/uri.md
  22. 32
      gulpfile.js
  23. 6
      lib/address.js
  24. 2
      lib/hdprivatekey.js
  25. 2
      lib/hdpublickey.js
  26. 2
      lib/privatekey.js
  27. 2
      lib/publickey.js
  28. 2
      lib/transaction/transaction.js
  29. 2
      lib/transport/peer.js
  30. 2
      lib/transport/pool.js
  31. 2
      lib/transport/rpc.js
  32. 2
      lib/unit.js
  33. 4
      lib/uri.js
  34. 7
      package.json

6
docs/config.json

@ -1,6 +0,0 @@
{
"useSideMenu": true,
"lineBreaks": "gfm",
"additionalFooterText": "Bitcore™ © 2013-2014 BitPay, Inc. Bitcore is released under the MIT license. ",
"anchorCharacter": "#"
}

0
docs/models/Address.md → docs/guide/address.md

0
docs/models/Block.md → docs/guide/block.md

0
docs/helpers/Crypto.md → docs/guide/crypto.md

0
docs/helpers/ECIES.md → docs/guide/ecies.md

0
docs/helpers/Encoding.md → docs/guide/encoding.md

0
docs/examples.md → docs/guide/examples.md

0
docs/models/Hierarchical.md → docs/guide/hierarchical.md

0
docs/index.md → docs/guide/index.md

0
docs/networking/JSONRPC.md → docs/guide/jsonrpc.md

0
docs/navigation.md → docs/guide/navigation.md

0
docs/helpers/Networks.md → docs/guide/networks.md

0
docs/helpers/PaymentProtocol.md → docs/guide/paymentprotocol.md

0
docs/networking/Peer.md → docs/guide/peer.md

0
docs/networking/Pool.md → docs/guide/pool.md

0
docs/models/PrivateKey.md → docs/guide/privatekey.md

0
docs/models/PublicKey.md → docs/guide/publickey.md

0
docs/models/Script.md → docs/guide/script.md

0
docs/models/Transaction.md → docs/guide/transaction.md

0
docs/helpers/Unit.md → docs/guide/unit.md

0
docs/helpers/URI.md → docs/guide/uri.md

32
gulpfile.js

@ -37,7 +37,10 @@ var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha'); var mocha = require('gulp-mocha');
var runSequence = require('run-sequence'); var runSequence = require('run-sequence');
var shell = require('gulp-shell'); var shell = require('gulp-shell');
var through = require('through2');
var gutil = require('gulp-util');
var jsdoc2md = require('jsdoc-to-markdown');
var mfs = require('more-fs');
var files = ['lib/**/*.js']; var files = ['lib/**/*.js'];
var tests = ['test/**/*.js']; var tests = ['test/**/*.js'];
@ -126,7 +129,32 @@ gulp.task('lint', function() {
gulp.task('plato', shell.task(['plato -d report -r -l .jshintrc -t bitcore lib'])); gulp.task('plato', shell.task(['plato -d report -r -l .jshintrc -t bitcore lib']));
gulp.task('jsdoc', shell.task(['jsdoc -c .jsdoc.conf lib'])); gulp.task('jsdoc', function() {
function jsdoc() {
return through.obj(function(file, enc, cb) {
if (file.isNull()){
cb(null, file);
return;
}
if (file.isStream()) {
cb(new gutil.PluginError('gulp-jsdoc2md', 'Streaming not supported'));
return;
}
var destination = 'docs/api/'+file.path.replace(file.base, '').replace(/\.js$/, '.md');
jsdoc2md.render(file.path, {})
.on('error', function(err) {
gutil.log(gutil.colors.red('jsdoc2md failed', err.message));
})
.pipe(mfs.writeStream(destination));
cb(null, file);
});
}
return gulp.src(files).pipe(jsdoc());
});
gulp.task('coverage', shell.task(['node_modules/.bin/./istanbul cover node_modules/.bin/_mocha -- --recursive'])); gulp.task('coverage', shell.task(['node_modules/.bin/./istanbul cover node_modules/.bin/_mocha -- --recursive']));

6
lib/address.js

@ -19,6 +19,7 @@ var JSUtil = require('./util/js');
* or `Address.PayToScriptHash` (the string `'scripthash'`). The network is an instance of {@link Network}. * or `Address.PayToScriptHash` (the string `'scripthash'`). The network is an instance of {@link Network}.
* *
* @example * @example
* ```javascript
* // validate that an input field is valid * // validate that an input field is valid
* var error = Address.getValidationError(input, 'testnet'); * var error = Address.getValidationError(input, 'testnet');
* if (!error) { * if (!error) {
@ -30,6 +31,7 @@ var JSUtil = require('./util/js');
* *
* // get an address from a public key * // get an address from a public key
* var address = Address(publicKey, 'testnet').toString(); * var address = Address(publicKey, 'testnet').toString();
* ```
* *
* @param {*} data - The encoded data in various formats * @param {*} data - The encoded data in various formats
* @param {Network|String|number} [network] - The network: 'livenet' or 'testnet' * @param {Network|String|number} [network] - The network: 'livenet' or 'testnet'
@ -358,9 +360,11 @@ Address.fromJSON = function fromJSON(json) {
* Will return a validation error if exists * Will return a validation error if exists
* *
* @example * @example
* ```javascript
* *
* var error = Address.getValidationError('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'testnet'); * var error = Address.getValidationError('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'testnet');
* // a network mismatch error * // a network mismatch error
* ```
* *
* @param {String} data - The encoded data * @param {String} data - The encoded data
* @param {String} network - The network: 'livenet' or 'testnet' * @param {String} network - The network: 'livenet' or 'testnet'
@ -381,9 +385,11 @@ Address.getValidationError = function(data, network, type) {
* Will return a boolean if an address is valid * Will return a boolean if an address is valid
* *
* @example * @example
* ```javascript
* *
* var valid = Address.isValid('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'livenet'); * var valid = Address.isValid('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'livenet');
* // true * // true
* ```
* *
* @param {String} data - The encoded data * @param {String} data - The encoded data
* @param {String} network - The network: 'livenet' or 'testnet' * @param {String} network - The network: 'livenet' or 'testnet'

2
lib/hdprivatekey.js

@ -75,10 +75,12 @@ function HDPrivateKey(arg) {
* derived. See the example usage for clarification. * derived. See the example usage for clarification.
* *
* @example * @example
* ```javascript
* var parent = new HDPrivateKey('xprv...'); * var parent = new HDPrivateKey('xprv...');
* var child_0_1_2h = parent.derive(0).derive(1).derive(2, true); * var child_0_1_2h = parent.derive(0).derive(1).derive(2, true);
* var copy_of_child_0_1_2h = parent.derive("m/0/1/2'"); * var copy_of_child_0_1_2h = parent.derive("m/0/1/2'");
* assert(child_0_1_2h.xprivkey === copy_of_child_0_1_2h); * assert(child_0_1_2h.xprivkey === copy_of_child_0_1_2h);
* ```
* *
* @param {string|number} arg * @param {string|number} arg
* @param {boolean?} hardened * @param {boolean?} hardened

2
lib/hdpublickey.js

@ -78,10 +78,12 @@ function HDPublicKey(arg) {
* derived. See the example usage for clarification. * derived. See the example usage for clarification.
* *
* @example * @example
* ```javascript
* var parent = new HDPublicKey('xpub...'); * var parent = new HDPublicKey('xpub...');
* var child_0_1_2 = parent.derive(0).derive(1).derive(2); * var child_0_1_2 = parent.derive(0).derive(1).derive(2);
* var copy_of_child_0_1_2 = parent.derive("m/0/1/2"); * var copy_of_child_0_1_2 = parent.derive("m/0/1/2");
* assert(child_0_1_2.xprivkey === copy_of_child_0_1_2); * assert(child_0_1_2.xprivkey === copy_of_child_0_1_2);
* ```
* *
* @param {string|number} arg * @param {string|number} arg
* @param {boolean?} hardened * @param {boolean?} hardened

2
lib/privatekey.js

@ -14,6 +14,7 @@ var Random = require('./crypto/random');
* Instantiate a PrivateKey from a BN, Buffer and WIF. * Instantiate a PrivateKey from a BN, Buffer and WIF.
* *
* @example * @example
* ```javascript
* *
* // generate a new random key * // generate a new random key
* var key = PrivateKey(); * var key = PrivateKey();
@ -26,6 +27,7 @@ var Random = require('./crypto/random');
* *
* // instantiate from the exported (and saved) private key * // instantiate from the exported (and saved) private key
* var imported = PrivateKey.fromWIF(exported); * var imported = PrivateKey.fromWIF(exported);
* ```
* *
* @param {String} data - The encoded data in various formats * @param {String} data - The encoded data in various formats
* @param {String} [network] - Either "livenet" or "testnet" * @param {String} [network] - Either "livenet" or "testnet"

2
lib/publickey.js

@ -12,6 +12,7 @@ var $ = require('./util/preconditions');
* Instantiate a PublicKey from a 'PrivateKey', 'Point', 'string', 'Buffer'. * Instantiate a PublicKey from a 'PrivateKey', 'Point', 'string', 'Buffer'.
* *
* @example * @example
* ```javascript
* *
* // instantiate from a private key * // instantiate from a private key
* var key = PublicKey(privateKey, true); * var key = PublicKey(privateKey, true);
@ -21,6 +22,7 @@ var $ = require('./util/preconditions');
* *
* // import the public key * // import the public key
* var imported = PublicKey.fromString(exported); * var imported = PublicKey.fromString(exported);
* ```
* *
* @param {String} data - The encoded data in various formats * @param {String} data - The encoded data in various formats
* @param {Object} extra - additional options * @param {Object} extra - additional options

2
lib/transaction/transaction.js

@ -224,6 +224,7 @@ Transaction.prototype._newTransaction = function() {
* SIGHASH_SINGLE or SIGHASH_NONE signatures will not be reset). * SIGHASH_SINGLE or SIGHASH_NONE signatures will not be reset).
* *
* @example * @example
* ```javascript
* var transaction = new Transaction(); * var transaction = new Transaction();
* *
* // From a pay to public key hash output from bitcoind's listunspent * // From a pay to public key hash output from bitcoind's listunspent
@ -235,6 +236,7 @@ Transaction.prototype._newTransaction = function() {
* // From a multisig P2SH output * // From a multisig P2SH output
* transaction.from({'txId': '0000...', inputIndex: 0, satoshis: 1000, script: '... OP_HASH'}, * transaction.from({'txId': '0000...', inputIndex: 0, satoshis: 1000, script: '... OP_HASH'},
* ['03000...', '02000...'], 2); * ['03000...', '02000...'], 2);
* ```
* *
* @param {Object} utxo * @param {Object} utxo
* @param {Array=} pubkeys * @param {Array=} pubkeys

2
lib/transport/peer.js

@ -16,12 +16,14 @@ var MAX_RECEIVE_BUFFER = 10000000;
* with it using the standar messages of the bitcoin p2p protocol. * with it using the standar messages of the bitcoin p2p protocol.
* *
* @example * @example
* ```javascript
* *
* var peer = new Peer('127.0.0.1').setProxy('127.0.0.1', 9050); * var peer = new Peer('127.0.0.1').setProxy('127.0.0.1', 9050);
* peer.on('tx', function(tx) { * peer.on('tx', function(tx) {
* console.log('New transaction: ', tx.id); * console.log('New transaction: ', tx.id);
* }); * });
* peer.connect(); * peer.connect();
* ```
* *
* @param {String} host - IP address of the remote host * @param {String} host - IP address of the remote host
* @param {Number} [port] - Port number of the remote host * @param {Number} [port] - Port number of the remote host

2
lib/transport/pool.js

@ -18,12 +18,14 @@ function now() {
* ongoing peer connections. Peer events are relayed to the pool. * ongoing peer connections. Peer events are relayed to the pool.
* *
* @example * @example
* ```javascript
* *
* var pool = new Pool(Networks.livenet); * var pool = new Pool(Networks.livenet);
* pool.on('peerinv', function(peer, message) { * pool.on('peerinv', function(peer, message) {
* // do something with the inventory announcement * // do something with the inventory announcement
* }); * });
* pool.connect(); * pool.connect();
* ```
* *
* @param {Network|String} network - The network to connect * @param {Network|String} network - The network to connect
* @returns {Pool} * @returns {Pool}

2
lib/transport/rpc.js

@ -8,11 +8,13 @@ var https = require('https');
* server and enables simple and batch RPC calls. * server and enables simple and batch RPC calls.
* *
* @example * @example
* ```javascript
* *
* var client = new RPC('user', 'pass'); * var client = new RPC('user', 'pass');
* client.getInfo(function(err, info) { * client.getInfo(function(err, info) {
* // do something with the info * // do something with the info
* }); * });
* ```
* *
* @param {String} user - username used to connect bitcoind * @param {String} user - username used to connect bitcoind
* @param {String} password - password used to connect bitcoind * @param {String} password - password used to connect bitcoind

2
lib/unit.js

@ -14,10 +14,12 @@ var JSUtil = require('./util/js');
* the unit accessors. * the unit accessors.
* *
* @example * @example
* ```javascript
* *
* var sats = Unit.fromBTC(1.3).toSatoshis(); * var sats = Unit.fromBTC(1.3).toSatoshis();
* var mili = Unit.fromBits(1.3).to(Unit.mBTC); * var mili = Unit.fromBits(1.3).to(Unit.mBTC);
* var btc = new Unit(1.3, Unit.bits).BTC; * var btc = new Unit(1.3, Unit.bits).BTC;
* ```
* *
* @param {Number} amount - The amount to be represented * @param {Number} amount - The amount to be represented
* @param {String} code - The unit of the amount * @param {String} code - The unit of the amount

4
lib/uri.js

@ -19,9 +19,11 @@ var JSUtil = require('./util/js');
* satoshis. Any other non-standard parameters can be found under the extra member. * satoshis. Any other non-standard parameters can be found under the extra member.
* *
* @example * @example
* ```javascript
* *
* var uri = new URI('bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2'); * var uri = new URI('bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2');
* console.log(uri.address, uri.amount); * console.log(uri.address, uri.amount);
* ```
* *
* @param {string|Object} data - A bitcoin URI string or an Object * @param {string|Object} data - A bitcoin URI string or an Object
* @param {Array.<string>} [knownParams] - Required non-standard params * @param {Array.<string>} [knownParams] - Required non-standard params
@ -79,9 +81,11 @@ URI.fromJSON = function fromJSON(json) {
* Check if an bitcoin URI string is valid * Check if an bitcoin URI string is valid
* *
* @example * @example
* ```javascript
* *
* var valid = URI.isValid('bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu'); * var valid = URI.isValid('bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu');
* // true * // true
* ```
* *
* @param {string|Object} data - A bitcoin URI string or an Object * @param {string|Object} data - A bitcoin URI string or an Object
* @param {Array.<string>} [knownParams] - Required non-standard params * @param {Array.<string>} [knownParams] - Required non-standard params

7
package.json

@ -95,18 +95,21 @@
"gulp": "^3.8.10", "gulp": "^3.8.10",
"gulp-closure-compiler": "^0.2.9", "gulp-closure-compiler": "^0.2.9",
"gulp-coveralls": "^0.1.3", "gulp-coveralls": "^0.1.3",
"gulp-jsdoc": "^0.1.4",
"gulp-jshint": "^1.9.0", "gulp-jshint": "^1.9.0",
"gulp-mocha": "^2.0.0", "gulp-mocha": "^2.0.0",
"gulp-shell": "^0.2.10", "gulp-shell": "^0.2.10",
"gulp-util": "=3.0.1",
"ink-docstrap": "git://github.com/bitpay/bitcore-jsdoctemplates.git", "ink-docstrap": "git://github.com/bitpay/bitcore-jsdoctemplates.git",
"istanbul": "^0.3.5", "istanbul": "^0.3.5",
"jsdoc-to-markdown": "=0.5.9",
"karma": "^0.12.28", "karma": "^0.12.28",
"karma-firefox-launcher": "^0.1.3", "karma-firefox-launcher": "^0.1.3",
"karma-mocha": "^0.1.9", "karma-mocha": "^0.1.9",
"mocha": "~2.0.1", "mocha": "~2.0.1",
"more-fs": "=0.5.0",
"run-sequence": "^1.0.2", "run-sequence": "^1.0.2",
"sinon": "^1.12.2" "sinon": "^1.12.2",
"through2": "=0.6.3"
}, },
"license": "MIT" "license": "MIT"
} }

Loading…
Cancel
Save