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

Commit d5e909b

Browse files
johnpapawardbell
authored andcommitted
docs(style-guide): add style-guide - v.4
1 parent 1ac2a42 commit d5e909b

File tree

67 files changed

+1119
-670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1119
-670
lines changed

gulpfile.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var globby = require("globby");
2525
var treeKill = require("tree-kill");
2626
var blc = require("broken-link-checker");
2727

28+
var tslint = require('gulp-tslint');
29+
2830
// TODO:
2931
// 1. Think about using runSequence
3032
// 2. Think about using spawn instead of exec in case of long error messages.
@@ -45,6 +47,7 @@ var exampleZipper = require(path.resolve(TOOLS_PATH, '_example-zipper/exampleZip
4547
var plunkerBuilder = require(path.resolve(TOOLS_PATH, 'plunker-builder/plunkerBuilder'));
4648
var fsUtils = require(path.resolve(TOOLS_PATH, 'fs-utils/fsUtils'));
4749

50+
4851
var _devguideShredOptions = {
4952
examplesDir: path.join(DOCS_PATH, '_examples'),
5053
fragmentsDir: path.join(DOCS_PATH, '_fragments'),
@@ -498,6 +501,20 @@ gulp.task('_zip-examples', function() {
498501
});
499502

500503

504+
// Linting
505+
506+
gulp.task('lint', function() {
507+
return gulp.src(['./public/docs/_examples/style-guide/ts/**/*.ts', '!./public/docs/_examples/style-guide/ts/**/*.avoid.ts'])
508+
.pipe(tslint({
509+
rulesDirectory: ['node_modules/codelyzer'],
510+
configuration: require('./tslint.json')
511+
}))
512+
.pipe(tslint.report('prose', {
513+
summarizeFailureOutput: true
514+
}));
515+
});
516+
517+
501518
// Helper functions
502519

503520
function harpCompile() {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"harp": "harp",
1010
"live-server": "live-server",
1111
"test-api-builder": "jasmine-node tools/api-builder",
12-
1312
"protractor": "protractor"
1413
},
1514
"repository": {
@@ -28,10 +27,11 @@
2827
"devDependencies": {
2928
"archiver": "^0.16.0",
3029
"assert-plus": "^0.1.5",
31-
"broken-link-checker":"0.7.0",
30+
"broken-link-checker": "0.7.0",
3231
"browser-sync": "^2.9.3",
3332
"canonical-path": "0.0.2",
3433
"cross-spawn": "^2.1.0",
34+
"codelyzer": "0.0.18",
3535
"del": "^1.2.0",
3636
"dgeni": "^0.4.0",
3737
"dgeni-packages": "^0.11.1",
@@ -42,6 +42,7 @@
4242
"gulp": "^3.5.6",
4343
"gulp-env": "0.4.0",
4444
"gulp-task-listing": "^1.0.1",
45+
"gulp-tslint": "^4.3.5",
4546
"gulp-util": "^3.0.6",
4647
"gulp-watch": "^4.3.4",
4748
"harp": "^0.20.3",
@@ -66,6 +67,7 @@
6667
"protractor": "^3.0.0",
6768
"q": "^1.4.1",
6869
"tree-kill": "^1.0.0",
70+
"tslint": "^3.2.2",
6971
"typescript": "1.7.3",
7072
"yargs": "^3.23.0"
7173
},
Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
6-
// app.component.ts
7-
import { Component, OnInit } from 'angular2/core';
2+
import { Component } from 'angular2/core';
83

9-
import { Hero } from './hero';
10-
import { HeroService } from './hero.service';
4+
import { HeroesComponent } from './heroes/heroes.component';
5+
import { HeroService } from './heroes/hero.service';
116

127
@Component({
138
selector: 'toh-app',
149
template: `
15-
<pre>{{heroes | json}}</pre>
10+
<toh-heroes></toh-heroes>
1611
`,
1712
styleUrls: ['app/app.component.css'],
13+
directives: [HeroesComponent],
1814
providers: [HeroService]
1915
})
20-
export class AppComponent implements OnInit{
21-
heroes: Hero[] = [];
22-
23-
constructor(private heroService: HeroService) {}
24-
25-
ngOnInit() {
26-
this.heroService.getHeroes()
27-
.then(heroes => this.heroes = heroes);
28-
}
29-
}
16+
export class AppComponent { }
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// #docregion
2+
/* avoid */
3+
4+
import { bootstrap } from 'angular2/platform/browser';
5+
import { Component, OnInit } from 'angular2/core';
6+
7+
class Hero {
8+
id: number;
9+
name: string;
10+
}
11+
12+
@Component({
13+
selector: 'my-app',
14+
template: `
15+
<h1>{{title}}</h1>
16+
<pre>{{heroes | json}}</pre>
17+
`,
18+
styleUrls: ['app/app.component.css']
19+
})
20+
class AppComponent implements OnInit {
21+
title = 'Tour of Heroes';
22+
23+
heroes: Hero[] = [];
24+
25+
ngOnInit() {
26+
getHeroes().then(heroes => this.heroes = heroes);
27+
}
28+
}
29+
30+
bootstrap(AppComponent, []);
31+
32+
const HEROES: Hero[] = [
33+
{id: 1, name: 'Bombasto'},
34+
{id: 2, name: 'Tornado'},
35+
{id: 3, name: 'Magneta'},
36+
];
37+
38+
function getHeroes(): Promise<Hero[]> {
39+
return Promise.resolve(HEROES); // TODO: get hero data from the server;
40+
}

public/docs/_examples/style-guide/ts/01-01/app/hero.model.ts renamed to public/docs/_examples/style-guide/ts/01-01/app/heroes/hero.model.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
62
export class Hero {
73
id: number;
84
name: string;

public/docs/_examples/style-guide/ts/01-01/app/hero.service.ts renamed to public/docs/_examples/style-guide/ts/01-01/app/heroes/hero.service.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
5-
62
import { Injectable } from 'angular2/core';
7-
import { HEROES } from './mock-heroes';
3+
4+
import { HEROES } from './mock-heroes';
85

96
@Injectable()
107
export class HeroService {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// #docregion
2+
import { Component, OnInit } from 'angular2/core';
3+
4+
import { Hero } from './hero.model';
5+
import { HeroService } from './hero.service';
6+
7+
@Component({
8+
selector: 'toh-heroes',
9+
template: `
10+
<pre>{{heroes | json}}</pre>
11+
`
12+
})
13+
export class HeroesComponent implements OnInit {
14+
heroes: Hero[] = [];
15+
16+
constructor(private heroService: HeroService) {}
17+
18+
ngOnInit() {
19+
this.heroService.getHeroes()
20+
.then(heroes => this.heroes = heroes);
21+
}
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// #docregion
2+
import { Hero } from './hero.model';
3+
4+
export const HEROES: Hero[] = [
5+
{id: 1, name: 'Bombasto'},
6+
{id: 2, name: 'Tornado'},
7+
{id: 3, name: 'Magneta'},
8+
];
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
// #docplaster
2-
31
// #docregion
4-
/* recommended */
2+
import { bootstrap } from 'angular2/platform/browser';
53

6-
import { bootstrap } from 'angular2/platform/browser';
74
import { AppComponent } from './app.component';
85

96
bootstrap(AppComponent, []);

public/docs/_examples/style-guide/ts/01-01/app/placeholder.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// #docregion
2+
/* avoid */
3+
4+
// HeroComponent is in the Tour of Heroes feature
5+
@Component({
6+
selector: 'hero'
7+
})
8+
export class HeroComponent {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Component } from 'angular2/core';
3+
4+
// #docregion example
5+
@Component({
6+
selector: 'toh-hero'
7+
})
8+
export class HeroComponent {}
9+
// #enddocregion example
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// #docregion
2+
/* avoid */
3+
4+
// UsersComponent is in an Admin feature
5+
@Component({
6+
selector: 'users'
7+
})
8+
export class UsersComponent {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Component } from 'angular2/core';
3+
4+
// #docregion example
5+
@Component({
6+
selector: 'admin-users'
7+
})
8+
export class UsersComponent {}
9+
// #enddocregion example
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// #docregion
2+
/* avoid */
3+
4+
@Directive({
5+
selector: '[validate]'
6+
})
7+
export class ValidateDirective {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Directive } from 'angular2/core';
3+
4+
// #docregion example
5+
@Directive({
6+
selector: '[tohValidate]'
7+
})
8+
export class ValidateDirective {}
9+
// #enddocregion example
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- #docregion -->
2+
<toh-hero-button></toh-hero-button>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// #docregion
2+
/* avoid */
3+
4+
@Component({
5+
selector: 'tohHeroButton'
6+
})
7+
export class HeroButtonComponent {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Component } from 'angular2/core';
3+
4+
// #docregion example
5+
@Component({
6+
selector: 'toh-hero-button'
7+
})
8+
export class HeroButtonComponent {}
9+
// #enddocregion example
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- #docregion -->
2+
<toh-hero-button></toh-hero-button>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!-- #docregion -->
2+
<!-- avoid -->
3+
<div tohHeroButton></div>

0 commit comments

Comments
 (0)