Skip to content

Commit a209282

Browse files
authored
Fixes jsdoc generation, adds jsdoc support (#512)
* Fixes jsdoc generation, adds jsdoc support * Better jsdoc config * fixup! Better jsdoc config * Adds better return types on some objects * Update .travis.yml
1 parent 942305a commit a209282

27 files changed

+368
-343
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ integration/test_logs
99
.DS_Store
1010
.idea/
1111
integration/test_logs
12+
out/
1213

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
language: node_js
33
node_js:
4-
- '5'
4+
- '6.11.4'
55

66
branches:
77
only:

jsdoc-conf.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"plugins": ["node_modules/jsdoc-babel"],
3+
"babel": {
4+
"plugins": ["transform-flow-strip-types"]
5+
},
6+
"source": {
7+
"include": ["./package.json", "./README.md"],
8+
"excludePattern": "(^|\\/|\\\\)_"
9+
},
10+
"templates": {
11+
"default": {
12+
"outputSourceFiles": false
13+
},
14+
"cleverLinks": false,
15+
"monospaceLinks": false
16+
},
17+
"opts": {
18+
"recurse": true
19+
}
20+
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@
5353
"gulp-uglify": "^2.1.2",
5454
"jasmine-reporters": "~2.2.1",
5555
"jest-cli": "^19.0.2",
56+
"jsdoc": "^3.5.5",
57+
"jsdoc-babel": "^0.3.0",
5658
"vinyl-source-stream": "^1.1.0"
5759
},
5860
"scripts": {
5961
"build": "./build_releases.sh",
6062
"release": "./build_releases.sh && npm publish",
61-
"test": "PARSE_BUILD=node jest"
63+
"test": "PARSE_BUILD=node jest",
64+
"docs": "jsdoc -c ./jsdoc-conf.json ./src"
6265
},
6366
"jest": {
6467
"automock": true,

src/Analytics.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type ParsePromise from './ParsePromise';
1919
*
2020
* @class Parse.Analytics
2121
* @static
22+
* @hideconstructor
2223
*/
2324

2425
/**
@@ -44,6 +45,7 @@ import type ParsePromise from './ParsePromise';
4445
* There is a default limit of 8 dimensions per event tracked.
4546
*
4647
* @method track
48+
* @name Parse.Analytics.track
4749
* @param {String} name The name of the custom event to report to Parse as
4850
* having happened.
4951
* @param {Object} dimensions The dictionary of information by which to

src/Cloud.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ import ParsePromise from './ParsePromise';
2424
*
2525
* @class Parse.Cloud
2626
* @static
27+
* @hideconstructor
2728
*/
2829

2930
/**
3031
* Makes a call to a cloud function.
3132
* @method run
33+
* @name Parse.Cloud.run
3234
* @param {String} name The function name.
3335
* @param {Object} data The parameters to send to the cloud function.
3436
* @param {Object} options A Backbone-style options object

src/CoreManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2015-present, Parse, LLC.
33
* All rights reserved.
44
*

src/FacebookUtils.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ var provider = {
9393
* Provides a set of utilities for using Parse with Facebook.
9494
* @class Parse.FacebookUtils
9595
* @static
96+
* @hideconstructor
9697
*/
9798
var FacebookUtils = {
9899
/**
@@ -105,6 +106,7 @@ var FacebookUtils = {
105106
* with these arguments.
106107
*
107108
* @method init
109+
* @name Parse.FacebookUtils.init
108110
* @param {Object} options Facebook options argument as described here:
109111
* <a href=
110112
* "https://developers.facebook.com/docs/reference/javascript/FB.init/">
@@ -141,6 +143,7 @@ var FacebookUtils = {
141143
* Gets whether the user has their account linked to Facebook.
142144
*
143145
* @method isLinked
146+
* @name Parse.FacebookUtils.isLinked
144147
* @param {Parse.User} user User to check for a facebook link.
145148
* The user must be logged in on this device.
146149
* @return {Boolean} <code>true</code> if the user has their account
@@ -156,13 +159,15 @@ var FacebookUtils = {
156159
* creates, in the case where it is a new user) a Parse.User.
157160
*
158161
* @method logIn
159-
* @param {String, Object} permissions The permissions required for Facebook
162+
* @name Parse.FacebookUtils.logIn
163+
* @param {(String|Object)} permissions The permissions required for Facebook
160164
* log in. This is a comma-separated string of permissions.
161165
* Alternatively, supply a Facebook authData object as described in our
162166
* REST API docs if you want to handle getting facebook auth tokens
163167
* yourself.
164168
* @param {Object} options Standard options object with success and error
165169
* callbacks.
170+
* @returns {Parse.Promise}
166171
*/
167172
logIn(permissions, options) {
168173
if (!permissions || typeof permissions === 'string') {
@@ -191,15 +196,17 @@ var FacebookUtils = {
191196
* the account to the Parse.User.
192197
*
193198
* @method link
199+
* @name Parse.FacebookUtils.link
194200
* @param {Parse.User} user User to link to Facebook. This must be the
195201
* current user.
196-
* @param {String, Object} permissions The permissions required for Facebook
202+
* @param {(String|Object)} permissions The permissions required for Facebook
197203
* log in. This is a comma-separated string of permissions.
198204
* Alternatively, supply a Facebook authData object as described in our
199205
* REST API docs if you want to handle getting facebook auth tokens
200206
* yourself.
201207
* @param {Object} options Standard options object with success and error
202208
* callbacks.
209+
* @returns {Parse.Promise}
203210
*/
204211
link(user, permissions, options) {
205212
if (!permissions || typeof permissions === 'string') {
@@ -226,10 +233,12 @@ var FacebookUtils = {
226233
* Unlinks the Parse.User from a Facebook account.
227234
*
228235
* @method unlink
236+
* @name Parse.FacebookUtils.unlink
229237
* @param {Parse.User} user User to unlink from Facebook. This must be the
230238
* current user.
231239
* @param {Object} options Standard options object with success and error
232240
* callbacks.
241+
* @returns {Parse.Promise}
233242
*/
234243
unlink: function(user, options) {
235244
if (!initialized) {

src/LiveQueryClient.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ let generateInterval = (k) => {
7878
*
7979
* javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries
8080
* to connect to the LiveQuery server
81-
*
82-
* @class Parse.LiveQueryClient
83-
* @constructor
84-
* @param {Object} options
85-
* @param {string} options.applicationId - applicationId of your Parse app
86-
* @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
87-
* @param {string} options.javascriptKey (optional)
88-
* @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
89-
* @param {string} options.sessionToken (optional)
90-
*
9181
*
9282
* We expose three events to help you monitor the status of the LiveQueryClient.
9383
*
@@ -119,10 +109,9 @@ let generateInterval = (k) => {
119109
* client.on('error', (error) => {
120110
*
121111
* });</pre>
122-
*
123-
*
112+
* @alias Parse.LiveQueryClient
124113
*/
125-
export default class LiveQueryClient extends EventEmitter {
114+
class LiveQueryClient extends EventEmitter {
126115
attempts: number;
127116
id: number;
128117
requestId: number;
@@ -136,6 +125,14 @@ export default class LiveQueryClient extends EventEmitter {
136125
socket: any;
137126
state: string;
138127

128+
/**
129+
* @param {Object} options
130+
* @param {string} options.applicationId - applicationId of your Parse app
131+
* @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
132+
* @param {string} options.javascriptKey (optional)
133+
* @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
134+
* @param {string} options.sessionToken (optional)
135+
*/
139136
constructor({
140137
applicationId,
141138
serverURL,
@@ -177,7 +174,6 @@ export default class LiveQueryClient extends EventEmitter {
177174
* <a href="https://github.com/ParsePlatform/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
178175
* from our Standard API.
179176
*
180-
* @method subscribe
181177
* @param {Object} query - the ParseQuery you want to subscribe to
182178
* @param {string} sessionToken (optional)
183179
* @return {Object} subscription
@@ -218,7 +214,6 @@ export default class LiveQueryClient extends EventEmitter {
218214
/**
219215
* After calling unsubscribe you'll stop receiving events from the subscription object.
220216
*
221-
* @method unsubscribe
222217
* @param {Object} subscription - subscription you would like to unsubscribe from.
223218
*/
224219
unsubscribe(subscription: Object) {
@@ -240,7 +235,6 @@ export default class LiveQueryClient extends EventEmitter {
240235
* After open is called, the LiveQueryClient will try to send a connect request
241236
* to the LiveQuery server.
242237
*
243-
* @method open
244238
*/
245239
open() {
246240
let WebSocketImplementation = this._getWebSocketImplementation();
@@ -303,7 +297,6 @@ export default class LiveQueryClient extends EventEmitter {
303297
* This method will close the WebSocket connection to this LiveQueryClient,
304298
* cancel the auto reconnect and unsubscribe all subscriptions based on it.
305299
*
306-
* @method close
307300
*/
308301
close() {
309302
if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
@@ -448,3 +441,5 @@ export default class LiveQueryClient extends EventEmitter {
448441
}).bind(this), time);
449442
}
450443
}
444+
445+
export default LiveQueryClient;

src/LiveQuerySubscription.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (c) 2015-present, Parse, LLC.
33
* All rights reserved.
44
*
@@ -16,10 +16,6 @@ import CoreManager from './CoreManager';
1616
* Extends events.EventEmitter
1717
* <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
1818
*
19-
* @constructor
20-
* @param {string} id - subscription id
21-
* @param {string} query - query to subscribe to
22-
* @param {string} sessionToken - optional session token
2319
*
2420
* <p>Open Event - When you call query.subscribe(), we send a subscribe request to
2521
* the LiveQuery server, when we get the confirmation from the LiveQuery server,
@@ -88,9 +84,14 @@ import CoreManager from './CoreManager';
8884
*
8985
* });</pre></p>
9086
*
91-
*
87+
* @alias Parse.LiveQuerySubscription
9288
*/
93-
export default class Subscription extends EventEmitter {
89+
class Subscription extends EventEmitter {
90+
/*
91+
* @param {string} id - subscription id
92+
* @param {string} query - query to subscribe to
93+
* @param {string} sessionToken - optional session token
94+
*/
9495
constructor(id, query, sessionToken) {
9596
super();
9697
this.id = id;
@@ -99,7 +100,7 @@ export default class Subscription extends EventEmitter {
99100
}
100101

101102
/**
102-
* @method unsubscribe
103+
* closes the subscription
103104
*/
104105
unsubscribe() {
105106
let _this = this;
@@ -110,3 +111,5 @@ export default class Subscription extends EventEmitter {
110111
});
111112
}
112113
}
114+
115+
export default Subscription;

0 commit comments

Comments
 (0)