From 85799aa1a5b46d851830fb149838eea37eff2881 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 17 Mar 2015 19:22:13 +0000 Subject: [PATCH] docs(*): add `@publicModule` tags Initial set of tags to demonstrate the public docs filtering Closes #988 --- .../processors/processClassDocs.js | 5 + .../services/ExportTreeVisitor.js | 21 +- docs/public-docs-package/index.js | 4 + .../src/core/annotations/annotations.js | 310 ++++++++++-------- .../angular2/src/core/annotations/template.js | 3 + .../src/core/annotations/visibility.js | 2 + modules/angular2/src/core/application.js | 142 ++++---- .../compiler/binding_propagation_config.js | 3 + .../angular2/src/core/compiler/compiler.js | 2 + .../angular2/src/core/compiler/interfaces.js | 3 + .../src/core/compiler/template_loader.js | 1 + modules/angular2/src/core/compiler/view.js | 13 + .../src/core/compiler/view_container.js | 3 + modules/angular2/src/core/dom/element.js | 3 + 14 files changed, 302 insertions(+), 213 deletions(-) diff --git a/docs/dgeni-package/processors/processClassDocs.js b/docs/dgeni-package/processors/processClassDocs.js index fd0f17f1ab..4dffe0c133 100644 --- a/docs/dgeni-package/processors/processClassDocs.js +++ b/docs/dgeni-package/processors/processClassDocs.js @@ -5,8 +5,10 @@ module.exports = function processClassDocs(log, getJSDocComment) { return { $runAfter: ['processModuleDocs'], $runBefore: ['parsing-tags', 'generateDocsFromComments'], + ignorePrivateMembers: false, $process: function(docs) { var memberDocs = []; + var ignorePrivateMembers = this.ignorePrivateMembers; _.forEach(docs, function(classDoc) { if ( classDoc.docType === 'class' ) { @@ -15,6 +17,8 @@ module.exports = function processClassDocs(log, getJSDocComment) { // Create a new doc for each member of the class _.forEach(classDoc.elements, function(memberDoc) { + if (ignorePrivateMembers && memberDoc.name.literalToken.value.charAt(0) === '_') return; + classDoc.members.push(memberDoc); memberDocs.push(memberDoc); @@ -22,6 +26,7 @@ module.exports = function processClassDocs(log, getJSDocComment) { memberDoc.classDoc = classDoc; memberDoc.name = memberDoc.name.literalToken.value; + if (memberDoc.commentBefore ) { // If this export has a comment, remove it from the list of // comments collected in the module diff --git a/docs/dgeni-package/services/ExportTreeVisitor.js b/docs/dgeni-package/services/ExportTreeVisitor.js index ec26898748..48f64da6eb 100644 --- a/docs/dgeni-package/services/ExportTreeVisitor.js +++ b/docs/dgeni-package/services/ExportTreeVisitor.js @@ -17,8 +17,10 @@ module.exports = function ExportTreeVisitor(ParseTreeVisitor, log) { ParseTreeVisitor.prototype.visitExportDeclaration.call(this, tree); log.silly('exit', this.currentExport); - // We are exiting the export declaration - store the export object - this.exports.push(this.currentExport); + if(this.currentExport) { + // We are exiting the export declaration - store the export object + this.exports.push(this.currentExport); + } this.currentExport = null; }, @@ -78,14 +80,15 @@ module.exports = function ExportTreeVisitor(ParseTreeVisitor, log) { }, visitNamedExport: function(tree) { - if ( this.currentExport ) { - this.updateExport(tree); + this.currentExport = null; + // if ( this.currentExport ) { + // this.updateExport(tree); - this.currentExport.namedExport = tree; - this.currentExport.name = 'NAMED_EXPORT'; - // TODO: work out this bit!! - // We need to cope with any export specifiers in the named export - } + // this.currentExport.namedExport = tree; + // this.currentExport.name = 'NAMED_EXPORT'; + // // TODO: work out this bit!! + // // We need to cope with any export specifiers in the named export + // } }, // TODO - if the export is an expression, find the thing that is being diff --git a/docs/public-docs-package/index.js b/docs/public-docs-package/index.js index e1de117dc2..242b26d2f5 100644 --- a/docs/public-docs-package/index.js +++ b/docs/public-docs-package/index.js @@ -10,6 +10,10 @@ module.exports = new Package('angular-public', [basePackage]) parseTagsProcessor.tagDefinitions.push({ name: 'publicModule' }); }) +.config(function(processClassDocs) { + processClassDocs.ignorePrivateMembers = true; +}) + // Configure file writing .config(function(writeFilesProcessor) { writeFilesProcessor.outputFolder = 'dist/public_docs'; diff --git a/modules/angular2/src/core/annotations/annotations.js b/modules/angular2/src/core/annotations/annotations.js index c250910616..e48da68295 100644 --- a/modules/angular2/src/core/annotations/annotations.js +++ b/modules/angular2/src/core/annotations/annotations.js @@ -4,148 +4,170 @@ import {ListWrapper, List} from 'angular2/src/facade/collection'; // type StringMap = {[idx: string]: string}; /** - * Directives allow you to attach behavior to the DOM elements. - * + * Directives allow you to attach behavior to the DOM elements. + * * Directive is an abstract concept, instead use concrete directives such as: [Component], [Decorator] or [Viewport]. + * @publicModule angular2/angular2 */ @ABSTRACT() export class Directive { /** - * The CSS selector that triggers the instantiation of a directive. - * - * Angular only allows directives to trigger on CSS selectors that do not cross element boundaries. + * The CSS selector that triggers the instantiation of a directive. + * + * Angular only allows directives to trigger on CSS selectors that do not cross element boundaries. * The supported selectors are: - * + * * - `element-name` select by element name. * - `.class` select by class name. * - `[attribute]` select by attribute name. * - `[attribute=value]` select by attribute name and value. * - `:not(sub_selector)` select only if the element does not match the `sub_selector`. - * + * * ## Example - * + * * Suppose we have a directive with an `input[type=text]` selector. - * + * * And the following HTML: * - *
- * - * - * - * + * ```html + * + * + * + * + * ``` + * * The directive would only be instantiated on the `` element. - * + * */ selector:string; - + /** * Enumerates the set of properties that accept data binding for a directive. - * + * * The `bind` property defines a set of `directiveProperty` to `bindingProperty` key-value pairs: - * + * * - `directiveProperty` specifies the component property where the value is written. - * - `bindingProperty` specifies the DOM property where the value is read from. - * - * You can include [Pipes] when specifying a `bindingProperty` to allow for data transformation and structural + * - `bindingProperty` specifies the DOM property where the value is read from. + * + * You can include [Pipes] when specifying a `bindingProperty` to allow for data transformation and structural * change detection of the value. - * + * * ## Syntax - * @Directive({ - * bind: { - * 'directiveProperty1': 'bindingProperty1', - * 'directiveProperty2': 'bindingProperty2 | pipe1 | ...', - * ... - * } - * } - * - * - * ## Basic Property Binding: - * - * @Decorator({ - * selector: '[tooltip]', - * bind: { - * 'tooltipText': 'tooltip' - * } - * }) - * class Tooltip { - * set tooltipText(text) { - * // This will get called every time the 'tooltip' binding changes with the new value. - * } - * } - * + * + * ``` + * @Directive({ + * bind: { + * 'directiveProperty1': 'bindingProperty1', + * 'directiveProperty2': 'bindingProperty2 | pipe1 | ...', + * ... + * } + * } + * ``` + * + * + * ## Basic Property Binding: + * + * ``` + * @Decorator({ + * selector: '[tooltip]', + * bind: { + * 'tooltipText': 'tooltip' + * } + * }) + * class Tooltip { + * set tooltipText(text) { + * // This will get called every time the 'tooltip' binding changes with the new value. + * } + * } + * ``` + * * As used in this example: - * - *
- * - * Whenever the `someExpression` expression changes, the `bind` declaration instructs Angular to update the + * + * ```html + *
+ * ``` + * + * Whenever the `someExpression` expression changes, the `bind` declaration instructs Angular to update the * `Tooltip`'s `tooltipText` property. - * - * + * + * * Similarly in this example: - * - *
- * + * + * ```html + *
+ * ``` + * * The `Tooltip`'s `tooltipText` property gets initialized to the `Some Text` literal. - * - * - * ## Bindings With Pipes: - * - * @Decorator({ - * selector: '[class-set]', - * bind: { - * 'classChanges': 'classSet | keyValDiff' - * } - * }) - * class ClassSet { - * set classChanges(changes:KeyValueChanges) { - * // This will get called every time the `class-set` expressions changes its structure. - * } - * } - * + * + * + * ## Bindings With Pipes: + * + * ``` + * @Decorator({ + * selector: '[class-set]', + * bind: { + * 'classChanges': 'classSet | keyValDiff' + * } + * }) + * class ClassSet { + * set classChanges(changes:KeyValueChanges) { + * // This will get called every time the `class-set` expressions changes its structure. + * } + * } + * ``` + * * As used in this example: - *
- * + * + * ```html + *
+ * ``` + * * In the above example, the `ClassSet` uses the `keyValDiff` [Pipe] for watching structural changes. This means that - * the `classChanges` setter gets invoked if the expression changes to a different reference, or if the + * the `classChanges` setter gets invoked if the expression changes to a different reference, or if the * structure of the expression changes. (Shallow property watching of the object) - * + * * NOTE: The `someExpression` can also contain its own [Pipe]s. In this case, the two pipes compose as if they were * inlined. - * + * */ bind:any; // StringMap - + /** * Specifies which DOM events the directive listens to and what the action should be. - * + * * The `event` property defines a set of `event` to `method` key-value pairs: - * + * * - `event` specifies the DOM event that the directive listens to. - * - `onMethod` specifies the method to execute when the event occurs. - * - * + * - `onMethod` specifies the method to execute when the event occurs. + * + * * ## Syntax - * @Directive({ - * events: { - * 'event1': 'onMethod', - * ... - * } - * } - * - * ## Basic Event Binding: - * - * @Decorator({ - * selector: 'input', - * event: { - * 'change': 'onChange' - * } - * }) - * class InputDecorator { - * onChange(event:Event) { - * // invoked whenever the DOM element fires the 'change' event. - * } - * } - * + * + * ``` + * @Directive({ + * events: { + * 'event1': 'onMethod', + * ... + * } + * } + * ``` + * + * ## Basic Event Binding: + * + * ``` + * @Decorator({ + * selector: 'input', + * event: { + * 'change': 'onChange' + * } + * }) + * class InputDecorator { + * onChange(event:Event) { + * // invoked whenever the DOM element fires the 'change' event. + * } + * } + * ``` + * */ events:any; // StringMap @@ -153,7 +175,7 @@ export class Directive { * Specifies a set of lifecycle events in which the directive participates. */ lifecycle:any; //List - + @CONST() constructor({ selector, @@ -178,6 +200,9 @@ export class Directive { } } +/** + * @publicModule angular2/angular2 + */ export class Component extends Directive { //TODO: vsavkin: uncomment it once the issue with defining fields in a sublass works services:any; //List; @@ -208,6 +233,9 @@ export class Component extends Directive { } } +/** + * @publicModule angular2/angular2 + */ export class Decorator extends Directive { compileChildren: boolean; @CONST() @@ -235,6 +263,9 @@ export class Decorator extends Directive { } } +/** + * @publicModule angular2/angular2 + */ export class Viewport extends Directive { @CONST() constructor({ @@ -261,47 +292,52 @@ export class Viewport extends Directive { /** * Specify that a directive should be notified whenever a [View] that contains it is destroyed. - * + * * ## Example - * - * @Decorator({ - * ..., - * lifecycle: [ onDestroy ] - * }) - * class ClassSet implements OnDestroy { - * onDestroy() { - * // invoked to notify directive of the containing view destruction. - * } - * } + * + * ``` + * @Decorator({ + * ..., + * lifecycle: [ onDestroy ] + * }) + * class ClassSet implements OnDestroy { + * onDestroy() { + * // invoked to notify directive of the containing view destruction. + * } + * } + * ``` + * @publicModule angular2/angular2 */ export const onDestroy = "onDestroy"; /** - * Specify that a directive should be notified when any of its bindings have changed. - * + * Specify that a directive should be notified when any of its bindings have changed. + * * ## Example: - * - * @Decorator({ - * selector: '[class-set]', - * bind: { - * 'propA': 'propA' - * 'propB': 'propB' - * } - * }) - * class ClassSet { - * propA; - * propB; - * - * onChange(changes:{[idx: string, PropertyUpdate]}) { - * // This will get called after any of the properties have been updated. - * if (changes['propA']) { - * // if propA was updated - * } - * if (changes['propA']) { - * // if propB was updated - * } - * } + * + * ``` + * @Decorator({ + * selector: '[class-set]', + * bind: { + * 'propA': 'propA' + * 'propB': 'propB' + * } + * }) + * class ClassSet { + * propA; + * propB; + * onChange(changes:{[idx: string, PropertyUpdate]}) { + * // This will get called after any of the properties have been updated. + * if (changes['propA']) { + * // if propA was updated * } + * if (changes['propA']) { + * // if propB was updated + * } + * } + * } + * ``` + * @publicModule angular2/angular2 */ export const onChange = "onChange"; diff --git a/modules/angular2/src/core/annotations/template.js b/modules/angular2/src/core/annotations/template.js index 550eaae62b..a0352b582d 100644 --- a/modules/angular2/src/core/annotations/template.js +++ b/modules/angular2/src/core/annotations/template.js @@ -1,5 +1,8 @@ import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang'; +/** + * @publicModule angular2/angular2 + */ export class Template { url:any; //string; inline:any; //string; diff --git a/modules/angular2/src/core/annotations/visibility.js b/modules/angular2/src/core/annotations/visibility.js index 828354de65..51321c5933 100644 --- a/modules/angular2/src/core/annotations/visibility.js +++ b/modules/angular2/src/core/annotations/visibility.js @@ -4,6 +4,7 @@ import {DependencyAnnotation} from 'angular2/di'; /** * The directive can only be injected from the current element * or from its parent. + * @publicModule angular2/angular2 */ export class Parent extends DependencyAnnotation { @CONST() @@ -15,6 +16,7 @@ export class Parent extends DependencyAnnotation { /** * The directive can only be injected from the current element * or from its ancestor. + * @publicModule angular2/angular2 */ export class Ancestor extends DependencyAnnotation { @CONST() diff --git a/modules/angular2/src/core/application.js b/modules/angular2/src/core/application.js index b5f66283c0..98ed4dea93 100644 --- a/modules/angular2/src/core/application.js +++ b/modules/angular2/src/core/application.js @@ -118,102 +118,110 @@ function _createVmZone(givenReporter:Function): VmTurnZone { } /** - * Bootstrapping for Angular applications. - * - * You instantiate an Angular application by explicitly specifying a component to use as the root component for your + * Bootstrapping for Angular applications. + * + * You instantiate an Angular application by explicitly specifying a component to use as the root component for your * application via the `bootstrap()` method. - * + * * ## Simple Example - * + * * Assuming this `index.html`: - * - * - * - * loading... - * - * - * + * + * ```html + * + * + * + * loading... + * + * + * ``` + * * An application is bootstrapped inside an existing browser DOM, typically `index.html`. Unlike Angular 1, Angular 2 * does not compile/process bindings in `index.html`. This is mainly for security reasons, as well as architectural * changes in Angular 2. This means that `index.html` can safely be processed using server-side binding technologies, * which may use double-curly `{{syntax}}` without collision from Angular 2 component double-curly `{{syntax}}`. - * + * * We can use this script code: - * @Component({ - * selector: 'my-app' - * }) - * @Template({ - * inline: 'Hello {{name}}!' - * }) - * class MyApp { - * name:string; - * - * constructor() { - * this.name = 'World'; - * } - * } - * - * main() { - * bootstrap(MyApp); - * } - * - * When the app developer invokes `bootstrap()` with the root component `MyApp` as its argument, Angular performs the + * + * ``` + * @Component({ + * selector: 'my-app' + * }) + * @Template({ + * inline: 'Hello {{name}}!' + * }) + * class MyApp { + * name:string; + * + * constructor() { + * this.name = 'World'; + * } + * } + * + * main() { + * bootstrap(MyApp); + * } + * ``` + * + * When the app developer invokes `bootstrap()` with the root component `MyApp` as its argument, Angular performs the * following tasks: - * - * 1. It uses the component's `selector` property to locate the DOM element which needs to be upgraded into + * + * 1. It uses the component's `selector` property to locate the DOM element which needs to be upgraded into * the angular component. - * 2. It creates a new child injector (from the primordial injector) and configures the injector with the component's - * `services`. Optionally, you can also override the injector configuration for an app by invoking + * 2. It creates a new child injector (from the primordial injector) and configures the injector with the component's + * `services`. Optionally, you can also override the injector configuration for an app by invoking * `bootstrap` with the `componentServiceBindings` argument. - * 3. It creates a new [Zone] and connects it to the angular application's change detection domain instance. + * 3. It creates a new [Zone] and connects it to the angular application's change detection domain instance. * 4. It creates a shadow DOM on the selected component's host element and loads the template into it. * 5. It instantiates the specified component. * 6. Finally, Angular performs change detection to apply the initial data bindings for the application. - * - * - * ## Instantiating Multiple Applications on a Single Page - * - * There are two ways to do this. - * - * - * ### Isolated Applications - * - * Angular creates a new application each time that the `bootstrap()` method is invoked. When multiple applications - * are created for a page, Angular treats each application as independent within an isolated change detection and - * [Zone] domain. If you need to share data between applications, use the strategy described in the next - * section, "Applications That Share Change Detection." * - * + * + * ## Instantiating Multiple Applications on a Single Page + * + * There are two ways to do this. + * + * + * ### Isolated Applications + * + * Angular creates a new application each time that the `bootstrap()` method is invoked. When multiple applications + * are created for a page, Angular treats each application as independent within an isolated change detection and + * [Zone] domain. If you need to share data between applications, use the strategy described in the next + * section, "Applications That Share Change Detection." + * + * * ### Applications That Share Change Detection - * - * If you need to bootstrap multiple applications that share common data, the applications must share a common + * + * If you need to bootstrap multiple applications that share common data, the applications must share a common * change detection and zone. To do that, create a meta-component that lists the application components in its template. * By only invoking the bootstrap()` method once with the meta-component as its argument, you ensure that only a single * change detection zone is created and therefore data can be shared across the applications. - * - * + * + * * ## Primordial Injector - * - * When working within a browser window, there are many singleton resources: cookies, title, location, and others. - * Angular services that represent these resources must likewise be shared across all Angular applications that + * + * When working within a browser window, there are many singleton resources: cookies, title, location, and others. + * Angular services that represent these resources must likewise be shared across all Angular applications that * occupy the same browser window. For this reason, Angular creates exactly one global primordial injector which stores - * all shared services, and each angular application injector has the primordial injector as its parent. - * - * Each application has its own private injector as well. When there are multiple applications on a page, Angular treats + * all shared services, and each angular application injector has the primordial injector as its parent. + * + * Each application has its own private injector as well. When there are multiple applications on a page, Angular treats * each application injector's services as private to that application. - * - * + * + * * # API * - [appComponentType]: The root component which should act as the application. This is a reference to a [Type] * which is annotated with `@Component(...)`. - * - [componentServiceBindings]: An additional set of bindings that can be added to the [Component.services] to + * - [componentServiceBindings]: An additional set of bindings that can be added to the [Component.services] to * override default injection behavior. * - [errorReporter]: `function(exception:any, stackTrace:string)` a default error reporter for unhandled exceptions. - * + * * Returns the application`s private [Injector]. + * + * @publicModule angular2/angular2 */ -export function bootstrap(appComponentType: Type, - componentServiceBindings: List=null, +export function bootstrap(appComponentType: Type, + componentServiceBindings: List=null, errorReporter: Function=null): Promise { BrowserDomAdapter.makeCurrent(); var bootstrapProcess = PromiseWrapper.completer(); diff --git a/modules/angular2/src/core/compiler/binding_propagation_config.js b/modules/angular2/src/core/compiler/binding_propagation_config.js index 229994ddb0..2c76c81c4b 100644 --- a/modules/angular2/src/core/compiler/binding_propagation_config.js +++ b/modules/angular2/src/core/compiler/binding_propagation_config.js @@ -1,5 +1,8 @@ import {ChangeDetector, CHECK_ONCE, DETACHED, CHECK_ALWAYS} from 'angular2/change_detection'; +/** + * @publicModule angular2/angular2 + */ export class BindingPropagationConfig { _cd:ChangeDetector; diff --git a/modules/angular2/src/core/compiler/compiler.js b/modules/angular2/src/core/compiler/compiler.js index 969aa81080..8a21cf37fb 100644 --- a/modules/angular2/src/core/compiler/compiler.js +++ b/modules/angular2/src/core/compiler/compiler.js @@ -21,6 +21,7 @@ import {CssProcessor} from './css_processor'; /** * Cache that stores the ProtoView of the template of a component. * Used to prevent duplicate work and resolve cyclic dependencies. + * @publicModule angular2/angular2 */ export class CompilerCache { _cache:Map; @@ -46,6 +47,7 @@ export class CompilerCache { * The compiler loads and translates the html templates of components into * nested ProtoViews. To decompose its functionality it uses * the CompilePipeline and the CompileSteps. + * @publicModule angular2/angular2 */ export class Compiler { _reader: DirectiveMetadataReader; diff --git a/modules/angular2/src/core/compiler/interfaces.js b/modules/angular2/src/core/compiler/interfaces.js index e4c2d71e34..3623a7a773 100644 --- a/modules/angular2/src/core/compiler/interfaces.js +++ b/modules/angular2/src/core/compiler/interfaces.js @@ -1,3 +1,6 @@ +/** + * @publicModule angular2/angular2 + */ export class OnChange { onChange(changes) { throw "OnChange.onChange is not implemented"; diff --git a/modules/angular2/src/core/compiler/template_loader.js b/modules/angular2/src/core/compiler/template_loader.js index bfcd0d895a..609d3cd92b 100644 --- a/modules/angular2/src/core/compiler/template_loader.js +++ b/modules/angular2/src/core/compiler/template_loader.js @@ -10,6 +10,7 @@ import {UrlResolver} from './url_resolver'; /** * Strategy to load component templates. + * @publicModule angular2/angular2 */ export class TemplateLoader { _xhr: XHR; diff --git a/modules/angular2/src/core/compiler/view.js b/modules/angular2/src/core/compiler/view.js index 5eff761e20..c1db305be0 100644 --- a/modules/angular2/src/core/compiler/view.js +++ b/modules/angular2/src/core/compiler/view.js @@ -28,6 +28,7 @@ var VIEW_POOL_PREFILL = 0; /** * Const of making objects: http://jsperf.com/instantiate-size-of-object + * @publicModule angular2/angular2 */ @IMPLEMENTS(ChangeDispatcher) export class View { @@ -280,6 +281,9 @@ export class View { } } +/** + * @publicModule angular2/angular2 + */ export class ProtoView { element; elementBinders:List; @@ -640,6 +644,9 @@ export class ProtoView { } } +/** + * @publicModule angular2/angular2 + */ export class ElementBindingMemento { _elementIndex:int; _setterName:string; @@ -656,6 +663,9 @@ export class ElementBindingMemento { } } +/** + * @publicModule angular2/angular2 + */ export class DirectiveBindingMemento { _elementInjectorIndex:int; _directiveIndex:int; @@ -712,6 +722,9 @@ class DirectiveMemento { } } +/** + * @publicModule angular2/angular2 + */ export class PropertyUpdate { currentValue; previousValue; diff --git a/modules/angular2/src/core/compiler/view_container.js b/modules/angular2/src/core/compiler/view_container.js index b95f37aaab..a2170ce0d8 100644 --- a/modules/angular2/src/core/compiler/view_container.js +++ b/modules/angular2/src/core/compiler/view_container.js @@ -8,6 +8,9 @@ import {isPresent, isBlank} from 'angular2/src/facade/lang'; import {EventManager} from 'angular2/src/core/events/event_manager'; import * as ldModule from './shadow_dom_emulation/light_dom'; +/** + * @publicModule angular2/angular2 + */ export class ViewContainer { parentView: viewModule.View; templateElement; diff --git a/modules/angular2/src/core/dom/element.js b/modules/angular2/src/core/dom/element.js index 82d57bc8da..bb9c98fb6b 100644 --- a/modules/angular2/src/core/dom/element.js +++ b/modules/angular2/src/core/dom/element.js @@ -1,6 +1,9 @@ import {DOM} from 'angular2/src/dom/dom_adapter'; import {normalizeBlank} from 'angular2/src/facade/lang'; +/** + * @publicModule angular2/angular2 + */ export class NgElement { domElement; constructor(domElement) {