Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

docs(toh-3/dart): copyedits and new snake_case glossary entry #1629

Merged
merged 2 commits into from
Jun 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions public/docs/_examples/toh-3/dart/lib/app_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'hero_detail_component.dart';

@Component(
selector: 'my-app',
// #docregion hero-detail-template
// #docregion hero-detail-template
template: '''
<h1>{{title}}</h1>
<h2>My Heroes</h2>
Expand All @@ -23,8 +23,9 @@ import 'hero_detail_component.dart';
</ul>
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
''',
// #enddocregion hero-detail-template
styles: const ['''
// #enddocregion hero-detail-template
styles: const [
'''
.selected {
background-color: #CFD8DC !important;
color: white;
Expand Down Expand Up @@ -73,17 +74,16 @@ import 'hero_detail_component.dart';
}
'''
],
// #docregion directives
directives: const [
HeroDetailComponent
])
// #enddocregion directives
// #docregion directives
directives: const [HeroDetailComponent]
// #enddocregion directives
)
class AppComponent {
final String title = 'Tour of Heroes';
final List<Hero> heroes = mockHeroes;
Hero selectedHero;

onSelect(Hero hero) {
void onSelect(Hero hero) {
selectedHero = hero;
}
}
Expand Down
1 change: 0 additions & 1 deletion public/docs/_examples/toh-3/dart/lib/hero.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ class Hero {

Hero(this.id, this.name);
}
// #enddocregion
33 changes: 15 additions & 18 deletions public/docs/_examples/toh-3/dart/lib/hero_detail_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,26 @@ import 'hero.dart';
// #docregion v1
@Component(
selector: 'my-hero-detail',
// #enddocregion v1
// #enddocregion v1
// #docregion template
template: '''
<div *ngIf="hero != null">
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name">
</div>
</div>
'''
<div *ngIf="hero != null">
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name">
</div>
</div>'''
// #enddocregion template
// #docregion v1
// #docregion v1
)
class HeroDetailComponent {
// #enddocregion v1
// #docregion inputs
// #enddocregion v1
// #docregion inputs
@Input()
// #docregion hero
// #docregion hero
Hero hero;
// #enddocregion hero
// #enddocregion inputs
// #docregion v1
// #enddocregion hero, inputs
// #docregion v1
}
// #enddocregion v1
14 changes: 13 additions & 1 deletion public/docs/dart/latest/glossary.jade
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@ include _util-fns
!=partial('../../ts/latest/_fragments/glossary-f-l')
!=partial('../../ts/latest/_fragments/glossary-m1')
//!=partial('../../ts/latest/_fragments/glossary-m2') not needed in dart
!=partial('../../ts/latest/_fragments/glossary-n-s')
!=partial('../../ts/latest/_fragments/glossary-n-s-1')

:marked
## snake_case
.l-sub-section
:marked
The practice of writing compound words or phrases such that each word is separated by an underscore (`_`).

Library and file names are often spelled in snake_case. Examples include: `angular2_tour_of_heroes` and `app_component.dart`.

This form is also known as **underscore case**.

!=partial('../../ts/latest/_fragments/glossary-n-s-2')
!=partial('../../ts/latest/_fragments/glossary-t1')
//!=partial('../../ts/latest/_fragments/glossary-t2') notneeded in dart
!=partial('../../ts/latest/_fragments/glossary-u-z')
Expand Down
3 changes: 1 addition & 2 deletions public/docs/dart/latest/tutorial/toh-pt1.jade
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ include ../_util-fns
.children
.file index.html
.file main.dart
.file styles.css
.file pubspec.yaml

// Add .file styles.css

.p &nbsp;

.callout.is-helpful
Expand Down
1 change: 1 addition & 0 deletions public/docs/dart/latest/tutorial/toh-pt2.jade
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ p Run the #[+liveExampleLink2('', 'toh-2')] for this part.
.children
.file index.html
.file main.dart
.file styles.css
.file pubspec.yaml
:marked
### Keep the app compiling and running
Expand Down
23 changes: 14 additions & 9 deletions public/docs/dart/latest/tutorial/toh-pt3.jade
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ p Run the #[+liveExampleLink2('', 'toh-3')] for this part.
.children
.file index.html
.file main.dart
.file styles.css
.file pubspec.yaml
:marked
### Keep the app compiling and running
We want to start the Dart compiler, have it watch for changes, and start our server. We'll do this by typing

code-example(format="." language="bash").
code-example(language="bash").
pub serve

:marked
Expand All @@ -50,7 +51,7 @@ code-example(format="." language="bash").
### Separating the Hero Detail Component
Add a new file named `hero_detail_component.dart` to the `lib` folder and create `HeroDetailComponent` as follows.

+makeExample('toh-3/dart/lib/hero_detail_component.dart', 'v1', 'hero_detail_component.dart (initial version)')(format=".")
+makeExample('toh-3/dart/lib/hero_detail_component.dart', 'v1', 'lib/hero_detail_component.dart (initial version)')(format=".")
.l-sub-section
:marked
### Naming conventions
Expand All @@ -61,7 +62,8 @@ code-example(format="." language="bash").

All of our component names end in "Component". All of our component file names end in "_component".

We spell our filenames in lower underscore case (AKA "snake_case") so we don't worry about
We spell our filenames in lower **underscore case**
(AKA **[snake_case](../guide/glossary.html#!#snake_case)**) so we don't worry about
case sensitivity on the server or in source control.

<!-- TODO
Expand Down Expand Up @@ -89,26 +91,26 @@ code-example(format="." language="bash").
So we replace `selectedHero` with `hero` everywhere in our new template. That's our only change.
The result looks like this:

+makeExample('toh-3/dart/lib/hero_detail_component.dart', 'template', 'hero_detail_component.dart (template)')(format=".")
+makeExample('toh-3/dart/lib/hero_detail_component.dart', 'template', 'lib/hero_detail_component.dart (template)')(format=".")

:marked
Now our hero detail layout exists only in the `HeroDetailComponent`.

#### Add the *hero* property
Let’s add that `hero` property we were talking about to the component class.
+makeExample('toh-3/dart/lib/hero_detail_component.dart', 'hero')(format=".")
+makeExample('toh-3/dart/lib/hero_detail_component.dart', 'hero')
:marked
Uh oh. We declared the `hero` property as type `Hero` but our `Hero` class is over in the `app_component.dart` file.
We have two components, each in their own file, that need to reference the `Hero` class.

We solve the problem by relocating the `Hero` class from `app_component.dart` to its own `hero.dart` file.

+makeExample('toh-3/dart/lib/hero.dart', null, 'hero.dart (Exported Hero class)')(format=".")
+makeExample('toh-3/dart/lib/hero.dart', '', 'lib/hero.dart')(format=".")

:marked
Add the following import statement near the top of both `app_component.dart` and `hero_detail_component.dart`.
Add the following import statement near the top of **both `app_component.dart` and `hero_detail_component.dart`**.

+makeExample('toh-3/dart/lib/hero_detail_component.dart', 'hero-import', 'hero_detail_component.dart and app_component.dart (Import the Hero class)')(format=".")
+makeExample('toh-3/dart/lib/hero_detail_component.dart', 'hero-import')

:marked
#### The *hero* property is an ***input***
Expand Down Expand Up @@ -167,7 +169,7 @@ code-example(format=".")
:marked
The `AppComponent`’s template should now look like this

+makeExample('toh-3/dart/lib/app_component.dart', 'hero-detail-template', 'app_component.dart (Template)')(format=".")
+makeExample('toh-3/dart/lib/app_component.dart', 'hero-detail-template', 'app_component.dart (template)')(format=".")
:marked
Thanks to the binding, the `HeroDetailComponent` should receive the hero from the `AppComponent` and display that hero's detail beneath the list.
The detail should update every time the user picks a new hero.
Expand Down Expand Up @@ -213,6 +215,7 @@ code-example(format=".")
.children
.file index.html
.file main.dart
.file styles.css
.file pubspec.yaml
:marked
Here are the code files we discussed in this chapter.
Expand All @@ -237,6 +240,8 @@ code-example(format=".")
* We learned to bind a parent component to a child component.
* We learned to declare the application directives we need in a `directives` list.

p Run the #[+liveExampleLink2('', 'toh-3')] for this part.

.l-main-section
:marked
## The Road Ahead
Expand Down
19 changes: 10 additions & 9 deletions public/docs/ts/latest/glossary.jade
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ include _util-fns
## dash-case
.l-sub-section
:marked
The practice of writing compound words or phrases such that each word is separated by a dash or hyphen (-).
The practice of writing compound words or phrases such that each word is separated by a dash or hyphen (`-`).

Directive selectors and the root of filenames are often spelled in dash-case. Examples include: `my-app` and the `hero-list.component.ts`.
Directive selectors and the root of filenames are often spelled in dash-case. Examples include: `my-app` and `hero-list.component.ts`.

This form is also known as [kebab-case](#kebab-case).

Expand Down Expand Up @@ -408,9 +408,9 @@ include _util-fns
## kebab-case
.l-sub-section
:marked
The practice of writing compound words or phrases such that each word is separated by a dash or hyphen (-).
The practice of writing compound words or phrases such that each word is separated by a dash or hyphen (`-`).

Directive selectors and the root of filenames are often spelled in kebab-case. Examples include: `my-app` and the `hero-list.component.ts`.
Directive selectors and the root of filenames are often spelled in kebab-case. Examples include: `my-app` and `hero-list.component.ts`.

This form is also known as [dash-case](#dash-case).

Expand Down Expand Up @@ -480,7 +480,7 @@ include _util-fns

// #enddocregion m2

// #docregion n-s
// #docregion n-s-1
- var lang = current.path[1]
- var decorator = lang === 'dart' ? 'annotation' : '<a href="#decorator">decorator</a>'
- var atSym = lang === 'js' ? '' : '@'
Expand Down Expand Up @@ -570,6 +570,7 @@ include _util-fns

<a id="S"></a>
.l-main-section
// #enddocregion n-s-1
:marked
## Scoped Package
.l-sub-section
Expand All @@ -582,9 +583,9 @@ include _util-fns
We import a scoped package the same way we'd import a *normal* package.
The only difference, from a consumer perspective,
is that the package name begins with the Angular *scope name*, `@angular`.
// #enddocregion n-s
+makeExample('../docs/_fragments/architecture/ts/app/app.component.ts', 'import')(format=".")
// #docregion n-s

+makeExample('../docs/_fragments/architecture/ts/app/app.component.ts', 'import')(format=".")
// #docregion n-s-2

:marked
## Structural Directive
Expand All @@ -596,7 +597,7 @@ include _util-fns

The `ngIf` "conditional element" directive and the `ngFor` "repeater" directive are
good examples in this category.
// #enddocregion n-s
// #enddocregion n-s-2

// #docregion t1
<a id="T"></a>
Expand Down