Skip to content

Commit 672b91c

Browse files
stephenpluspluscallmehiphop
authored andcommitted
docs: generate uniform service overviews (#1475)
1 parent e5bf912 commit 672b91c

File tree

5 files changed

+45
-62
lines changed

5 files changed

+45
-62
lines changed

src/index.js

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,11 @@ var Transaction = require('./transaction.js');
5252
var PKG = require('../package.json');
5353

5454
/**
55-
* Interact with the
56-
* [Google Cloud Datastore](https://developers.google.com/datastore/).
57-
*
5855
* @constructor
5956
* @alias module:datastore
6057
* @mixes module:datastore/request
6158
*
62-
* @classdesc
63-
* The `gcloud.datastore` object allows you to interact with Google Cloud
64-
* Datastore.
65-
*
66-
* To learn more about Datastore, read the
67-
* [Google Cloud Datastore Concepts Overview](https://cloud.google.com/datastore/docs/concepts/overview)
59+
* @resource [Google Cloud Datastore Concepts Overview]{@link https://cloud.google.com/datastore/docs/concepts/overview}
6860
*
6961
* @param {object=} options - [Configuration object](#/docs).
7062
* @param {string=} options.apiEndpoint - Override the default API endpoint used
@@ -73,13 +65,6 @@ var PKG = require('../package.json');
7365
* @param {string} options.namespace - Namespace to isolate transactions to.
7466
*
7567
* @example
76-
* var gcloud = require('google-cloud')({
77-
* projectId: 'grape-spaceship-123',
78-
* keyFilename: '/path/to/keyfile.json'
79-
* });
80-
*
81-
* var datastore = gcloud.datastore();
82-
*
8368
* //-
8469
* // <h3>The Datastore Emulator</h3>
8570
* //
@@ -107,12 +92,7 @@ var PKG = require('../package.json');
10792
* // Set that environment variable and your localhost Datastore will
10893
* // automatically be used. You can also pass this address in manually with
10994
* // `apiEndpoint`.
110-
* //-
111-
* var datastore = gcloud.datastore({
112-
* apiEndpoint: 'http://localhost:8080'
113-
* });
114-
*
115-
* //-
95+
* //
11696
* // Additionally, `DATASTORE_PROJECT_ID` is recognized. If you have this set,
11797
* // you don't need to provide a `projectId`.
11898
* //-
@@ -213,7 +193,7 @@ var PKG = require('../package.json');
213193
* };
214194
*
215195
* // Check if more results may exist.
216-
* if (info.moreResults !== gcloud.datastore.NO_MORE_RESULTS) {
196+
* if (info.moreResults !== datastore.NO_MORE_RESULTS) {
217197
* frontEndResponse.nextPageCursor = info.endCursor;
218198
* }
219199
*
@@ -360,9 +340,9 @@ modelo.inherits(Datastore, DatastoreRequest, common.GrpcService);
360340
* @return {object}
361341
*
362342
* @example
363-
* var threeDouble = gcloud.datastore.double(3.0);
343+
* var threeDouble = datastore.double(3.0);
364344
*/
365-
Datastore.double = function(value) {
345+
Datastore.prototype.double = Datastore.double = function(value) {
366346
return new entity.Double(value);
367347
};
368348

@@ -380,9 +360,9 @@ Datastore.double = function(value) {
380360
* longitude: -74.0447
381361
* };
382362
*
383-
* var geoPoint = gcloud.datastore.geoPoint(coordinates);
363+
* var geoPoint = datastore.geoPoint(coordinates);
384364
*/
385-
Datastore.geoPoint = function(coordindates) {
365+
Datastore.prototype.geoPoint = Datastore.geoPoint = function(coordindates) {
386366
return new entity.GeoPoint(coordindates);
387367
};
388368

@@ -393,9 +373,9 @@ Datastore.geoPoint = function(coordindates) {
393373
* @return {object}
394374
*
395375
* @example
396-
* var sevenInteger = gcloud.datastore.int(7);
376+
* var sevenInteger = datastore.int(7);
397377
*/
398-
Datastore.int = function(value) {
378+
Datastore.prototype.int = Datastore.int = function(value) {
399379
return new entity.Int(value);
400380
};
401381

@@ -408,6 +388,7 @@ Datastore.int = function(value) {
408388
*
409389
* @type {string}
410390
*/
391+
Datastore.prototype.MORE_RESULTS_AFTER_CURSOR =
411392
Datastore.MORE_RESULTS_AFTER_CURSOR = 'MORE_RESULTS_AFTER_CURSOR';
412393

413394
/**
@@ -419,6 +400,7 @@ Datastore.MORE_RESULTS_AFTER_CURSOR = 'MORE_RESULTS_AFTER_CURSOR';
419400
*
420401
* @type {string}
421402
*/
403+
Datastore.prototype.MORE_RESULTS_AFTER_LIMIT =
422404
Datastore.MORE_RESULTS_AFTER_LIMIT = 'MORE_RESULTS_AFTER_LIMIT';
423405

424406
/**
@@ -430,6 +412,7 @@ Datastore.MORE_RESULTS_AFTER_LIMIT = 'MORE_RESULTS_AFTER_LIMIT';
430412
*
431413
* @type {string}
432414
*/
415+
Datastore.prototype.NO_MORE_RESULTS =
433416
Datastore.NO_MORE_RESULTS = 'NO_MORE_RESULTS';
434417

435418
/**

src/query.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ var arrify = require('arrify');
4242
* @param {string} kind - Kind to query.
4343
*
4444
* @example
45-
* var gcloud = require('google-cloud')({
46-
* keyFilename: '/path/to/keyfile.json',
47-
* projectId: 'grape-spaceship-123'
48-
* });
49-
*
50-
* var datastore = gcloud.datastore();
5145
* var query = datastore.createQuery('AnimalNamespace', 'Lion');
5246
*/
5347
function Query(scope, namespace, kinds) {

src/request.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ var CONSISTENCY_PROTO_CODE = {
5757
*
5858
* Creates requests to the Datastore endpoint. Designed to be inherited by
5959
* {module:datastore} and {module:datastore/transaction} objects.
60-
*
61-
* @example
62-
* // This is how to create a transaction object directly using this Transaction
63-
* // class. The following transaction object is created for use in the examples
64-
* // in this file below.
65-
* var datastore = gcloud.datastore({ projectId: 'project-id' });
66-
* var Transaction = require('gcloud/lib/datastore/transaction');
67-
* var transaction = new Transaction(datastore, 'my-project-id');
68-
* transaction.id = '1234'; // Give the transaction an ID.
6960
*/
7061
/**
7162
* Handle logic for Datastore API operations.
@@ -717,9 +708,9 @@ DatastoreRequest.prototype.runQuery = function(query, options, callback) {
717708
* key: key,
718709
* data: {
719710
* name: 'DonutShack',
720-
* rating: gcloud.datastore.int(10),
721-
* worth: gcloud.datastore.double(123456.78),
722-
* location: gcloud.datastore.geoPoint({
711+
* rating: datastore.int(10),
712+
* worth: datastore.double(123456.78),
713+
* location: datastore.geoPoint({
723714
* latitude: 40.6894,
724715
* longitude: -74.0447
725716
* }),

src/transaction.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ var Request = require('./request.js');
3535
/*! Developer Documentation
3636
*
3737
* @param {module:datastore} datastore - A Datastore instance.
38-
*
39-
* @example
40-
* // This is how to create a transaction object directly using this Transaction
41-
* // class. The following transaction object is created for use in the examples
42-
* // in this file below.
43-
* var Transaction = gcloud.datastore.Transaction;
44-
* var datastore = gcloud.datastore({ projectId: 'project-id' });
45-
* var transaction = new Transaction(datastore, 'my-project-id');
46-
* transaction.id = '1234'; // Give the transaction an ID.
4738
*/
4839
/**
4940
* A transaction is a set of Datastore operations on one or more entities. Each
@@ -58,12 +49,6 @@ var Request = require('./request.js');
5849
* @mixes module:datastore/request
5950
*
6051
* @example
61-
* var gcloud = require('google-cloud');
62-
* var datastore = gcloud.datastore({
63-
* projectId: 'my-project',
64-
* keyFilename: '/path/to/keyfile.json'
65-
* });
66-
*
6752
* var transaction = datastore.transaction();
6853
*/
6954
function Transaction(datastore) {

test/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ describe('Datastore', function() {
167167
var double = Datastore.double(aDouble);
168168
assert.strictEqual(double.value, aDouble);
169169
});
170+
171+
it('should also be on the prototype', function() {
172+
assert.strictEqual(datastore.double, Datastore.double);
173+
});
170174
});
171175

172176
describe('geoPoint', function() {
@@ -175,6 +179,10 @@ describe('Datastore', function() {
175179
var geoPoint = Datastore.geoPoint(aGeoPoint);
176180
assert.strictEqual(geoPoint.value, aGeoPoint);
177181
});
182+
183+
it('should also be on the prototype', function() {
184+
assert.strictEqual(datastore.geoPoint, Datastore.geoPoint);
185+
});
178186
});
179187

180188
describe('int', function() {
@@ -183,6 +191,10 @@ describe('Datastore', function() {
183191
var int = Datastore.int(anInt);
184192
assert.strictEqual(int.value, anInt);
185193
});
194+
195+
it('should also be on the prototype', function() {
196+
assert.strictEqual(datastore.int, Datastore.int);
197+
});
186198
});
187199

188200
describe('MORE_RESULTS_AFTER_CURSOR', function() {
@@ -192,6 +204,13 @@ describe('Datastore', function() {
192204
'MORE_RESULTS_AFTER_CURSOR'
193205
);
194206
});
207+
208+
it('should also be on the prototype', function() {
209+
assert.strictEqual(
210+
datastore.MORE_RESULTS_AFTER_CURSOR,
211+
Datastore.MORE_RESULTS_AFTER_CURSOR
212+
);
213+
});
195214
});
196215

197216
describe('MORE_RESULTS_AFTER_LIMIT', function() {
@@ -201,12 +220,23 @@ describe('Datastore', function() {
201220
'MORE_RESULTS_AFTER_LIMIT'
202221
);
203222
});
223+
224+
it('should also be on the prototype', function() {
225+
assert.strictEqual(
226+
datastore.MORE_RESULTS_AFTER_LIMIT,
227+
Datastore.MORE_RESULTS_AFTER_LIMIT
228+
);
229+
});
204230
});
205231

206232
describe('NO_MORE_RESULTS', function() {
207233
it('should expose a NO_MORE_RESULTS helper', function() {
208234
assert.strictEqual(Datastore.NO_MORE_RESULTS, 'NO_MORE_RESULTS');
209235
});
236+
237+
it('should also be on the prototype', function() {
238+
assert.strictEqual(datastore.NO_MORE_RESULTS, Datastore.NO_MORE_RESULTS);
239+
});
210240
});
211241

212242
describe('createQuery', function() {

0 commit comments

Comments
 (0)