Skip to content

Commit 6e1ad90

Browse files
committed
[DOC beta] Enforce public/private declaration for API docs.
1 parent b30ad1e commit 6e1ad90

File tree

162 files changed

+1189
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+1189
-444
lines changed

.jscsrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@
5656
"requireSpacesAfterClosingParenthesisInFunctionDeclaration": {
5757
"beforeOpeningRoundBrace": false,
5858
"beforeOpeningCurlyBrace": true
59-
}
59+
},
60+
"requireCommentsToIncludeAccess": true
6061
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
var assert = require('assert');
2+
3+
function isDocComment(comment) {
4+
return comment.value[0] === '*';
5+
}
6+
7+
function isModuleOnlyComment(comment) {
8+
return comment.value.match(/^\*\n\s*@module.+\n(?:\s*@submodule.+\n)?$/);
9+
}
10+
11+
function includesAccessDeclaration(comment) {
12+
return comment.value.match(/\n\s*(@private|@public)\s/);
13+
}
14+
15+
function RequireCommentsToIncludeAccess() { }
16+
17+
RequireCommentsToIncludeAccess.prototype = {
18+
configure: function(value) {
19+
assert(
20+
value === true,
21+
this.getOptionName() + ' option requires a true value or should be removed'
22+
);
23+
},
24+
25+
getOptionName: function() {
26+
return 'requireCommentsToIncludeAccess';
27+
},
28+
29+
check: function(file, errors) {
30+
file.iterateTokensByType('Block', function(comment) {
31+
if (isDocComment(comment) && !isModuleOnlyComment(comment) && !includesAccessDeclaration(comment)) {
32+
errors.add('You must supply `@public` or `@private` for block comments.', comment.loc.end);
33+
}
34+
});
35+
}
36+
};
37+
38+
module.exports = RequireCommentsToIncludeAccess;

packages/container/lib/container.js

+8
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,22 @@ Container.prototype = {
4545
_registry: null,
4646

4747
/**
48+
@private
49+
4850
@property cache
4951
@type InheritingDict
5052
*/
5153
cache: null,
5254

5355
/**
56+
@private
5457
@property factoryCache
5558
@type InheritingDict
5659
*/
5760
factoryCache: null,
5861

5962
/**
63+
@private
6064
@property validationCache
6165
@type InheritingDict
6266
*/
@@ -100,6 +104,7 @@ Container.prototype = {
100104
twitter === twitter2; //=> false
101105
```
102106
107+
@private
103108
@method lookup
104109
@param {String} fullName
105110
@param {Object} options
@@ -113,6 +118,7 @@ Container.prototype = {
113118
/**
114119
Given a fullName return the corresponding factory.
115120
121+
@private
116122
@method lookupFactory
117123
@param {String} fullName
118124
@return {any}
@@ -126,6 +132,7 @@ Container.prototype = {
126132
A depth first traversal, destroying the container, its descendant containers and all
127133
their managed objects.
128134
135+
@private
129136
@method destroy
130137
*/
131138
destroy() {
@@ -141,6 +148,7 @@ Container.prototype = {
141148
/**
142149
Clear either the entire cache or just the cache for a particular key.
143150
151+
@private
144152
@method reset
145153
@param {String} fullName optional key to reset; if missing, resets everything
146154
*/

packages/container/lib/registry.js

+17
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,21 @@ Registry.prototype = {
4747
/**
4848
A backup registry for resolving registrations when no matches can be found.
4949
50+
@private
5051
@property fallback
5152
@type Registry
5253
*/
5354
fallback: null,
5455

5556
/**
57+
@private
5658
@property resolver
5759
@type function
5860
*/
5961
resolver: null,
6062

6163
/**
64+
@private
6265
@property registrations
6366
@type InheritingDict
6467
*/
@@ -143,6 +146,7 @@ Registry.prototype = {
143146
/**
144147
Creates a container based on this registry.
145148
149+
@private
146150
@method container
147151
@param {Object} options
148152
@return {Container} created container
@@ -164,6 +168,7 @@ Registry.prototype = {
164168
2.0TODO: Remove this method. The bookkeeping is only needed to support
165169
deprecated behavior.
166170
171+
@private
167172
@param {Container} newly created container
168173
*/
169174
registerContainer(container) {
@@ -208,6 +213,7 @@ Registry.prototype = {
208213
registry.register('communication:main', Email, {singleton: false});
209214
```
210215
216+
@private
211217
@method register
212218
@param {String} fullName
213219
@param {Function} factory
@@ -244,6 +250,7 @@ Registry.prototype = {
244250
registry.resolve('model:user') === undefined //=> true
245251
```
246252
253+
@private
247254
@method unregister
248255
@param {String} fullName
249256
*/
@@ -286,6 +293,7 @@ Registry.prototype = {
286293
registry.resolve('api:twitter') // => Twitter
287294
```
288295
296+
@private
289297
@method resolve
290298
@param {String} fullName
291299
@return {Function} fullName's factory
@@ -307,6 +315,7 @@ Registry.prototype = {
307315
class name (including namespace) where Ember's resolver expects
308316
to find the `fullName`.
309317
318+
@private
310319
@method describe
311320
@param {String} fullName
312321
@return {string} described fullName
@@ -318,6 +327,7 @@ Registry.prototype = {
318327
/**
319328
A hook to enable custom fullName normalization behaviour
320329
330+
@private
321331
@method normalizeFullName
322332
@param {String} fullName
323333
@return {string} normalized fullName
@@ -329,6 +339,7 @@ Registry.prototype = {
329339
/**
330340
normalize a fullName based on the applications conventions
331341
342+
@private
332343
@method normalize
333344
@param {String} fullName
334345
@return {string} normalized fullName
@@ -342,6 +353,7 @@ Registry.prototype = {
342353
/**
343354
@method makeToString
344355
356+
@private
345357
@param {any} factory
346358
@param {string} fullName
347359
@return {function} toString function
@@ -354,6 +366,7 @@ Registry.prototype = {
354366
Given a fullName check if the container is aware of its factory
355367
or singleton instance.
356368
369+
@private
357370
@method has
358371
@param {String} fullName
359372
@return {Boolean}
@@ -387,6 +400,7 @@ Registry.prototype = {
387400
facebook === facebook2; // => false
388401
```
389402
403+
@private
390404
@method optionsForType
391405
@param {String} type
392406
@param {Object} options
@@ -404,6 +418,7 @@ Registry.prototype = {
404418
},
405419

406420
/**
421+
@private
407422
@method options
408423
@param {String} fullName
409424
@param {Object} options
@@ -540,6 +555,7 @@ Registry.prototype = {
540555
user.source === post.source; //=> true
541556
```
542557
558+
@private
543559
@method injection
544560
@param {String} factoryName
545561
@param {String} property
@@ -650,6 +666,7 @@ Registry.prototype = {
650666
UserFactory.store === PostFactory.store; //=> true
651667
```
652668
669+
@private
653670
@method factoryInjection
654671
@param {String} factoryName
655672
@param {String} property

packages/ember-application/lib/ext/controller.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
@module ember
33
@submodule ember-application
4+
@public
45
*/
56

67
import Ember from "ember-metal/core"; // Ember.assert
@@ -70,6 +71,7 @@ var defaultControllersComputedProperty = computed(function() {
7071
/**
7172
@class ControllerMixin
7273
@namespace Ember
74+
@public
7375
*/
7476
ControllerMixin.reopen({
7577
concatenatedProperties: ['needs'],
@@ -118,8 +120,10 @@ ControllerMixin.reopen({
118120
119121
This is only available for singleton controllers.
120122
123+
@deprecated Use `Ember.inject.controller()` instead.
121124
@property {Array} needs
122125
@default []
126+
@public
123127
*/
124128
needs: [],
125129

@@ -148,6 +152,7 @@ ControllerMixin.reopen({
148152
@method controllerFor
149153
@see {Ember.Route#controllerFor}
150154
@deprecated Use `needs` instead
155+
@public
151156
*/
152157
controllerFor(controllerName) {
153158
Ember.deprecate("Controller#controllerFor is deprecated, please use Controller#needs instead");
@@ -172,6 +177,7 @@ ControllerMixin.reopen({
172177
@see {Ember.ControllerMixin#needs}
173178
@property {Object} controllers
174179
@default null
180+
@public
175181
*/
176182
controllers: defaultControllersComputedProperty
177183
});

packages/ember-application/lib/main.js

-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import Ember from 'ember-metal/core';
22
import { runLoadHooks } from 'ember-runtime/system/lazy_load';
33

44
/**
5-
Ember Application
6-
75
@module ember
86
@submodule ember-application
9-
@requires ember-views, ember-routing
107
*/
118

129
import DefaultResolver from 'ember-application/system/resolver';

packages/ember-application/lib/system/application-instance.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import Registry from 'container/registry';
3030
That state is what the `ApplicationInstance` manages: it is responsible for
3131
creating the container that contains all application state, and disposing of
3232
it once the particular test run or FastBoot request has finished.
33+
34+
@public
3335
*/
3436

3537
export default EmberObject.extend({
@@ -38,6 +40,7 @@ export default EmberObject.extend({
3840
instance-specific state for this application run.
3941
4042
@property {Ember.Container} container
43+
@public
4144
*/
4245
container: null,
4346

@@ -46,6 +49,7 @@ export default EmberObject.extend({
4649
and other code that makes up the application.
4750
4851
@property {Ember.Registry} registry
52+
@private
4953
*/
5054
applicationRegistry: null,
5155

@@ -54,6 +58,7 @@ export default EmberObject.extend({
5458
`applicationRegistry` as a fallback.
5559
5660
@property {Ember.Registry} registry
61+
@private
5762
*/
5863
registry: null,
5964

@@ -156,7 +161,9 @@ export default EmberObject.extend({
156161
this._didSetupRouter = true;
157162
},
158163

159-
/** @private
164+
/**
165+
@private
166+
160167
Sets up the router, initializing the child router and configuring the
161168
location before routing begins.
162169

0 commit comments

Comments
 (0)