From 2170379251c61eec046361edfb13df88ecb13fee Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 9 Sep 2016 12:05:06 -0700 Subject: [PATCH] refactor(common): cleanup, strip deprecated doc (#11469) --- modules/@angular/common/index.ts | 7 +- modules/@angular/common/src/common.ts | 13 ---- .../@angular/common/src/common_directives.ts | 59 --------------- modules/@angular/common/src/common_module.ts | 4 +- modules/@angular/common/src/directives.ts | 20 ------ .../common/src/directives/core_directives.ts | 72 ------------------- .../@angular/common/src/directives/index.ts | 47 ++++++++++++ modules/@angular/common/src/pipes.ts | 10 --- .../src/pipes/{common_pipes.ts => index.ts} | 21 ++++-- 9 files changed, 68 insertions(+), 185 deletions(-) delete mode 100644 modules/@angular/common/src/common.ts delete mode 100644 modules/@angular/common/src/common_directives.ts delete mode 100644 modules/@angular/common/src/directives.ts delete mode 100644 modules/@angular/common/src/directives/core_directives.ts create mode 100644 modules/@angular/common/src/directives/index.ts rename modules/@angular/common/src/pipes/{common_pipes.ts => index.ts} (75%) diff --git a/modules/@angular/common/index.ts b/modules/@angular/common/index.ts index a55ca93ed3..56ec817053 100644 --- a/modules/@angular/common/index.ts +++ b/modules/@angular/common/index.ts @@ -11,6 +11,9 @@ * @description * Entry point for all public APIs of the common package. */ -export * from './src/common'; +export * from './src/location'; +export {NgLocalization} from './src/localization'; +export {CommonModule} from './src/common_module'; -// This file only reexports content of the `src` folder. Keep it that way. +export {NgClass, NgFor, NgIf, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet} from './src/directives/index'; +export {AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe} from './src/pipes/index'; \ No newline at end of file diff --git a/modules/@angular/common/src/common.ts b/modules/@angular/common/src/common.ts deleted file mode 100644 index 68fdb094ce..0000000000 --- a/modules/@angular/common/src/common.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -export * from './pipes'; -export * from './directives'; -export * from './location'; -export {NgLocalization} from './localization'; -export {CommonModule} from './common_module'; diff --git a/modules/@angular/common/src/common_directives.ts b/modules/@angular/common/src/common_directives.ts deleted file mode 100644 index c346e04c95..0000000000 --- a/modules/@angular/common/src/common_directives.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Provider} from '@angular/core'; - -import {CORE_DIRECTIVES} from './directives/core_directives'; - - -/** - * A collection of Angular core directives that are likely to be used in each and every Angular - * application. This includes core directives (e.g., NgIf and NgFor), and forms directives (e.g., - * NgModel). - * - * This collection can be used to quickly enumerate all the built-in directives in the `directives` - * property of the `@Component` decorator. - * - * ### Example - * - * Instead of writing: - * - * ```typescript - * import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchCase, NgSwitchDefault, NgModel, NgForm} from - * '@angular/common'; - * import {OtherDirective} from './myDirectives'; - * - * @Component({ - * selector: 'my-component', - * templateUrl: 'myComponent.html', - * directives: [NgClass, NgIf, NgFor, NgSwitch, NgSwitchCase, NgSwitchDefault, NgModel, NgForm, - * OtherDirective] - * }) - * export class MyComponent { - * ... - * } - * ``` - * one could import all the common directives at once: - * - * ```typescript - * import {COMMON_DIRECTIVES} from '@angular/common'; - * import {OtherDirective} from './myDirectives'; - * - * @Component({ - * selector: 'my-component', - * templateUrl: 'myComponent.html', - * directives: [COMMON_DIRECTIVES, OtherDirective] - * }) - * export class MyComponent { - * ... - * } - * ``` - * - * @experimental Contains forms which are experimental. - */ -export const COMMON_DIRECTIVES: Provider[] = CORE_DIRECTIVES; diff --git a/modules/@angular/common/src/common_module.ts b/modules/@angular/common/src/common_module.ts index 92c5e51725..849d0a547f 100644 --- a/modules/@angular/common/src/common_module.ts +++ b/modules/@angular/common/src/common_module.ts @@ -8,9 +8,9 @@ import {NgModule} from '@angular/core'; -import {COMMON_DIRECTIVES} from './common_directives'; +import {COMMON_DIRECTIVES} from './directives/index'; import {NgLocaleLocalization, NgLocalization} from './localization'; -import {COMMON_PIPES} from './pipes/common_pipes'; +import {COMMON_PIPES} from './pipes/index'; // Note: This does not contain the location providers, // as they need some platform specific implementations to work. diff --git a/modules/@angular/common/src/directives.ts b/modules/@angular/common/src/directives.ts deleted file mode 100644 index 4b709669a5..0000000000 --- a/modules/@angular/common/src/directives.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/** - * @module - * @description - * Common directives shipped with Angular. - */ -export {NgClass} from './directives/ng_class'; -export {NgFor} from './directives/ng_for'; -export {NgIf} from './directives/ng_if'; -export {NgPlural, NgPluralCase} from './directives/ng_plural'; -export {NgStyle} from './directives/ng_style'; -export {NgSwitch, NgSwitchCase, NgSwitchDefault} from './directives/ng_switch'; -export {NgTemplateOutlet} from './directives/ng_template_outlet'; diff --git a/modules/@angular/common/src/directives/core_directives.ts b/modules/@angular/common/src/directives/core_directives.ts deleted file mode 100644 index 5efa97503b..0000000000 --- a/modules/@angular/common/src/directives/core_directives.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Type} from '@angular/core'; - -import {NgClass} from './ng_class'; -import {NgFor} from './ng_for'; -import {NgIf} from './ng_if'; -import {NgPlural, NgPluralCase} from './ng_plural'; -import {NgStyle} from './ng_style'; -import {NgSwitch, NgSwitchCase, NgSwitchDefault} from './ng_switch'; -import {NgTemplateOutlet} from './ng_template_outlet'; - -/** - * A collection of Angular core directives that are likely to be used in each and every Angular - * application. - * - * This collection can be used to quickly enumerate all the built-in directives in the `directives` - * property of the `@Component` annotation. - * - * ### Example ([live demo](http://plnkr.co/edit/yakGwpCdUkg0qfzX5m8g?p=preview)) - * - * Instead of writing: - * - * ```typescript - * import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchCase, NgSwitchDefault} from '@angular/common'; - * import {OtherDirective} from './myDirectives'; - * - * @Component({ - * selector: 'my-component', - * templateUrl: 'myComponent.html', - * directives: [NgClass, NgIf, NgFor, NgSwitch, NgSwitchCase, NgSwitchDefault, OtherDirective] - * }) - * export class MyComponent { - * ... - * } - * ``` - * one could import all the core directives at once: - * - * ```typescript - * import {CORE_DIRECTIVES} from '@angular/common'; - * import {OtherDirective} from './myDirectives'; - * - * @Component({ - * selector: 'my-component', - * templateUrl: 'myComponent.html', - * directives: [CORE_DIRECTIVES, OtherDirective] - * }) - * export class MyComponent { - * ... - * } - * ``` - * - * @stable - */ -export const CORE_DIRECTIVES: Type[] = [ - NgClass, - NgFor, - NgIf, - NgTemplateOutlet, - NgStyle, - NgSwitch, - NgSwitchCase, - NgSwitchDefault, - NgPlural, - NgPluralCase, -]; diff --git a/modules/@angular/common/src/directives/index.ts b/modules/@angular/common/src/directives/index.ts new file mode 100644 index 0000000000..5984efc0a1 --- /dev/null +++ b/modules/@angular/common/src/directives/index.ts @@ -0,0 +1,47 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {Provider} from '@angular/core'; + +import {NgClass} from './ng_class'; +import {NgFor} from './ng_for'; +import {NgIf} from './ng_if'; +import {NgPlural, NgPluralCase} from './ng_plural'; +import {NgStyle} from './ng_style'; +import {NgSwitch, NgSwitchCase, NgSwitchDefault} from './ng_switch'; +import {NgTemplateOutlet} from './ng_template_outlet'; + +export { + NgClass, + NgFor, + NgIf, + NgPlural, + NgPluralCase, + NgStyle, + NgSwitch, + NgSwitchCase, + NgSwitchDefault, + NgTemplateOutlet +}; + +/** + * A collection of Angular directives that are likely to be used in each and every Angular + * application. + */ +export const COMMON_DIRECTIVES: Provider[] = [ + NgClass, + NgFor, + NgIf, + NgTemplateOutlet, + NgStyle, + NgSwitch, + NgSwitchCase, + NgSwitchDefault, + NgPlural, + NgPluralCase, +]; diff --git a/modules/@angular/common/src/pipes.ts b/modules/@angular/common/src/pipes.ts index ec92ae1038..83084589d7 100644 --- a/modules/@angular/common/src/pipes.ts +++ b/modules/@angular/common/src/pipes.ts @@ -11,13 +11,3 @@ * @description * This module provides a set of common Pipes. */ - -export {AsyncPipe} from './pipes/async_pipe'; -export {DatePipe} from './pipes/date_pipe'; -export {I18nPluralPipe} from './pipes/i18n_plural_pipe'; -export {I18nSelectPipe} from './pipes/i18n_select_pipe'; -export {JsonPipe} from './pipes/json_pipe'; -export {LowerCasePipe} from './pipes/lowercase_pipe'; -export {CurrencyPipe, DecimalPipe, PercentPipe} from './pipes/number_pipe'; -export {SlicePipe} from './pipes/slice_pipe'; -export {UpperCasePipe} from './pipes/uppercase_pipe'; diff --git a/modules/@angular/common/src/pipes/common_pipes.ts b/modules/@angular/common/src/pipes/index.ts similarity index 75% rename from modules/@angular/common/src/pipes/common_pipes.ts rename to modules/@angular/common/src/pipes/index.ts index 31fa5b9d46..26d20ae8f9 100644 --- a/modules/@angular/common/src/pipes/common_pipes.ts +++ b/modules/@angular/common/src/pipes/index.ts @@ -21,15 +21,22 @@ import {CurrencyPipe, DecimalPipe, PercentPipe} from './number_pipe'; import {SlicePipe} from './slice_pipe'; import {UpperCasePipe} from './uppercase_pipe'; +export { + AsyncPipe, + CurrencyPipe, + DatePipe, + DecimalPipe, + I18nPluralPipe, + I18nSelectPipe, + JsonPipe, + LowerCasePipe, + PercentPipe, + SlicePipe, + UpperCasePipe +}; /** - * A collection of Angular core pipes that are likely to be used in each and every - * application. - * - * This collection can be used to quickly enumerate all the built-in pipes in the `pipes` - * property of the `@Component` decorator. - * - * @experimental Contains i18n pipes which are experimental + * A collection of Angular pipes that are likely to be used in each and every application. */ export const COMMON_PIPES = [ AsyncPipe,