Skip to content

docs: updated vision detect params/examples #1500

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

Merged
merged 2 commits into from
Aug 29, 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
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

This comment was marked as spam.

This comment was marked as spam.

* 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

This comment was marked as spam.


/**
* 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