Skip to content

Commit

Permalink
Add return types and properties types in JSDoc to a lot of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Slava committed Nov 2, 2014
1 parent b5d2cce commit 44832cb
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/accounts-base/accounts_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ if (Meteor.isClient) {
/**
* @summary A [Mongo.Collection](#collections) containing user documents.
* @locus Anywhere
* @type {Mongo.Collection}
*/
Meteor.users = new Mongo.Collection("users", {
_preventAutopublish: true,
Expand Down
4 changes: 4 additions & 0 deletions packages/blaze/preamble.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @namespace Blaze
* @summary The namespace for all Blaze-related methods and classes.
*/
Blaze = {};

// Utility to HTML-escape a string. Included for legacy reasons.
Expand Down
7 changes: 7 additions & 0 deletions packages/blaze/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Blaze.TemplateInstance = function (view) {
* @instance
* @summary The [View](#blaze_view) object for this invocation of the template.
* @locus Client
* @type {Blaze.View}
*/
this.view = view;
this.data = null;
Expand All @@ -188,6 +189,7 @@ Blaze.TemplateInstance = function (view) {
* @instance
* @summary The first top-level DOM node in this template instance.
* @locus Client
* @type {DOMNode}
*/
this.firstNode = null;

Expand All @@ -197,6 +199,7 @@ Blaze.TemplateInstance = function (view) {
* @instance
* @summary The last top-level DOM node in this template instance.
* @locus Client
* @type {DOMNode}
*/
this.lastNode = null;
};
Expand All @@ -205,6 +208,7 @@ Blaze.TemplateInstance = function (view) {
* @summary Find all elements matching `selector` in this template instance, and return them as a JQuery object.
* @locus Client
* @param {String} selector The CSS selector to match, scoped to the template contents.
* @returns {DOMNode[]}
*/
Blaze.TemplateInstance.prototype.$ = function (selector) {
var view = this.view;
Expand All @@ -217,6 +221,7 @@ Blaze.TemplateInstance.prototype.$ = function (selector) {
* @summary Find all elements matching `selector` in this template instance.
* @locus Client
* @param {String} selector The CSS selector to match, scoped to the template contents.
* @returns {DOMNode[]}
*/
Blaze.TemplateInstance.prototype.findAll = function (selector) {
return Array.prototype.slice.call(this.$(selector));
Expand All @@ -226,6 +231,7 @@ Blaze.TemplateInstance.prototype.findAll = function (selector) {
* @summary Find one element matching `selector` in this template instance.
* @locus Client
* @param {String} selector The CSS selector to match, scoped to the template contents.
* @returns {DOMNode}
*/
Blaze.TemplateInstance.prototype.find = function (selector) {
var result = this.$(selector);
Expand Down Expand Up @@ -283,6 +289,7 @@ Template.prototype.events = function (eventMap) {
* @memberOf Template
* @summary The [template instance](#template_inst) corresponding to the current template helper, event handler, callback, or autorun. If there isn't one, `null`.
* @locus Client
* @returns Blaze.TemplateInstance
*/
Template.instance = function () {
var view = Blaze.currentView;
Expand Down
1 change: 1 addition & 0 deletions packages/blaze/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ Blaze._isContentEqual = function (a, b) {
/**
* @summary The View corresponding to the current template helper, event handler, callback, or autorun. If there isn't one, `null`.
* @locus Client
* @type {Blaze.View}
*/
Blaze.currentView = null;

Expand Down
8 changes: 6 additions & 2 deletions packages/check/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var currentArgumentChecker = new Meteor.EnvironmentVariable;
/**
* @summary Check that a value matches a [pattern](#matchpatterns).
* If the value does not match the pattern, throw a `Match.Error`.
*
*
* Particularly useful to assert that arguments to a function have the right
* types and structure.
* @locus Anywhere
Expand Down Expand Up @@ -37,6 +37,10 @@ check = function (value, pattern) {
}
};

/**
* @namespace Match
* @summary The namespace for all Match types and methods.
*/
Match = {
Optional: function (pattern) {
return new Optional(pattern);
Expand Down Expand Up @@ -76,7 +80,7 @@ Match = {
// XXX maybe also implement a Match.match which returns more information about
// failures but without using exception handling or doing what check()
// does with _failIfArgumentsAreNotAllChecked and Meteor.Error conversion

/**
* @summary Returns true if the value matches the pattern.
* @locus Anywhere
Expand Down
4 changes: 4 additions & 0 deletions packages/ddp/common.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/**
* @namespace DDP
* @summary The namespace for DDP-related methods.
*/
DDP = {};
LivedataTest = {};
7 changes: 4 additions & 3 deletions packages/ddp/livedata_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ MethodInvocation = function (options) {
// purposes). not currently true except in a client such as a browser,
// since there's usually no point in running stubs unless you have a
// zero-latency connection to the user.

/**
* @summary Access inside a method invocation. Boolean value, true if this invocation is a stub.
* @locus Anywhere
* @name isSimulation
* @memberOf MethodInvocation
* @instance
* @type {Boolean}
*/
this.isSimulation = options.isSimulation;

Expand All @@ -39,7 +40,7 @@ MethodInvocation = function (options) {
this._calledUnblock = false;

// current user id

/**
* @summary The id of the user that made this method call, or `null` if no user was logged in.
* @locus Anywhere
Expand All @@ -54,7 +55,7 @@ MethodInvocation = function (options) {
this._setUserId = options.setUserId || function () {};

// On the server, the connection this method call came in on.

/**
* @summary Access inside a method invocation. The [connection](#meteor_onconnection) that this method was received on. `null` if the method is not associated with a connection, eg. a server initiated method call.
* @locus Server
Expand Down
6 changes: 3 additions & 3 deletions packages/ddp/livedata_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ var Subscription = function (
self._ready = false;

// Part of the public API: the user of this sub.

/**
* @summary Access inside the publish function. The id of the logged-in user, or `null` if no user is logged in.
* @locus Server
Expand Down Expand Up @@ -1082,7 +1082,7 @@ _.extend(Subscription.prototype, {
// server (and clean up its _subscriptions table) we don't actually provide a
// mechanism for an app to notice this (the subscribe onError callback only
// triggers if there is an error).

/**
* @summary Call inside the publish function. Stops this client's subscription; the `onError` callback is *not* invoked on the client.
* @locus Server
Expand Down Expand Up @@ -1364,7 +1364,7 @@ _.extend(Server.prototype, {
* (it lets us determine whether to print a warning suggesting
* that you turn off autopublish.)
*/

/**
* @summary Publish a record set.
* @memberOf Meteor
Expand Down
3 changes: 3 additions & 0 deletions packages/meteor/client_environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ Meteor = {
* @summary Boolean variable. True if running in client environment.
* @locus Anywhere
* @static
* @type {Boolean}
*/
isClient: true,

/**
* @summary Boolean variable. True if running in server environment.
* @locus Anywhere
* @static
* @type {Boolean}
*/
isServer: false
};
Expand All @@ -24,6 +26,7 @@ if (typeof __meteor_runtime_config__ === 'object' &&
/**
* @summary `Meteor.settings` contains deployment-specific configuration options. You can initialize settings by passing the `--settings` option (which takes the name of a file containing JSON data) to `meteor run` or `meteor deploy`. When running your server directly (e.g. from a bundle), you instead specify settings by putting the JSON directly into the `METEOR_SETTINGS` environment variable. If you don't provide any settings, `Meteor.settings` will be an empty object. If the settings object contains a key named `public`, then `Meteor.settings.public` will be available on the client as well as the server. All other properties of `Meteor.settings` are only defined on the server.
* @locus Anywhere
* @type {Object}
*/
Meteor.settings = { 'public': __meteor_runtime_config__.PUBLIC_SETTINGS };
}
2 changes: 2 additions & 0 deletions packages/meteor/cordova_environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* @summary Boolean variable. True if running in a Cordova mobile environment.
* @type {Boolean}
* @static
* @locus Anywhere
*/
Meteor.isCordova = true;
Expand Down
1 change: 1 addition & 0 deletions packages/meteor/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if (typeof __meteor_runtime_config__ === 'object' &&
/**
* @summary `Meteor.release` is a string containing the name of the [release](#meteorupdate) with which the project was built (for example, `"1.2.3"`). It is `undefined` if the project was built using a git checkout of Meteor.
* @locus Anywhere
* @type {String}
*/
Meteor.release = __meteor_runtime_config__.meteorRelease;
}
Expand Down
11 changes: 11 additions & 0 deletions packages/tracker/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
// Package docs at http://docs.meteor.com/#tracker //
//////////////////////////////////////////////////

/**
* @namespace Tracker
* @summary The namespace for Tracker-related methods.
*/
Tracker = {};

// http://docs.meteor.com/#tracker_active

/**
* @summary True if there is a current computation, meaning that dependencies on reactive data sources will be tracked and potentially cause the current computation to be rerun.
* @locus Client
* @type {Boolean}
*/
Tracker.active = false;

Expand All @@ -17,6 +22,7 @@ Tracker.active = false;
/**
* @summary The current computation, or `null` if there isn't one. The current computation is the [`Tracker.Computation`](#tracker_computation) object created by the innermost active call to `Tracker.autorun`, and it's the computation that gains dependencies when reactive data sources are accessed.
* @locus Client
* @type {Tracker.Computation}
*/
Tracker.currentComputation = null;

Expand Down Expand Up @@ -146,6 +152,7 @@ Tracker.Computation = function (f, parent) {
* @memberOf Tracker.Computation
* @instance
* @name invalidated
* @type {Boolean}
*/
self.invalidated = false;

Expand All @@ -157,6 +164,7 @@ Tracker.Computation = function (f, parent) {
* @memberOf Tracker.Computation
* @instance
* @name firstRun
* @type {Boolean}
*/
self.firstRun = true;

Expand Down Expand Up @@ -313,6 +321,7 @@ If there is no current computation and `depend()` is called with no arguments, i
Returns true if the computation is a new dependent of `dependency` rather than an existing one.
* @locus Client
* @param {Tracker.Computation} [fromComputation] An optional computation declared to depend on `dependency` instead of the current computation.
* @returns {Boolean}
*/
Tracker.Dependency.prototype.depend = function (computation) {
if (! computation) {
Expand Down Expand Up @@ -350,6 +359,7 @@ Tracker.Dependency.prototype.changed = function () {
/**
* @summary True if this Dependency has one or more dependent Computations, which would be invalidated if this Dependency were to change.
* @locus Client
* @returns {Boolean}
*/
Tracker.Dependency.prototype.hasDependents = function () {
var self = this;
Expand Down Expand Up @@ -434,6 +444,7 @@ Tracker.flush = function (_opts) {
* @summary Run a function now and rerun it later whenever its dependencies change. Returns a Computation object that can be used to stop or observe the rerunning.
* @locus Client
* @param {Function} runFunc The function to run. It receives one argument: the Computation object that will be returned.
* @returns {Tracker.Computation}
*/
Tracker.autorun = function (f) {
if (typeof f !== 'function')
Expand Down
2 changes: 1 addition & 1 deletion scripts/admin/jsdoc/jsdoc-conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"tools/skel-pack/package.js"
]
}
}
}

0 comments on commit 44832cb

Please sign in to comment.