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

Commit 6d2d52c

Browse files
chalinkwalrath
authored andcommitted
docs(dart): cleanup 'live example' links (#1449)
This fixes various issues such as: - missing space in Dart version between the live demo and demo source links. - Live example link directing to Plunker for Dart. The main mixins (`liveExampleLink`*) used to support the generation of links now assume reasonable default values for their arguments, and in most cases the defaults are used. * Dart example links: use http vs https As agree to with @kwalrath.
1 parent 12984fd commit 6d2d52c

10 files changed

Lines changed: 41 additions & 34 deletions

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ include ../../../_includes/_util-fns
1414
- var _liveLink = 'sample repo';
1515

1616
mixin liveExampleLink(linkText, exampleUrlPartName)
17-
a(href='https://angular-examples.github.io/#{exampleUrlPartName}' target="_blank")= linkText
17+
- var text = linkText || 'live example';
18+
- var ex = exampleUrlPartName || getExampleName();
19+
- var href = 'http://angular-examples.github.io/' + ex;
20+
a(href='#{href}' target="_blank")= text
1821

1922
mixin liveExampleLink2(linkText, exampleUrlPartName)
20-
- var liveExampleSourceLinkText = attributes.srcLinkText || 'view source'
21-
| #[+liveExampleLink(linkText, exampleUrlPartName)]
22-
| (#[a(href='https://github.com/angular-examples/#{exampleUrlPartName}' target="_blank") #{liveExampleSourceLinkText}])
23+
- var srcText = attributes.srcText || 'view source';
24+
- var ex = exampleUrlPartName || attributes.example || getExampleName();
25+
- var href = 'http://github.com/angular-examples/' + ex;
26+
span #[+liveExampleLink(linkText, ex)] (#[a(href='#{href}' target="_blank") #{srcText}])
2327

2428
- var adjustExamplePath = function(_path) {
2529
- if(!_path) return _path;

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ include ../../../_includes/_util-fns
55
//- Other values match the defaults.
66
77
mixin liveExampleLink(linkText, exampleUrlPartName)
8-
a(href='/resources/live-examples/#{exampleUrlPartName}/ts/plnkr.html' target="_blank")= linkText
8+
- var text = linkText || 'live example';
9+
- var ex = exampleUrlPartName || getExampleName();
10+
- var href = '/resources/live-examples/' + ex + '/ts/plnkr.html';
11+
a(href='#{href}' target="_blank")= text
912

1013
mixin liveExampleLink2(linkText, exampleUrlPartName)
11-
//- In Dart this also gives a link to the source.
12-
| #[+liveExampleLink(linkText, exampleUrlPartName)]
14+
//- In Dart this gives 2 links: to the demo and to the source.
15+
+liveExampleLink(linkText, exampleUrlPartName)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ block includes
1010
* [apply the attribute directive to an element in a template](#apply-directive)
1111
* [respond to user-initiated events](#respond-to-user)
1212
* [pass values into the directive using data binding](#bindings)
13-
p.
14-
#[+liveExampleLink2('Live example', 'attribute-directives')].
13+
14+
p Try the #[+liveExampleLink2()].
15+
1516
:marked
1617
## Directives overview
1718

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ block includes
1919
* [Controlling View Encapsulation: Emulated, Native, and None](#view-encapsulation)
2020
* [Appendix 1: Inspecting the generated runtime component styles](#inspect-generated-css)
2121
* [Appendix 2: Loading Styles with Relative URLs](#relative-urls)
22-
p
23-
| #[+liveExampleLink2('Run the live example', 'component-styles')] 
24-
| of the code shown in this chapter.
22+
23+
p Run the #[+liveExampleLink2()] of the code shown in this chapter.
2524

2625
.l-main-section
2726
:marked

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ block includes
1212
interesting and useful results.
1313

1414
In this chapter we explore these points and write some code.
15-
p
16-
| Try the #[+liveExampleLink2('live example', 'hierarchical-dependency-injection')].
15+
16+
p Try the #[+liveExampleLink2()].
1717

1818
.l-main-section
1919
:marked

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

Lines changed: 2 additions & 2 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('live example', 'lifecycle-hooks')].
27+
p Try the #[+liveExampleLink2()].
2828

2929
a#hooks-overview
3030
.l-main-section
@@ -199,7 +199,7 @@ a#the-sample
199199
.l-main-section
200200
h2 Lifecycle exercises
201201
p.
202-
The #[+liveExampleLink('live example', 'lifecycle-hooks')]
202+
The #[+liveExampleLink()]
203203
demonstrates the lifecycle hooks in action through a series of exercises
204204
presented as components under the control of the root `AppComponent`.
205205
:marked

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ block includes
1717
In fact, we'd like to apply them in our HTML templates as we do styles.
1818
p.
1919
Welcome, Angular pipes, the simple display-value transformations that we can declare in our HTML!
20-
Try the #[+liveExampleLink2('live example', 'pipes')].
20+
Try the #[+liveExampleLink2()].
2121

2222
.l-main-section
2323
:marked
@@ -169,7 +169,7 @@ figure.image-display
169169
Custom pipes must be registered manually.
170170

171171
p.
172-
If we try the #[+liveExampleLink('live code', 'pipes')] example,
172+
If we try the #[+liveExampleLink()],
173173
we can probe its behavior by changing the value and the optional exponent in the template.
174174

175175
:marked
@@ -219,10 +219,10 @@ a#change-detection
219219
Here's the `FlyingHeroesPipe` implementation which follows the pattern for custom pipes we saw earlier.
220220
+makeExample('pipes/ts/app/flying-heroes.pipe.ts', 'pure', 'app/flying-heroes.pipe.ts')(format='.')
221221

222-
:marked
223-
When we run the sample now we see odd behavior (try it in the [live example](/resources/live-examples/pipes/ts/plnkr.html)).
222+
p.
223+
When we run the sample now we see odd behavior (try it in the #[+liveExampleLink()]).
224224
Every hero we add is a flying hero but none of them are displayed.
225-
225+
:marked
226226
Although we're not getting the behavior we want, Angular isn't broken.
227227
It's just using a different change detection algorithm — one that ignores changes to the list or any of its items.
228228

@@ -238,7 +238,7 @@ a#change-detection
238238

239239
*If we **mutate** the #{_array}, no pipe is invoked and no display updated;
240240
if we **replace** the #{_array}, then the pipe executes and the display is updated*.
241-
The *Flying Heroes* in the [live example](/resources/live-examples/pipes/ts/plnkr.html) extends the
241+
The *Flying Heroes* extends the
242242
code with checkbox switches and additional displays to help us experience these effects.
243243

244244
figure.image-display
@@ -328,15 +328,15 @@ block pure-change
328328

329329
We can derive a `FlyingHeroesImpureComponent` that we derive from the `FlyingHeroesComponent`.
330330
+makeExample('pipes/ts/app/flying-heroes.component.ts','impure-component','app/flying-heroes.component.ts (FlyingHeroesImpureComponent)')(format='.')
331-
:marked
331+
p.
332332
The only substantive change is the pipe.
333-
We can confirm in the [live example](/resources/live-examples/pipes/ts/plnkr.html)
334-
that the *flying heroes* display updates as we enter new heroes even when we mutate the `heroes` #{_array}.
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}.
336+
335337
- var _dollar = _docsFor === 'ts' ? '$' : '';
338+
h3#async-pipe The impure #[i AsyncPipe]
336339
:marked
337-
<a id="async-pipe"></a>
338-
### The impure *AsyncPipe*
339-
340340
The Angular `AsyncPipe` is an interesting example of an impure pipe.
341341
The `AsyncPipe` accepts a `#{_Promise}` or `#{_Observable}` as input
342342
and subscribes to the input automatically, eventually returning the emitted value(s).

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ ul
3636
li #[a(href="#search-parameters") Set query string parameters]
3737
li #[a(href="#more-observables") Debounce search term input]
3838
li #[a(href="#in-mem-web-api") Appendix: the in-memory web api service]
39-
p.
39+
p.
4040
We illustrate these topics with code that you can
41-
#[+liveExampleLink2('run live in a browser', 'server-communication')].
41+
#[+liveExampleLink2('run live in a browser')].
4242

4343
.l-main-section
4444
h1 Demos
@@ -694,4 +694,4 @@ block redirect-to-web-api
694694
p Here is the revised (and final) version of the #[code #[+adjExPath('app/main.ts')]] demonstrating these steps.
695695
+makeExample('server-communication/ts/app/main.ts', 'final', 'app/main.ts (final)')(format=".")
696696

697-
p See the full source code in the #[+liveExampleLink2('live example', 'server-communication')].
697+
p See the full source code in the #[+liveExampleLink2()].

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ block includes
1414
- [discover the &lt;template> element](#template)
1515
- [understand the asterisk (\*) in **ngFor*](#asterisk)
1616
- [write our own structural directive](#unless)
17-
p
18-
| Try the #[+liveExampleLink2('live example', 'structural-directives')].
17+
18+
p Try the #[+liveExampleLink2()].
1919

2020
<a id="definition"></a>
2121
.l-main-section

public/docs/ts/latest/quickstart.jade

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

2323
h1 Try it!
2424
p
25-
| Try the #[+liveExampleLink2('live example', 'quickstart')] which loads the sample app
25+
| Try the #[+liveExampleLink2()] which loads the sample app
2626
+ifDocsFor('ts')
2727
| &nbsp;in #[a(href="http://plnkr.co/" title="Plunker" target="_blank") plunker]
2828
| &nbsp;and displays the simple message:

0 commit comments

Comments
 (0)