Skip to content

Commit 353d9f2

Browse files
callmehiphopstephenplusplus
authored andcommitted
docs: updated vision detect params/examples (#1500)
* docs: updated vision detect params/examples * updated buffer example
1 parent 737b916 commit 353d9f2

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

packages/vision/src/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ Vision.prototype.annotate = function(requests, callback) {
133133
});
134134
};
135135

136+
// jscs:disable maximumLineLength
136137
/**
137138
* Detect properties from an image (or images) of one or more types.
138139
*
@@ -156,9 +157,10 @@ Vision.prototype.annotate = function(requests, callback) {
156157
* For the response in the original format, review the `apiResponse` argument
157158
* your callback receives.
158159
*
159-
* @param {string|string[]|module:storage/file|module:storage/file[]} images -
160-
* The source image(s) to run the detection on. It can be either a local
161-
* image path, a remote image URL, or a @google-cloud/storage File object.
160+
* @param {string|string[]|buffer|buffer[]|module:storage/file|module:storage/file[]} images - The
161+
* source image(s) to run the detection on. It can be either a local image
162+
* path, a remote image URL, a Buffer, or a @google-cloud/storage File
163+
* object.
162164
* @param {string[]|object=} options - An array of types or a configuration
163165
* object.
164166
* @param {object=} options.imageContext - See an
@@ -210,6 +212,20 @@ Vision.prototype.annotate = function(requests, callback) {
210212
* vision.detect(img, types, function(err, detection, apiResponse) {});
211213
*
212214
* //-
215+
* // Run feature detection over a Buffer.
216+
* //-
217+
* var level = require('level');
218+
* var db = level('./users-database');
219+
*
220+
* db.get('user-image', { encoding: 'binary' }, function(err, image) {
221+
* if (err) {
222+
* // Error handling omitted.
223+
* }
224+
*
225+
* vision.detect(image, function(err, detection, apiResponse) {});
226+
* });
227+
*
228+
* //-
213229
* // Supply multiple images for feature detection.
214230
* //-
215231
* var images = [
@@ -519,6 +535,7 @@ Vision.prototype.detect = function(images, options, callback) {
519535
});
520536
});
521537
};
538+
// jscs:enable maximumLineLength
522539

523540
/**
524541
* Run face detection against an image.

test/docs.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ describe('documentation', function() {
135135
};
136136
}
137137

138+
// For {module:vision} docs.
139+
function FakeLevel() {
140+
return {
141+
get: function(key, options, callback) {
142+
callback(null, 'image.jpg');
143+
}
144+
};
145+
}
146+
138147
fileDocBlocks.methods.forEach(function(method) {
139148
var code = method.examples.map(prop('code')).join('\n');
140149
var lowercaseId = method.id.toLowerCase();
@@ -171,7 +180,8 @@ describe('documentation', function() {
171180
/require\('(@google-cloud\/[^']*)/g,
172181
'require(\'../packages/' + directory + '/node_modules/$1'
173182
)
174-
.replace('require(\'express\')', FakeExpress.toString());
183+
.replace('require(\'express\')', FakeExpress.toString())
184+
.replace('require(\'level\')', FakeLevel.toString());
175185

176186
var displayName = filename
177187
.replace('docs/json/master/', '')

0 commit comments

Comments
 (0)