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

Commit d1907db

Browse files
committed
docs: revert Jade to markdown
Previously, the markdown of some chapters was converted to Jade markup to support the conditional exclusion of TS prose parts in Dart chapters. This commit reverts some of that back to clean markdown, thanks to a few custom directives.
1 parent dba3a8f commit d1907db

33 files changed

+366
-170
lines changed

public/_includes/_scripts-include.jade

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ script(src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular
2121

2222
<!-- Angular.io Site JS -->
2323
script(src="/resources/js/site.js")
24+
script(src="/resources/js/util.js")
2425
script(src="/resources/js/controllers/app-controller.js")
2526
script(src="/resources/js/controllers/resources-controller.js")
2627
script(src="/resources/js/directives/cheatsheet.js")
@@ -32,6 +33,9 @@ script(src="/resources/js/directives/copy.js")
3233
script(src="/resources/js/directives/code-tabs.js")
3334
script(src="/resources/js/directives/code-pane.js")
3435
script(src="/resources/js/directives/code-example.js")
36+
script(src="/resources/js/directives/if-docs.js")
37+
script(src="/resources/js/directives/live-example.js")
38+
script(src="/resources/js/directives/ngio-ex-path.js")
3539
script(src="/resources/js/directives/scroll-y-offset-element.js")
3640

3741
<!-- GA -->

public/docs/dart/latest/_util-fns.jade

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ include ../../../_includes/_util-fns
2020
- var _indexHtmlDir = 'web';
2121
- var _mainDir = 'web';
2222

23+
//- Deprecated
2324
mixin liveExampleLink(linkText, exampleUrlPartName)
2425
- var text = linkText || 'live example';
2526
- var ex = exampleUrlPartName || getExampleName();
2627
- var href = 'http://angular-examples.github.io/' + ex;
2728
a(href='#{href}' target="_blank")= text
2829

30+
//- Deprecated
2931
mixin liveExampleLink2(linkText, exampleUrlPartName)
3032
- var srcText = attributes.srcText || 'view source';
3133
- var ex = exampleUrlPartName || attributes.example || getExampleName();

public/docs/dart/latest/guide/dependency-injection.jade

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,12 @@ block ctor-syntax
1010
We also leveraged Dart's constructor syntax for declaring parameters and
1111
initializing properties simultaneously.
1212

13-
block service-in-its-own-file
14-
//- N/A
15-
16-
block one-class-per-file-ts-tradeoffs
17-
//- N/A
18-
1913
block injectable-not-always-needed-in-ts
2014
//- The [Angular 2 Dart Transformer](https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer)
2115
//- generates static code to replace the use of dart:mirrors. It requires that types be
2216
//- identified as targets for static code generation. Generally this is achieved
2317
//- by marking the class as @Injectable (though there are other mechanisms).
2418
25-
block ts-any-decorator-will-do
26-
//- N/A
27-
2819
block always-include-paren
2920
:marked
3021
Always write `@Injectable()`, not just `@Injectable`.
@@ -43,11 +34,6 @@ block real-logger
4334
A real implementation would probably use the
4435
[logging package](https://pub.dartlang.org/packages/logging).
4536

46-
block canonical-provider-expr
47-
| &nbsp;that creates a new instance of the&nbsp;
48-
a(href="../api/core/Provider-class.html") Provider
49-
| &nbsp;class:
50-
5137
block provider-ctor-args
5238
- var _secondParam = 'named parameter, such as <code>useClass</code>'
5339
:marked

public/docs/dart/latest/guide/server-communication.jade

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@ block includes
88
- var _Angular_http_library = 'Dart <a href="' + _httpUrl + '"><b>http</b></a> library'
99

1010
block demos-list
11-
li #[a(href="#http-client") HTTP client: Tour of Heroes]
12-
li #[a(href="#cors") JSONP client: Wikipedia to fetch data from a service that does not support CORS] #[b (under development)]
13-
14-
block rxjs-import
15-
//- N/A
16-
17-
block http-client
18-
19-
block system-config-of-http
20-
//- N/A
11+
:marked
12+
- [HTTP client: Tour of Heroes](#http-client)
13+
- [JSONP client: Wikipedia to fetch data from a service that does not support CORS (**under development**)](#cors)
2114

2215
block http-providers
2316
:marked
@@ -50,9 +43,6 @@ block getheroes-and-addhero
5043
programming in Dart, or the tutorial on
5144
[_Asynchronous Programming: Futures_](https://www.dartlang.org/docs/tutorials/futures/).
5245

53-
block rxjs
54-
//- N/A
55-
5646
block parse-json
5747
:marked
5848
The response data are in JSON string form.
@@ -65,7 +55,7 @@ block error-handling
6555
block hlc-error-handling
6656
:marked
6757
Back in the `HeroListComponent`, we wrapped our call to
68-
`#{_priv}heroService.getHeroes()` in a `try` clause. When an exception is
58+
`!{_priv}heroService.getHeroes()` in a `try` clause. When an exception is
6959
caught, the `errorMessage` variable &mdash; which we've bound conditionally in the
7060
template &mdash; gets assigned to.
7161

@@ -75,9 +65,6 @@ block hero-list-comp-add-hero
7565
awaits for the *service's* asynchronous `addHero()` to return, and when it does,
7666
the new hero is added to the `heroes` list for presentation to the user.
7767

78-
block promises
79-
//- N/A
80-
8168
block wikipedia-jsonp+
8269
:marked
8370
Wikipedia offers a modern `CORS` API and a legacy `JSONP` search API.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
include ../_util-fns
22

33
+includeShared('{ts}', 'intro')
4-
5-
p Run the #[+liveExampleLink2('', 'toh-5')].
6-
74
+includeShared('{ts}', 'main')
85

public/docs/dart/latest/tutorial/toh-pt1.jade

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ include ../_util-fns
3333

3434
.callout.is-helpful
3535
header Source code
36-
p Run the #[+liveExampleLink2('', 'toh-1')] for this part.
36+
:marked
37+
Run the <live-example></live-example> for this part.
3738

3839
:marked
3940
## Keep the app compiling and running

public/docs/dart/latest/tutorial/toh-pt2.jade

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ include ../_util-fns
66
We’ll expand our Tour of Heroes app to display a list of heroes,
77
allow the user to select a hero, and display the hero’s details.
88

9-
p Run the #[+liveExampleLink2('', 'toh-2')] for this part.
10-
:marked
9+
Run the <live-example></live-example> for this part.
10+
1111
Let’s take stock of what we’ll need to display a list of heroes.
1212
First, we need a list of heroes. We want to display those heroes in the view’s template,
1313
so we’ll need a way to do that.
@@ -294,8 +294,8 @@ code-example(language="bash").
294294
* We added the ability to select a hero and show the hero’s details
295295
* We learned how to use the built-in directives `ngIf` and `ngFor` in a component’s template
296296

297-
p Run the #[+liveExampleLink2('', 'toh-2')] for this part.
298-
:marked
297+
Run the <live-example></live-example> for this part.
298+
299299
### The Road Ahead
300300
Our Tour of Heroes has grown, but it’s far from complete.
301301
We can't put the entire app into a single component.

public/docs/dart/latest/tutorial/toh-pt3.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include ../_util-fns
44
Our app is growing.
55
Use cases are flowing in for reusing components, passing data to components, and creating more reusable assets. Let's separate the heroes list from the hero details and make the details component reusable.
66

7-
p Run the #[+liveExampleLink2('', 'toh-3')] for this part.
7+
Run the <live-example></live-example> for this part.
88

99
.l-main-section
1010
:marked
@@ -240,7 +240,7 @@ code-example(format=".")
240240
* We learned to bind a parent component to a child component.
241241
* We learned to declare the application directives we need in a `directives` list.
242242

243-
p Run the #[+liveExampleLink2('', 'toh-3')] for this part.
243+
Run the <live-example></live-example> for this part.
244244

245245
.l-main-section
246246
:marked

public/docs/dart/latest/tutorial/toh-pt4.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include ../_util-fns
1515
Because data services are invariably asynchronous,
1616
we'll finish the chapter with a **!{_Promise}**-based version of the data service.
1717

18-
p Run the #[+liveExampleLink2('', 'toh-4')] for this part.
18+
Run the <live-example></live-example> for this part.
1919

2020
.l-main-section
2121
:marked

public/docs/dart/latest/tutorial/toh-pt5.jade

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ figure.image-display
1818
The [Routing and Navigation](../guide/router.html) chapter covers the router in more detail
1919
than we will in this tutorial.
2020

21-
p Run the #[+liveExampleLink2('', 'toh-5')] for this part.
21+
Run the <live-example></live-example> for this part.
2222

2323
.l-main-section
2424
:marked
@@ -653,11 +653,10 @@ figure.image-display
653653
.l-main-section
654654
:marked
655655
## Application structure and code
656-
p.
657-
Review the sample source code in the #[+liveExampleLink2('', 'toh-5')] for this chapter.
656+
657+
Review the sample source code in the <live-example></live-example> for this chapter.
658658
Verify that we have the following structure:
659659

660-
:marked
661660
.filetree
662661
.file angular2_tour_of_heroes
663662
.children

public/docs/ts/latest/_util-fns.jade

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ include ../../../_includes/_util-fns
44
- var _docsFor = 'ts';
55
//- Other values match the defaults.
66
7+
//- Deprecated
78
mixin liveExampleLink(linkText, exampleUrlPartName)
89
- var text = linkText || 'live example';
910
- var ex = exampleUrlPartName || getExampleName();
1011
- var href = '/resources/live-examples/' + ex + '/ts/plnkr.html';
1112
a(href='#{href}' target="_blank")= text
1213

14+
//- Deprecated
1315
mixin liveExampleLink2(linkText, exampleUrlPartName)
1416
//- In Dart this gives 2 links: to the demo and to the source.
1517
+liveExampleLink(linkText, exampleUrlPartName)

public/docs/ts/latest/guide/attribute-directives.jade

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ block includes
1111
* [respond to user-initiated events](#respond-to-user)
1212
* [pass values into the directive using data binding](#bindings)
1313

14-
p Try the #[+liveExampleLink2()].
14+
Try the <live-example></live-example>.
1515

16-
:marked
1716
## Directives overview
1817

1918
There are three kinds of directives in Angular:

public/docs/ts/latest/guide/component-styles.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ block includes
2020
* [Appendix 1: Inspecting the generated runtime component styles](#inspect-generated-css)
2121
* [Appendix 2: Loading Styles with Relative URLs](#relative-urls)
2222

23-
p Run the #[+liveExampleLink2()] of the code shown in this chapter.
23+
Run the <live-example></live-example> of the code shown in this chapter.
2424

2525
.l-main-section
2626
:marked

public/docs/ts/latest/guide/dependency-injection.jade

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ block includes
1717
- [Dependency injection tokens](#dependency-injection-tokens)
1818
- [Summary](#summary)
1919

20-
p Run the #[+liveExampleLink2()].
20+
Run the <live-example></live-example>.
2121

2222
.l-main-section#why-di
2323
:marked
@@ -427,7 +427,7 @@ block injectable-not-always-needed-in-ts
427427
fact `InjectableMetadata` #{_decorator}s that
428428
identify a class as a target for instantiation by an injector.
429429

430-
block ts-any-decorator-will-do
430+
+ifDocsFor('ts')
431431
.l-sub-section
432432
:marked
433433
Injectors use a class's constructor metadata to determine dependent types as
@@ -508,20 +508,25 @@ code-example(format="nocode").
508508
What matters is that the injector has a provider to go to when it needs a `Logger`.
509509

510510
//- Dart limitation: the provide function isn't const so it cannot be used in an annotation.
511-
- var __andProvideFn = _docsFor == 'dart' ? '' : 'and <i>provide</i> object literal';
511+
- var _andProvideFn = _docsFor == 'dart' ? '' : 'and <i>provide</i> object literal';
512512
#provide
513513
:marked
514-
### The *Provider* class !{__andProvideFn}
514+
### The *Provider* class !{_andProvideFn}
515515

516516
:marked
517517
We wrote the `providers` #{_array} like this:
518518

519519
+makeExample('dependency-injection/ts/app/providers.component.ts','providers-1')
520520

521-
p
522-
| This is actually a short-hand expression for a provider registration
523-
block canonical-provider-expr
524-
| &nbsp;using a <i>provider</i> object literal with two properties:
521+
:marked
522+
This is actually a short-hand expression for a provider registration
523+
<span if-docs="ts">
524+
using a _provider_ object literal with two properties:
525+
</span>
526+
<span if-docs="dart">
527+
that creates a new instance of the
528+
[Provider](../api/core/Provider-class.html) class:
529+
</span>
525530

526531
+makeExample('dependency-injection/ts/app/providers.component.ts','providers-3')
527532

@@ -861,7 +866,7 @@ block dart-map-alternative
861866
Framework developers may take this approach when they
862867
must acquire services generically and dynamically.
863868

864-
block one-class-per-file-ts-tradeoffs
869+
+ifDocsFor('ts')
865870
.l-main-section#one-class-per-file
866871
:marked
867872
## Appendix: Why we recommend one class per file

public/docs/ts/latest/guide/hierarchical-dependency-injection.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ block includes
1313

1414
In this chapter we explore these points and write some code.
1515

16-
p Try the #[+liveExampleLink2()].
16+
Try the <live-example></live-example>.
1717

1818
.l-main-section
1919
:marked

public/docs/ts/latest/guide/lifecycle-hooks.jade

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ block includes
2424
* [AfterViewInit and AfterViewChecked](#afterview)
2525
* [AfterContentInit and AfterContentChecked](#aftercontent)
2626

27-
p Try the #[+liveExampleLink2()].
27+
Try the <live-example></live-example>.
2828

2929
a#hooks-overview
3030
.l-main-section
@@ -195,14 +195,14 @@ a(id="other-lifecycles")
195195
3rd party libraries might implement their hooks as well in order to give us, the developers, more
196196
control over how these libraries are used.
197197

198-
a#the-sample
199-
.l-main-section
200-
h2 Lifecycle exercises
201-
p.
202-
The #[+liveExampleLink()]
198+
.l-main-section#the-sample
199+
:marked
200+
## Lifecycle exercises
201+
202+
The <live-example></live-example>
203203
demonstrates the lifecycle hooks in action through a series of exercises
204204
presented as components under the control of the root `AppComponent`.
205-
:marked
205+
206206
They follow a common pattern: a *parent* component serves as a test rig for
207207
a *child* component that illustrates one or more of the lifecycle hook methods.
208208

public/docs/ts/latest/guide/pipes.jade

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ block includes
1515
desire many of the same transformations repeatedly, both within and across many applications.
1616
We almost think of them as styles.
1717
In fact, we'd like to apply them in our HTML templates as we do styles.
18-
p.
18+
1919
Introducing Angular pipes, a way to write display-value transformations that we can declare in our HTML!
20-
Try the #[+liveExampleLink2()].
20+
Try the <live-example></live-example>.
2121

2222
.l-main-section
2323
:marked
@@ -168,11 +168,10 @@ figure.image-display
168168
Angular built-in pipes are pre-registered.
169169
Custom pipes must be registered manually.
170170

171-
p.
172-
If we try the #[+liveExampleLink()],
171+
:marked
172+
If we try the <live-example></live-example>,
173173
we can probe its behavior by changing the value and the optional exponent in the template.
174174

175-
:marked
176175
## Power Boost Calculator (extra-credit)
177176

178177
It's not much fun updating the template to test our custom pipe.
@@ -219,10 +218,10 @@ a#change-detection
219218
Here's the `FlyingHeroesPipe` implementation which follows the pattern for custom pipes we saw earlier.
220219
+makeExample('pipes/ts/app/flying-heroes.pipe.ts', 'pure', 'app/flying-heroes.pipe.ts')(format='.')
221220

222-
p.
223-
When we run the sample now we see odd behavior (try it in the #[+liveExampleLink()]).
224-
Every hero we add is a flying hero but none of them are displayed.
225221
:marked
222+
When we run the sample now we see odd behavior (try it in the <live-example></live-example>).
223+
Every hero we add is a flying hero but none of them are displayed.
224+
226225
Although we're not getting the behavior we want, Angular isn't broken.
227226
It's just using a different change detection algorithm &mdash; one that ignores changes to the list or any of its items.
228227

@@ -328,11 +327,10 @@ block pure-change
328327

329328
We can derive a `FlyingHeroesImpureComponent` that we derive from the `FlyingHeroesComponent`.
330329
+makeExample('pipes/ts/app/flying-heroes.component.ts','impure-component','app/flying-heroes.component.ts (FlyingHeroesImpureComponent)')(format='.')
331-
p.
330+
:marked
332331
The only substantive change is the pipe.
333-
We can confirm in the #[+liveExampleLink()] that the #[i flying heroes]
334-
display updates as we enter new heroes even when we mutate the
335-
#[code heroes] #{_array}.
332+
We can confirm in the <live-example></live-example> that the _flying heroes_
333+
display updates as we enter new heroes even when we mutate the `heroes` #{_array}.
336334

337335
- var _dollar = _docsFor === 'ts' ? '$' : '';
338336
h3#async-pipe The impure #[i AsyncPipe]

0 commit comments

Comments
 (0)