Skip to content

Commit

Permalink
docs: updated vision detect params/examples (#1500)
Browse files Browse the repository at this point in the history
* docs: updated vision detect params/examples

* updated buffer example
  • Loading branch information
callmehiphop authored and stephenplusplus committed Aug 29, 2016
1 parent 737b916 commit 353d9f2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
23 changes: 20 additions & 3 deletions packages/vision/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Vision.prototype.annotate = function(requests, callback) {
});
};

// jscs:disable maximumLineLength
/**
* Detect properties from an image (or images) of one or more types.
*
Expand All @@ -156,9 +157,10 @@ Vision.prototype.annotate = function(requests, callback) {
* For the response in the original format, review the `apiResponse` argument
* your callback receives.
*
* @param {string|string[]|module:storage/file|module:storage/file[]} images -
* The source image(s) to run the detection on. It can be either a local
* image path, a remote image URL, or a @google-cloud/storage File object.
* @param {string|string[]|buffer|buffer[]|module:storage/file|module:storage/file[]} images - The
* source image(s) to run the detection on. It can be either a local image
* path, a remote image URL, a Buffer, or a @google-cloud/storage File
* object.
* @param {string[]|object=} options - An array of types or a configuration
* object.
* @param {object=} options.imageContext - See an
Expand Down Expand Up @@ -210,6 +212,20 @@ Vision.prototype.annotate = function(requests, callback) {
* vision.detect(img, types, function(err, detection, apiResponse) {});
*
* //-
* // Run feature detection over a Buffer.
* //-
* var level = require('level');
* var db = level('./users-database');
*
* db.get('user-image', { encoding: 'binary' }, function(err, image) {
* if (err) {
* // Error handling omitted.
* }
*
* vision.detect(image, function(err, detection, apiResponse) {});
* });
*
* //-
* // Supply multiple images for feature detection.
* //-
* var images = [
Expand Down Expand Up @@ -519,6 +535,7 @@ Vision.prototype.detect = function(images, options, callback) {
});
});
};
// jscs:enable maximumLineLength

/**
* Run face detection against an image.
Expand Down
12 changes: 11 additions & 1 deletion test/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ describe('documentation', function() {
};
}

// For {module:vision} docs.
function FakeLevel() {
return {
get: function(key, options, callback) {
callback(null, 'image.jpg');
}
};
}

fileDocBlocks.methods.forEach(function(method) {
var code = method.examples.map(prop('code')).join('\n');
var lowercaseId = method.id.toLowerCase();
Expand Down Expand Up @@ -171,7 +180,8 @@ describe('documentation', function() {
/require\('(@google-cloud\/[^']*)/g,
'require(\'../packages/' + directory + '/node_modules/$1'
)
.replace('require(\'express\')', FakeExpress.toString());
.replace('require(\'express\')', FakeExpress.toString())
.replace('require(\'level\')', FakeLevel.toString());

var displayName = filename
.replace('docs/json/master/', '')
Expand Down

0 comments on commit 353d9f2

Please sign in to comment.