First pass at build-shred-map complete

This commit is contained in:
Jay Traband 2015-08-11 00:27:09 -07:00 committed by YuCheng Hu
parent c85d482b18
commit f43477263f
28 changed files with 481 additions and 129 deletions

View File

@ -3,13 +3,14 @@ var watch = require('gulp-watch');
var gutil = require('gulp-util');
var path = require('path');
var del = require('del');
var _ = require('lodash');
var docShredder = require('./public/doc-shredder/doc-shredder');
var _shredOptions = {
basePath: path.resolve('./public/docs'),
sourceDir: "_examples",
destDir: "_fragments"
examplesDir: "_examples",
fragmentsDir: "_fragments"
};
/*
@ -42,19 +43,29 @@ gulp.task('serve-and-watch', function (cb) {
});
gulp.task('shred-full', ['shred-clean'], function() {
docShredder.shred( _shredOptions);
return docShredder.shred( _shredOptions);
});
gulp.task('shred-clean', function(cb) {
var cleanPath = path.join(_shredOptions.basePath, _shredOptions.destDir, '**/*.*')
var cleanPath = path.join(_shredOptions.basePath, _shredOptions.fragmentsDir, '**/*.*')
del([ cleanPath, '!**/*.ovr.*'], function (err, paths) {
// console.log('Deleted files/folders:\n', paths.join('\n'));
cb();
});
});
gulp.task('build-shred-maps', ['shred-full'], function() {
var options = _.extend(_shredOptions, {
jadeDir: '.',
outputDir: '.'
});
return docShredder.buildShredMap(options).then(function(x) {
// var json = x[2];
});
})
function shredWatch(shredOptions, postShredAction) {
var pattern = path.join(shredOptions.basePath, shredOptions.sourceDir, "**/*.*");
var pattern = path.join(shredOptions.basePath, shredOptions.examplesDir, "**/*.*");
watch([pattern], function (event, done) {
console.log('Event type: ' + event.event); // added, changed, or deleted
console.log('Event path: ' + event.path); // The path of the modified file

View File

@ -7,28 +7,7 @@ var delPromise = Q.denodeify(del);
var Dgeni = require('dgeni');
var _ = require('lodash');
var resolveShredOptions = function(shredOptions) {
return _.defaults({}, shredOptions, {
basePath: path.resolve('.'),
// read files from any subdir under here
sourceDir: "docs/_examples",
// shredded files get copied here with same subdir structure.
destDir: "docs/_fragments",
// whether to include subdirectories when shredding.
includeSubdirs: true
});
}
var resolveMapOptions = function(mapOptions) {
return _.defaults({}, mapOptions, {
basePath: path.resolve('.'),
// read files from any subdir under here
sourceDir: "docs",
destDir: "docs",
// whether to include subdirectories when shredding.
includeSubdirs: true
});
}
var shred = function(shredOptions) {
try {
@ -42,26 +21,26 @@ var shred = function(shredOptions) {
}
var shredSingleDir = function(shredOptions, filePath) {
shredOptions = resolveOptions(shredOptions);
var root = path.resolve(shredOptions.basePath, shredOptions.sourceDir);
shredOptions = resolveShredOptions(shredOptions);
var root = path.resolve(shredOptions.basePath, shredOptions.examplesDir);
var fileDir = path.dirname(filePath);
var relativePath = path.relative(root, fileDir);
var sourceDir = path.join(shredOptions.sourceDir, relativePath);
var destDir = path.join(shredOptions.destDir, relativePath);
var examplesDir = path.join(shredOptions.examplesDir, relativePath);
var fragmentsDir = path.join(shredOptions.fragmentsDir, relativePath);
var options = {
basePath: shredOptions.basePath,
includeSubdirs: false,
sourceDir: sourceDir,
destDir: destDir
examplesDir: examplesDir,
fragmentsDir: fragmentsDir
}
var cleanPath = path.join(shredOptions.basePath, destDir, '*.*')
var cleanPath = path.join(shredOptions.basePath, fragmentsDir, '*.*')
return delPromise([ cleanPath, '!**/*.ovr.*']).then(function(paths) {
// console.log('Deleted files/folders:\n', paths.join('\n'));
return shred(options);
});
}
var getShredMap = function(shredMapOptions) {
var buildShredMap = function(shredMapOptions) {
try {
var pkg = createShredMapPackage(shredMapOptions);
var dgeni = new Dgeni([ pkg]);
@ -73,11 +52,11 @@ var getShredMap = function(shredMapOptions) {
}
module.exports = {
shred: shred,
shredSingleDir: shredSingleDir,
resolveShredOptions: resolveShredOptions,
getShredMap: getShredMap
buildShredMap: buildShredMap
};
function createShredPackage(shredOptions) {
@ -103,9 +82,9 @@ function createShredPackage(shredOptions) {
var extns = ['*.js', '*.html', '*.ts', '*.css' ];
var includeFiles = extns.map(function(extn) {
if (options.includeSubdirs) {
return path.join(options.sourceDir, '**', extn);
return path.join(options.examplesDir, '**', extn);
} else {
return path.join(options.sourceDir, extn);
return path.join(options.examplesDir, extn);
}
});
readFilesProcessor.sourceFiles = [ {
@ -113,18 +92,18 @@ function createShredPackage(shredOptions) {
include: includeFiles,
// When calculating the relative path to these files use this as the base path.
// So `src/foo/bar.js` will have relative path of `foo/bar.js`
basePath: options.sourceDir
basePath: options.examplesDir
} ];
})
.config(function(writeFilesProcessor) {
// Specify where the writeFilesProcessor will write our generated doc files
writeFilesProcessor.outputFolder = options.destDir;
writeFilesProcessor.outputFolder = options.fragmentsDir;
});
return pkg;
}
var createShredMapPackage = function(mapOptions) {
var pkg = new Dgeni.Package('docshred-mapper', [
var pkg = new Dgeni.Package('doc-shred-mapper', [
require('dgeni-packages/base'),
require('dgeni-packages/nunjucks')
]);
@ -133,7 +112,9 @@ var createShredMapPackage = function(mapOptions) {
initializePackage(pkg)
.factory(require('./extractPathsReader'))
.processor(require('./shredMapProcessor'))
.config(function(shredMapProcessor) {
shredMapProcessor.options = options;
})
.config(function(readFilesProcessor, extractPathsReader ) {
readFilesProcessor.fileReaders = [ extractPathsReader];
})
@ -146,9 +127,9 @@ var createShredMapPackage = function(mapOptions) {
var extns = ['*.jade' ];
var includeFiles = extns.map(function(extn) {
if (options.includeSubdirs) {
return path.join(options.sourceDir, '**', extn);
return path.join(options.jadeDir, '**', extn);
} else {
return path.join(options.sourceDir, extn);
return path.join(options.jadeDir, extn);
}
});
readFilesProcessor.sourceFiles = [ {
@ -156,15 +137,15 @@ var createShredMapPackage = function(mapOptions) {
include: includeFiles,
// When calculating the relative path to these files use this as the base path.
// So `src/foo/bar.js` will have relative path of `foo/bar.js`
basePath: options.sourceDir
basePath: options.jadeDir
} ];
})
.config(function(writeFilesProcessor) {
// Specify where the writeFilesProcessor will write our generated doc files
writeFilesProcessor.outputFolder = options.destDir;
writeFilesProcessor.outputFolder = options.outputDir;
})
.config(function(templateFinder) {
// Add a folder to search for our own templates to use when rendering docs
// look for templates in this folder
templateFinder.templateFolders = [ path.resolve(__dirname) ];
// Specify how to match docs to templates.
@ -174,6 +155,7 @@ var createShredMapPackage = function(mapOptions) {
.config(function(computePathsProcessor, computeIdsProcessor) {
computePathsProcessor.$enabled = false;
computeIdsProcessor.$enabled = false;
// Unused for now.
//computePathsProcessor.pathTemplates.push({
// docTypes: ['foo'],
// pathTemplate: '',
@ -192,6 +174,30 @@ var createShredMapPackage = function(mapOptions) {
return pkg;
}
function resolveShredOptions(shredOptions) {
return _.defaults({}, shredOptions, {
basePath: path.resolve('.'),
// read files from any subdir under here
examplesDir: "docs/_examples",
// shredded files get copied here with same subdir structure.
fragmentsDir: "docs/_fragments",
// whether to include subdirectories when shredding.
includeSubdirs: true
});
}
function resolveMapOptions(mapOptions) {
return _.defaults({}, mapOptions, {
basePath: path.resolve('.'),
// read files from any subdir under here
jadeDir: "docs",
fragmentsDir: "docs/_fragments",
examplesDir: "docs/_examples",
// whether to include subdirectories when shredding.
includeSubdirs: true
});
}
function initializePackage(pkg) {
return pkg
.processor(require('dgeni-packages/base/processors/read-files'))

View File

@ -1,29 +1,30 @@
/**
* @dgService htmlFileShredder
* @dgService extractPathsReader
* @description
*/
var path = require('canonical-path');
module.exports = function extractPathsReader(log) {
// regex for makeTabs line
var rx = /\s*\+makeTabs\(\s*["'](.*?)["']\s*,\s*["'](.*?)["'].*?\)/g
return {
name: 'extractPathsReader',
getDocs: function (fileInfo) {
var content = fileInfo.content;
var refPaths = [];
var fragPaths = [];
var r;
while ((r = rx.exec(content)) !== null) {
var basePath = r[1];
var fileNames = r[2].split(',');
fileNames.forEach(function(fn) {
refPaths.push(path.join(basePath, fn));
fragPaths.push(path.join(basePath, fn.trim()));
})
}
if (refPaths.length) {
if (fragPaths.length) {
return [{
refPaths: refPaths
fragPaths: fragPaths
}];
} else {
return [];

View File

@ -29,6 +29,7 @@ module.exports = function regionExtractor() {
}
});
var rx = new RegExp(nullLine + '\n', 'g');
docs.forEach(function(doc) {
var content;
if (doc.endIx) {
@ -37,8 +38,7 @@ module.exports = function regionExtractor() {
content = lines.slice(doc.startIx + 1).join('\n');
}
// eliminate all #docregion lines
var rx = new RegExp(nullLine + '\n', 'g');
var content = content.replace(rx, '');
content = content.replace(rx, '');
if (content.substr(-3) === nullLine) {
content = content.substr(0, content.length-3);
}

View File

@ -3,28 +3,53 @@
* @description
*
*/
var path = require('canonical-path');
var fs = require('fs');
module.exports = function shredMapProcessor(log) {
return {
$runAfter: ['readFilesProcessor'],
$runBefore: ['rendering-docs'],
$process: function(docs) {
var docMaps = []
var options = this.options;
var jadeToFragMap = {};
var fragToJadeMap = {};
docs.forEach(function(doc) {
var docMap = {
jadePath: doc.fileInfo.filePath,
jadeRelativePath: doc.fileInfo.projectRelativePath,
refPaths: doc.refPaths
var jadePath = path.join(options.jadeDir, doc.fileInfo.relativePath);
var fragInfos = doc.fragPaths.map(function(fragPath) {
fragPath = path.join(options.fragmentsDir, fragPath) + '.md';
var fullPath = path.join(options.basePath, fragPath);
var fragInfo = { fragPath: fragPath, exists: fs.existsSync(fullPath) };
if (fragInfo.exists) {
var jadePaths = fragToJadeMap[fragInfo];
if (!jadePaths) {
jadePaths = [];
fragToJadeMap[fragPath] = jadePaths;
}
docMaps.push(docMap);
jadePaths.push(jadePath);
}
return fragInfo;
});
jadeToFragMap[jadePath] = fragInfos;
});
var newDocs = [{
docType: 'xref-doc.html',
docMaps: docMaps,
outputPath: 'xref-doc.html'
docType: 'xref-jade.html',
basePath: this.options.basePath,
jadeToFragMap: jadeToFragMap,
outputPath: 'xref-jade-to-frag.html'
}, {
docType: 'xref-doc.js',
json: JSON.stringify(docMaps),
outputPath: 'xref-doc.js'
docType: 'xref-frag.html',
basePath: this.options.basePath,
fragToJadeMap: fragToJadeMap,
outputPath: 'xref-frag-to-jade.html'
}, {
docType: 'xref-doc.json',
json: JSON.stringify({
basePath: this.options.basePath,
jadeToFragMap: jadeToFragMap,
}, null, 2),
outputPath: 'xref-jade.json'
}]
return newDocs;
}

View File

@ -6,17 +6,17 @@ var watch = require('gulp-watch');
var docShredder = require('../doc-shredder');
var shredOptions = docShredder.resolveShredOptions({
sourceDir: "test_source",
destDir: "test_fragments"
});
var shredOptions = {
examplesDir: "test_source",
fragmentsDir: "test_fragments"
};
gulp.task('shred', function() {
return docShredder.shred(shredOptions);
});
gulp.task('clean', function (cb) {
var cleanPath = path.join(shredOptions.destDir, '**/*.*')
var cleanPath = path.join(shredOptions.fragmentsDir, '**/*.*')
del([ cleanPath, '!**/*.ovr.*'], function (err, paths) {
// console.log('Deleted files/folders:\n', paths.join('\n'));
cb();
@ -24,7 +24,7 @@ gulp.task('clean', function (cb) {
});
gulp.task('watch', function (cb) {
var pattern = path.join(shredOptions.sourceDir, "**/*.*");
var pattern = path.join(shredOptions.examplesDir, "**/*.*");
watch([ pattern], function(event, done) {
console.log('Event type: ' + event.event); // added, changed, or deleted
console.log('Event path: ' + event.path); // The path of the modified file
@ -34,10 +34,12 @@ gulp.task('watch', function (cb) {
gulp.task('map', function() {
var options = {
sourceDir: 'test_jade',
destDir: 'test_jade'
jadeDir: 'test_jade',
examplesDir: 'test_source',
fragmentsDir: 'test_fragments',
outputDir: '.'
}
return docShredder.getShredMap(options).then(function(x) {
return docShredder.buildShredMap(options).then(function(x) {
var docMaps = x.docMaps;
})

View File

@ -1,6 +0,0 @@
# Jade file -> Example file cross references
Jade file: - C:/xxx/yyy/zzz
References:
- a/b/c
- b/d/e

View File

@ -36,7 +36,7 @@ include ../../../../_includes/_util-fns
The TypeScript setup includes System.js, a third-party open-source library that adds ES6 module loading functionality to browsers. This step isn't needed for the ES5 version.
+makeTabs('gettingstarted', 'ts/index.html,js/index.html', 'TypeScript, JavaScript')
+makeTabs('gettingstarted', 'ts/index2.html,js/index.html', 'TypeScript, JavaScript')
.callout.is-helpful
header Don't use code.angularjs.org in a live app
@ -52,7 +52,7 @@ include ../../../../_includes/_util-fns
`<my-app>` element in `index.html`, and call Angular's `bootstrap()` to kick
it all off like this:
+makeTabs("gettingstarted", "ts/main.ts, js/main.js", "TypeScript, JavaScript")
+makeTabs("gettingstarted", "ts/main.ts, js/main2.js", "TypeScript, JavaScript")
.callout.is-helpful
header Annotations vs Decorators

View File

@ -1,28 +0,0 @@
<h1> Jade document --> example Cross Reference Report
<ol>
<li>
Jade file: <strong>test_jade/guides/setupAlt2.jade</strong>
<p>Reference paths</p>
<ul>
<li>Path: gettingstarted/ts/index.html</li>
<li>Path: gettingstarted/js/index.html</li>
<li>Path: gettingstarted/ts/main.ts</li>
<li>Path: gettingstarted/ js/main.js</li>
<li>Path: gettingstarted/ts/main-import.ts</li>
</ul>
<br>
</li>
<li>
Jade file: <strong>test_jade/setupAlt.jade</strong>
<p>Reference paths</p>
<ul>
<li>Path: gettingstarted/ts/index.html</li>
<li>Path: gettingstarted/js/index.html</li>
<li>Path: gettingstarted/ts/main.ts</li>
<li>Path: gettingstarted/ js/main.js</li>
<li>Path: gettingstarted/ts/main-import.ts</li>
</ul>
<br>
</li>
</ol>

View File

@ -1 +0,0 @@
[{"jadePath":"c:/GitHub/angular.io.ideablade/public/doc-shredder/test/test_jade/guides/setupAlt2.jade","jadeRelativePath":"test_jade/guides/setupAlt2.jade","refPaths":["gettingstarted/ts/index.html","gettingstarted/js/index.html","gettingstarted/ts/main.ts","gettingstarted/ js/main.js","gettingstarted/ts/main-import.ts"]},{"jadePath":"c:/GitHub/angular.io.ideablade/public/doc-shredder/test/test_jade/setupAlt.jade","jadeRelativePath":"test_jade/setupAlt.jade","refPaths":["gettingstarted/ts/index.html","gettingstarted/js/index.html","gettingstarted/ts/main.ts","gettingstarted/ js/main.js","gettingstarted/ts/main-import.ts"]}]

View File

@ -0,0 +1,38 @@
<h1> Frament path to jade path cross reference report
<p>Base path: c:/GitHub/angular.io.ideablade/public/doc-shredder/test</p>
<ol>
<li>
Fragment file: <strong>test_fragments/gettingstarted/ts/index.html.md</strong>
<p>Jade files</p>
<ul>
<li>test_jade/guides/setupAlt2.jade</li>
</ul>
<br>
</li>
<li>
Fragment file: <strong>test_fragments/gettingstarted/js/index.html.md</strong>
<p>Jade files</p>
<ul>
<li>test_jade/setupAlt.jade</li>
</ul>
<br>
</li>
<li>
Fragment file: <strong>test_fragments/gettingstarted/ts/main.ts.md</strong>
<p>Jade files</p>
<ul>
<li>test_jade/setupAlt.jade</li>
</ul>
<br>
</li>
<li>
Fragment file: <strong>test_fragments/gettingstarted/ts/main-import.ts.md</strong>
<p>Jade files</p>
<ul>
<li>test_jade/setupAlt.jade</li>
</ul>
<br>
</li>
</ol>

View File

@ -0,0 +1,20 @@
<h1> Jade path to fragment path cross reference report
<p>Base path: c:/GitHub/angular.io.ideablade/public/doc-shredder/test</p>
<ol>
<li>
Jade file: <strong>test_jade/guides/setupAlt2.jade</strong>
<p>Fragment files</p>
<ul><li>test_fragments/gettingstarted/ts/index.html.md</li><li>test_fragments/gettingstarted/js/index.html.md</li><li>test_fragments/gettingstarted/ts/main.ts.md</li><li> *** NOT FOUND*** : test_fragments/gettingstarted/ js/main.js.md</li><li>test_fragments/gettingstarted/ts/main-import.ts.md</li>
</ul>
<br>
</li>
<li>
Jade file: <strong>test_jade/setupAlt.jade</strong>
<p>Fragment files</p>
<ul><li> *** NOT FOUND*** : test_fragments/gettingstarted/ts/index2.html.md</li><li>test_fragments/gettingstarted/js/index.html.md</li><li>test_fragments/gettingstarted/ts/main.ts.md</li><li> *** NOT FOUND*** : test_fragments/gettingstarted/ js/main2.js.md</li><li>test_fragments/gettingstarted/ts/main-import.ts.md</li>
</ul>
<br>
</li>
</ol>

View File

@ -0,0 +1,46 @@
{
"test_jade/guides/setupAlt2.jade": [
{
"fragPath": "test_fragments/gettingstarted/ts/index.html.md",
"exists": true
},
{
"fragPath": "test_fragments/gettingstarted/js/index.html.md",
"exists": true
},
{
"fragPath": "test_fragments/gettingstarted/ts/main.ts.md",
"exists": true
},
{
"fragPath": "test_fragments/gettingstarted/ js/main.js.md",
"exists": false
},
{
"fragPath": "test_fragments/gettingstarted/ts/main-import.ts.md",
"exists": true
}
],
"test_jade/setupAlt.jade": [
{
"fragPath": "test_fragments/gettingstarted/ts/index2.html.md",
"exists": false
},
{
"fragPath": "test_fragments/gettingstarted/js/index.html.md",
"exists": true
},
{
"fragPath": "test_fragments/gettingstarted/ts/main.ts.md",
"exists": true
},
{
"fragPath": "test_fragments/gettingstarted/ js/main2.js.md",
"exists": false
},
{
"fragPath": "test_fragments/gettingstarted/ts/main-import.ts.md",
"exists": true
}
]
}

View File

@ -1,16 +0,0 @@
<h1> Jade document --> example Cross Reference Report
<ol>
{%- for docMap in doc.docMaps %}
<li>
Jade file: <strong>{{ docMap.jadeRelativePath }}</strong>
<p>Reference paths</p>
<ul>
{%- for refPath in docMap.refPaths %}
<li>Path: {{ refPath }}</li>
{%- endfor %}
</ul>
<br>
</li>
{%- endfor %}
</ol>

View File

@ -0,0 +1,17 @@
<h1> Frament path to jade path cross reference report
<p>Base path: {{ doc.basePath }}</p>
<ol>
{% for fragPath, jadePaths in doc.fragToJadeMap %}
<li>
Fragment file: <strong>{{ fragPath }}</strong>
<p>Jade files</p>
<ul>
{%- for jadePath in jadePaths %}
<li>{{ jadePath }}</li>
{%- endfor %}
</ul>
<br>
</li>
{%- endfor %}
</ol>

View File

@ -0,0 +1,21 @@
<h1> Jade path to fragment path cross reference report
<p>Base path: {{ doc.basePath }}</p>
<ol>
{% for jadePath, fragInfos in doc.jadeToFragMap %}
<li>
Jade file: <strong>{{ jadePath }}</strong>
<p>Fragment files</p>
<ul>
{%- for fragInfo in fragInfos %}
{%- if fragInfo.exists -%}
<li>{{ fragInfo.fragPath }}</li>
{%- else -%}
<li> *** NOT FOUND*** : {{ fragInfo.fragPath }}</li>
{%- endif -%}
{%- endfor %}
</ul>
<br>
</li>
{%- endfor %}
</ol>

View File

@ -0,0 +1,17 @@
```
function AppComponent() {}
AppComponent.annotations = [
new angular.ComponentAnnotation({
selector: 'my-app'
}),
new angular.ViewAnnotation({
template: '<h1 id="output">My first Angular 2 App</h1>'
})
];
document.addEventListener('DOMContentLoaded', function() {
angular.bootstrap(AppComponent);
});
```

View File

@ -0,0 +1,46 @@
<h1> Frament path to jade path cross reference report
<p>Base path: c:\GitHub\angular.io.ideablade\public\docs</p>
<ol>
<li>
Fragment file: <strong>_fragments/gettingstarted/ts/index.html.md</strong>
<p>Jade files</p>
<ul>
<li>js/latest/guide/setupAlt.jade</li>
</ul>
<br>
</li>
<li>
Fragment file: <strong>_fragments/gettingstarted/js/index.html.md</strong>
<p>Jade files</p>
<ul>
<li>js/latest/guide/setupAlt.jade</li>
</ul>
<br>
</li>
<li>
Fragment file: <strong>_fragments/gettingstarted/ts/main.ts.md</strong>
<p>Jade files</p>
<ul>
<li>js/latest/guide/setupAlt.jade</li>
</ul>
<br>
</li>
<li>
Fragment file: <strong>_fragments/gettingstarted/js/main.js.md</strong>
<p>Jade files</p>
<ul>
<li>js/latest/guide/setupAlt.jade</li>
</ul>
<br>
</li>
<li>
Fragment file: <strong>_fragments/gettingstarted/ts/main-import.ts.md</strong>
<p>Jade files</p>
<ul>
<li>js/latest/guide/setupAlt.jade</li>
</ul>
<br>
</li>
</ol>

View File

@ -0,0 +1,13 @@
<h1> Jade path to fragment path cross reference report
<p>Base path: c:\GitHub\angular.io.ideablade\public\docs</p>
<ol>
<li>
Jade file: <strong>js/latest/guide/setupAlt.jade</strong>
<p>Fragment files</p>
<ul><li>_fragments/gettingstarted/ts/index.html.md</li><li>_fragments/gettingstarted/js/index.html.md</li><li>_fragments/gettingstarted/ts/main.ts.md</li><li>_fragments/gettingstarted/js/main.js.md</li><li>_fragments/gettingstarted/ts/main-import.ts.md</li>
</ul>
<br>
</li>
</ol>

View File

@ -0,0 +1,27 @@
{
"basePath": "c:\\GitHub\\angular.io.ideablade\\public\\docs",
"jadeToFragMap": {
"js/latest/guide/setupAlt.jade": [
{
"fragPath": "_fragments/gettingstarted/ts/index.html.md",
"exists": true
},
{
"fragPath": "_fragments/gettingstarted/js/index.html.md",
"exists": true
},
{
"fragPath": "_fragments/gettingstarted/ts/main.ts.md",
"exists": true
},
{
"fragPath": "_fragments/gettingstarted/js/main.js.md",
"exists": true
},
{
"fragPath": "_fragments/gettingstarted/ts/main-import.ts.md",
"exists": true
}
]
}
}

View File

@ -0,0 +1,11 @@
<!-- #docregion -->
<!DOCTYPE html>
<html>
<head>
<script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.sfx.dev.js"></script>
<script src="main.js"></script>
</head>
<body>
<my-app></my-app>
</body>
</html>

View File

@ -0,0 +1,17 @@
// #docregion
function AppComponent() {}
AppComponent.annotations = [
new angular.ComponentAnnotation({
selector: 'my-app'
}),
new angular.ViewAnnotation({
template: '<h1 id="output">My first Angular 2 App</h1>'
})
];
// #docregion bootstrap
document.addEventListener('DOMContentLoaded', function() {
angular.bootstrap(AppComponent);
});
// #enddocregion

View File

@ -0,0 +1,20 @@
// protractor-spec.js
describe('Protractor quick start test', function() {
// #docregion javascript
it('should display Alice with JavaScript', function() {
browser.get('gettingstarted/js/index.html');
});
// #enddocregion
// #docregion typescript
it('should display Alice with TypeScrip', function() {
browser.get('gettingstarted/ts/index.html');
});
// #enddocregion
afterEach(function() {
expect(element(by.id('output')).getText()).toEqual('My first Angular 2 App');
});
});

View File

@ -0,0 +1,15 @@
<!-- #docregion -->
<!DOCTYPE html>
<html>
<head>
<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
<script src="https://jspm.io/system@0.16.js"></script>
<script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.dev.js"></script>
</head>
<body>
<my-app></my-app>
<script>
System.import('main');
</script>
</body>
</html>

View File

@ -0,0 +1,33 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
}
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
// #docregion
// #docregion import
var angular2_1 = require('angular2/angular2');
// #enddocregion
var AppComponent = (function () {
function AppComponent() {
}
AppComponent = __decorate([
angular2_1.Component({
selector: 'my-app'
}),
angular2_1.View({
template: '<h1 id="output">My first Angular 2 App</h1>'
}),
__metadata('design:paramtypes', [])
], AppComponent);
return AppComponent;
})();
// #docregion bootstrap
angular2_1.bootstrap(AppComponent);
// #enddocregion
//# sourceMappingURL=main.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":["AppComponent","AppComponent.constructor"],"mappings":";;;;;;;;;;;AAEA,AAFA,UAAU;AACV,iBAAiB;AACjB,yBAAyC,mBAAmB,CAAC,CAAA;AAG7D,AAFA,aAAa;;IAEbA;IAOAC,CAACA;IAPDD;QAACA,oBAASA,CAACA;YACTA,QAAQA,EAAEA,QAAQA;SACnBA,CAACA;QACDA,eAAIA,CAACA;YACJA,QAAQA,EAAEA,6CAA6CA;SACxDA,CAACA;;qBAEDA;IAADA,mBAACA;AAADA,CAACA,AAPD,IAOC;AAGD,AADA,oBAAoB;AACpB,oBAAS,CAAC,YAAY,CAAC,CAAC;AACxB,aAAa"}

View File

@ -0,0 +1,16 @@
// #docregion
// #docregion import
import {Component, View, bootstrap} from 'angular2/angular2';
// #enddocregion
@Component({
selector: 'my-app'
})
@View({
template: '<h1 id="output">My first Angular 2 App</h1>'
})
class AppComponent {
}
// #docregion bootstrap
bootstrap(AppComponent);
// #enddocregion