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

Commit fedc39d

Browse files
chalinwardbell
authored andcommitted
docs(quickstart-ts/dart): updated prose and example code; consolidate for TS&Dart
closes #1396
1 parent a3400d0 commit fedc39d

File tree

12 files changed

+607
-601
lines changed

12 files changed

+607
-601
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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}
10+
11+
/*
12+
* See https://github.com/angular/angular.io/blob/master/public/docs/_examples/styles.css
13+
* for the full set of master styles used by the documentation samples
14+
*/

public/docs/_examples/quickstart/ts/app/app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ import { Component } from '@angular/core';
99
template: '<h1>My First Angular 2 App</h1>'
1010
})
1111
// #enddocregion metadata
12-
// #docregion export
12+
// #docregion class
1313
export class AppComponent { }
14-
// #enddocregion export
14+
// #enddocregion class
Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
/* #docregion */
2-
/* Master Styles */
32
h1 {
4-
color: #369;
5-
font-family: Arial, Helvetica, sans-serif;
3+
color: #369;
4+
font-family: Arial, Helvetica, sans-serif;
65
font-size: 250%;
76
}
8-
h2, h3 {
9-
color: #444;
10-
font-family: Arial, Helvetica, sans-serif;
11-
font-weight: lighter;
12-
}
13-
body {
14-
margin: 2em;
15-
}
16-
body, input[text], button {
17-
color: #888;
18-
font-family: Cambria, Georgia;
7+
body {
8+
margin: 2em;
199
}
2010

21-
/*
22-
* See https://github.com/angular/angular.io/blob/master/public/docs/_examples/styles.css
23-
* for the full set of master styles used by the documentation samples
24-
*/
25-
11+
/*
12+
* See https://github.com/angular/angular.io/blob/master/public/docs/_examples/styles.css
13+
* for the full set of master styles used by the documentation samples
14+
*/

public/docs/_examples/quickstart/ts/systemjs.config.1.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
packages: packages
4040
}
4141

42-
// filterSystemConfig - index.html's chance to modify config before we register it.
43-
if (global.filterSystemConfig) { global.filterSystemConfig(config); }
44-
4542
System.config(config);
4643

4744
})(this);

public/docs/_examples/systemjs.config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* System configuration for Angular 2 samples
33
* Adjust as necessary for your application needs.
4-
* Override at the last minute with global.filterSystemConfig (as plunkers do)
54
*/
65
(function(global) {
76

@@ -42,9 +41,6 @@
4241
packages: packages
4342
}
4443

45-
// filterSystemConfig - index.html's chance to modify config before we register it.
46-
if (global.filterSystemConfig) { global.filterSystemConfig(config); }
47-
4844
System.config(config);
4945

5046
})(this);

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)