Skip to content

Commit

Permalink
[DOC beta] Enforce public/private declaration for API docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Jun 7, 2015
1 parent b30ad1e commit 6e1ad90
Show file tree
Hide file tree
Showing 162 changed files with 1,189 additions and 444 deletions.
3 changes: 2 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
"requireSpacesAfterClosingParenthesisInFunctionDeclaration": {
"beforeOpeningRoundBrace": false,
"beforeOpeningCurlyBrace": true
}
},
"requireCommentsToIncludeAccess": true
}
38 changes: 38 additions & 0 deletions lib/jscs-rules/require-comments-to-include-access.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var assert = require('assert');

function isDocComment(comment) {
return comment.value[0] === '*';
}

function isModuleOnlyComment(comment) {
return comment.value.match(/^\*\n\s*@module.+\n(?:\s*@submodule.+\n)?$/);
}

function includesAccessDeclaration(comment) {
return comment.value.match(/\n\s*(@private|@public)\s/);
}

function RequireCommentsToIncludeAccess() { }

RequireCommentsToIncludeAccess.prototype = {
configure: function(value) {
assert(
value === true,
this.getOptionName() + ' option requires a true value or should be removed'
);
},

getOptionName: function() {
return 'requireCommentsToIncludeAccess';
},

check: function(file, errors) {
file.iterateTokensByType('Block', function(comment) {
if (isDocComment(comment) && !isModuleOnlyComment(comment) && !includesAccessDeclaration(comment)) {
errors.add('You must supply `@public` or `@private` for block comments.', comment.loc.end);
}
});
}
};

module.exports = RequireCommentsToIncludeAccess;
8 changes: 8 additions & 0 deletions packages/container/lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@ Container.prototype = {
_registry: null,

/**
@private
@property cache
@type InheritingDict
*/
cache: null,

/**
@private
@property factoryCache
@type InheritingDict
*/
factoryCache: null,

/**
@private
@property validationCache
@type InheritingDict
*/
Expand Down Expand Up @@ -100,6 +104,7 @@ Container.prototype = {
twitter === twitter2; //=> false
```
@private
@method lookup
@param {String} fullName
@param {Object} options
Expand All @@ -113,6 +118,7 @@ Container.prototype = {
/**
Given a fullName return the corresponding factory.
@private
@method lookupFactory
@param {String} fullName
@return {any}
Expand All @@ -126,6 +132,7 @@ Container.prototype = {
A depth first traversal, destroying the container, its descendant containers and all
their managed objects.
@private
@method destroy
*/
destroy() {
Expand All @@ -141,6 +148,7 @@ Container.prototype = {
/**
Clear either the entire cache or just the cache for a particular key.
@private
@method reset
@param {String} fullName optional key to reset; if missing, resets everything
*/
Expand Down
17 changes: 17 additions & 0 deletions packages/container/lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@ Registry.prototype = {
/**
A backup registry for resolving registrations when no matches can be found.
@private
@property fallback
@type Registry
*/
fallback: null,

/**
@private
@property resolver
@type function
*/
resolver: null,

/**
@private
@property registrations
@type InheritingDict
*/
Expand Down Expand Up @@ -143,6 +146,7 @@ Registry.prototype = {
/**
Creates a container based on this registry.
@private
@method container
@param {Object} options
@return {Container} created container
Expand All @@ -164,6 +168,7 @@ Registry.prototype = {
2.0TODO: Remove this method. The bookkeeping is only needed to support
deprecated behavior.
@private
@param {Container} newly created container
*/
registerContainer(container) {
Expand Down Expand Up @@ -208,6 +213,7 @@ Registry.prototype = {
registry.register('communication:main', Email, {singleton: false});
```
@private
@method register
@param {String} fullName
@param {Function} factory
Expand Down Expand Up @@ -244,6 +250,7 @@ Registry.prototype = {
registry.resolve('model:user') === undefined //=> true
```
@private
@method unregister
@param {String} fullName
*/
Expand Down Expand Up @@ -286,6 +293,7 @@ Registry.prototype = {
registry.resolve('api:twitter') // => Twitter
```
@private
@method resolve
@param {String} fullName
@return {Function} fullName's factory
Expand All @@ -307,6 +315,7 @@ Registry.prototype = {
class name (including namespace) where Ember's resolver expects
to find the `fullName`.
@private
@method describe
@param {String} fullName
@return {string} described fullName
Expand All @@ -318,6 +327,7 @@ Registry.prototype = {
/**
A hook to enable custom fullName normalization behaviour
@private
@method normalizeFullName
@param {String} fullName
@return {string} normalized fullName
Expand All @@ -329,6 +339,7 @@ Registry.prototype = {
/**
normalize a fullName based on the applications conventions
@private
@method normalize
@param {String} fullName
@return {string} normalized fullName
Expand All @@ -342,6 +353,7 @@ Registry.prototype = {
/**
@method makeToString
@private
@param {any} factory
@param {string} fullName
@return {function} toString function
Expand All @@ -354,6 +366,7 @@ Registry.prototype = {
Given a fullName check if the container is aware of its factory
or singleton instance.
@private
@method has
@param {String} fullName
@return {Boolean}
Expand Down Expand Up @@ -387,6 +400,7 @@ Registry.prototype = {
facebook === facebook2; // => false
```
@private
@method optionsForType
@param {String} type
@param {Object} options
Expand All @@ -404,6 +418,7 @@ Registry.prototype = {
},

/**
@private
@method options
@param {String} fullName
@param {Object} options
Expand Down Expand Up @@ -540,6 +555,7 @@ Registry.prototype = {
user.source === post.source; //=> true
```
@private
@method injection
@param {String} factoryName
@param {String} property
Expand Down Expand Up @@ -650,6 +666,7 @@ Registry.prototype = {
UserFactory.store === PostFactory.store; //=> true
```
@private
@method factoryInjection
@param {String} factoryName
@param {String} property
Expand Down
6 changes: 6 additions & 0 deletions packages/ember-application/lib/ext/controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
@module ember
@submodule ember-application
@public
*/

import Ember from "ember-metal/core"; // Ember.assert
Expand Down Expand Up @@ -70,6 +71,7 @@ var defaultControllersComputedProperty = computed(function() {
/**
@class ControllerMixin
@namespace Ember
@public
*/
ControllerMixin.reopen({
concatenatedProperties: ['needs'],
Expand Down Expand Up @@ -118,8 +120,10 @@ ControllerMixin.reopen({
This is only available for singleton controllers.
@deprecated Use `Ember.inject.controller()` instead.
@property {Array} needs
@default []
@public
*/
needs: [],

Expand Down Expand Up @@ -148,6 +152,7 @@ ControllerMixin.reopen({
@method controllerFor
@see {Ember.Route#controllerFor}
@deprecated Use `needs` instead
@public
*/
controllerFor(controllerName) {
Ember.deprecate("Controller#controllerFor is deprecated, please use Controller#needs instead");
Expand All @@ -172,6 +177,7 @@ ControllerMixin.reopen({
@see {Ember.ControllerMixin#needs}
@property {Object} controllers
@default null
@public
*/
controllers: defaultControllersComputedProperty
});
Expand Down
3 changes: 0 additions & 3 deletions packages/ember-application/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import Ember from 'ember-metal/core';
import { runLoadHooks } from 'ember-runtime/system/lazy_load';

/**
Ember Application
@module ember
@submodule ember-application
@requires ember-views, ember-routing
*/

import DefaultResolver from 'ember-application/system/resolver';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import Registry from 'container/registry';
That state is what the `ApplicationInstance` manages: it is responsible for
creating the container that contains all application state, and disposing of
it once the particular test run or FastBoot request has finished.
@public
*/

export default EmberObject.extend({
Expand All @@ -38,6 +40,7 @@ export default EmberObject.extend({
instance-specific state for this application run.
@property {Ember.Container} container
@public
*/
container: null,

Expand All @@ -46,6 +49,7 @@ export default EmberObject.extend({
and other code that makes up the application.
@property {Ember.Registry} registry
@private
*/
applicationRegistry: null,

Expand All @@ -54,6 +58,7 @@ export default EmberObject.extend({
`applicationRegistry` as a fallback.
@property {Ember.Registry} registry
@private
*/
registry: null,

Expand Down Expand Up @@ -156,7 +161,9 @@ export default EmberObject.extend({
this._didSetupRouter = true;
},

/** @private
/**
@private
Sets up the router, initializing the child router and configuring the
location before routing begins.
Expand Down
Loading

0 comments on commit 6e1ad90

Please sign in to comment.