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

Commit c8f805a

Browse files
committed
chore(quickstart/dart): updated prose and example code
Recreated prose as extension of TS prose. Code was updated to conform to the organization of the app given on the TS side. I.e., the app component was factored out into its own file. E2e tests pass :).
1 parent d8cdee3 commit c8f805a

File tree

6 files changed

+199
-209
lines changed

6 files changed

+199
-209
lines changed

public/_includes/_util-fns.jade

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@
44
//- Should be one of: 'ts', 'dart' or 'js'. Set in lang specific _util-fns file.
55
- var _docsFor = '';
66

7+
//- Should match `_docsFor`, but in this case provides the full capitalized
8+
//- name of the language.
9+
- var _Lang = 'TypeScript';
10+
711
//- Simple "macros" used via interpolation in text:
812
//- e.g., the #{_priv}el variable has an `@Input` #{_decorator}.
913
1014
//- Use #{_decorator} whereever the word "decorator" is expected, provided it is not
1115
//- preceded by the article "a". (E.g., will be "annotation" for Dart)
1216
- var _decorator = 'decorator';
1317

18+
//- Articles (which toggle between 'a' and 'an'). Used for, e.g.,
19+
//- array vs. list; decorator vs. annotation.
20+
- var _a = 'a';
21+
- var _an = 'an';
22+
1423
//- TS arrays vs. Dart lists
1524
- var _array = 'array';
25+
//- Deprecate now that we have the articles _a and _an
1626
- var _an_array = 'an array';
1727

1828
//- Promise vs. Future, etc
@@ -48,6 +58,7 @@ mixin makeExample(_filePath, region, _title, stylePatterns)
4858
- var frag = getFrag(filePath, region);
4959
- var defaultFormat = frag.split('\n').length > 2 ? "linenums" : "";
5060
- var format = attributes.format || defaultFormat;
61+
- if (attributes.format === '.') format = '';
5162
- var avoid = !!attributes.avoid;
5263

5364
if (title)
@@ -57,6 +68,13 @@ mixin makeExample(_filePath, region, _title, stylePatterns)
5768
.example-title #{title}
5869
code-example(language="#{language}" format="#{format}")
5970
!= styleString(frag, stylePatterns)
71+
72+
//- Like makeExample, but doesn't show line numbers and
73+
//- title is appened with `(excerpt)` if it doesn't already
74+
//- end with a parenthetical remark.
75+
mixin makeExcerpt(_filePath, region, _title, stylePatterns)
76+
- if (_title && !_title.match(/\([\w ]+\)$/)) _title = _title + ' (excerpt)';
77+
+makeExample(_filePath, region, _title, stylePatterns)(format='')
6078

6179
mixin makeTabs(filePaths, regions, tabNames, stylePatterns)
6280
- filePaths = strSplit(filePaths);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// #docregion
2+
// #docregion import
3+
import 'package:angular2/core.dart';
4+
// #enddocregion import
5+
6+
// #docregion metadata
7+
@Component(
8+
selector: 'my-app',
9+
template: '<h1>My First Angular 2 App</h1>')
10+
// #enddocregion metadata
11+
// #docregion class
12+
class AppComponent {}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// #docregion
2-
import 'package:angular2/core.dart';
32
import 'package:angular2/platform/browser.dart';
43

5-
@Component(selector: 'my-app', template: '<h1>My First Angular 2 App</h1>')
6-
class AppComponent {}
4+
import 'package:angular2_getting_started/app_component.dart';
75

8-
main() {
6+
void main() {
97
bootstrap(AppComponent);
108
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* #docregion */
2+
h1 {
3+
color: #369;
4+
font-family: Arial, Helvetica, sans-serif;
5+
font-size: 250%;
6+
}
7+
body {
8+
margin: 2em;
9+
}

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ include ../../../_includes/_util-fns
44
- var _docsFor = 'dart';
55
- var _decorator = 'annotation';
66
- var _array = 'list';
7-
- var _an_array = 'a list';
7+
- var _an_array = 'a list'; //- Deprecate now that we have the articles
8+
- var _a = 'an';
9+
- var _an = 'a';
810
- var _priv = '_';
11+
- var _Lang = 'Dart';
912
- var _Promise = 'Future';
1013
- var _Observable = 'Stream';
1114

1215
mixin liveExampleLink(linkText, exampleUrlPartName)
13-
a(href='https://angular-examples.github.io/#{exampleUrlPartName}')= linkText
16+
a(href='https://angular-examples.github.io/#{exampleUrlPartName}' target="_blank")= linkText
1417

1518
mixin liveExampleLink2(linkText, exampleUrlPartName)
1619
- var liveExampleSourceLinkText = attributes.srcLinkText || 'view source'
1720
| #[+liveExampleLink(linkText, exampleUrlPartName)]
18-
| (#[a(href='https://github.com/angular-examples/#{exampleUrlPartName}') #{liveExampleSourceLinkText}])
21+
| (#[a(href='https://github.com/angular-examples/#{exampleUrlPartName}' target="_blank") #{liveExampleSourceLinkText}])
1922

2023
- var adjustExamplePath = function(_path) {
2124
- if(!_path) return _path;
@@ -25,9 +28,11 @@ mixin liveExampleLink2(linkText, exampleUrlPartName)
2528
- // if(extn == 'dart') return path;
2629
- var baseName = getBaseFileName(path) || path; // TODO: have getBaseFileName() return path
2730
- var baseNameNoExt = baseName.substr(0,baseName.length - (extn.length + 1));
28-
- var inWebFolder = baseNameNoExt.match(/^(main|index)$/);
31+
- var inWebFolder = baseNameNoExt.match(/^(main|index(\.\d)?)$/);
2932
- // Adjust the folder path, e.g., ts -> dart
30-
- folder = folder.replace(/(^|\/)ts\//, '$1dart/').replace(/(^|\/)app($|\/)/, inWebFolder ? '$1web$2' : '$1lib$2');
33+
- folder = folder.replace(/(^|\/)ts($|\/)/, '$1dart$2').replace(/(^|\/)app($|\/)/, inWebFolder ? '$1web$2' : '$1lib$2');
34+
- // Special case not handled above: e.g., index.html -> web/index.html
35+
- if(baseNameNoExt.match(/^(index|styles)(\.\d)?$/)) folder = (folder ? folder + '/' : '') + 'web';
3136
- // In file name, replace special characters with underscore
3237
- baseNameNoExt = baseNameNoExt.replace(/[\-\.]/g, '_');
3338
- // Adjust the file extension
@@ -40,7 +45,7 @@ mixin liveExampleLink2(linkText, exampleUrlPartName)
4045
- var title = _title.trim();
4146
- // Assume title is a path if it ends with an extension like '.foo',
4247
- // optionally followed by some comment in parentheses.
43-
- var matches = title.match(/(.*\.\w+)($|\s*\([\w ]+\)?$)/);
48+
- var matches = title.match(/(.*\.\w+)($|\s*\([\w ]+\)$)/);
4449
- if(matches && matches.length == 3) {
4550
- // e.g. matches == ['abc.ts (excerpt)', 'abc.ts', ' (excerpt)']
4651
- var path = adjustExamplePath(matches[1]);

0 commit comments

Comments
 (0)