diff --git a/README.md b/README.md
index 83b6c9e370..30bf88cc28 100644
--- a/README.md
+++ b/README.md
@@ -20,16 +20,8 @@ Angular.io is currently the preview site for Angular 2. This site also includes
## Development setup with watches and browser reload
1. cd into root directory `angular.io/`
- 2. install `browser-sync`
-
- `npm install -g browser-sync`
-
- *or on Windows*
-
- `npm install -g browser-sync --msvs_version=2013`
-
- 3. run `gulp serve-and-sync`
- 4. browser will launch ( on localhost:3000 instead of localhost:9000) and stay refreshed automatically.
+ 2. run `gulp serve-and-sync`
+ 3. browser will launch ( on localhost:3000 instead of localhost:9000) and stay refreshed automatically.
## Technology Used
- Angular 1.x: The production ready version of Angular
diff --git a/public/doc-shredder/doc-shredder.js b/public/doc-shredder/doc-shredder.js
index 77a590270d..70b4d980a5 100644
--- a/public/doc-shredder/doc-shredder.js
+++ b/public/doc-shredder/doc-shredder.js
@@ -7,15 +7,7 @@ var delPromise = Q.denodeify(del);
var Dgeni = require('dgeni');
var _ = require('lodash');
-var createPackage = function(shredOptions) {
- var shredder = new Dgeni.Package('doc-shredder', [
- // require('dgeni-packages/base') - doesn't work
- ]);
- shredder.options = resolveOptions(shredOptions);
- return configure(shredder);
-};
-
-var resolveOptions = function(shredOptions) {
+var resolveShredOptions = function(shredOptions) {
return _.defaults({}, shredOptions, {
basePath: path.resolve('.'),
// read files from any subdir under here
@@ -27,9 +19,20 @@ var resolveOptions = function(shredOptions) {
});
}
+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 {
- var pkg = createPackage(shredOptions);
+ var pkg = createShredPackage(shredOptions);
var dgeni = new Dgeni([ pkg]);
return dgeni.generate();
} catch(x) {
@@ -58,16 +61,139 @@ var shredSingleDir = function(shredOptions, filePath) {
});
}
+var getShredMap = function(shredMapOptions) {
+ try {
+ var pkg = createShredMapPackage(shredMapOptions);
+ var dgeni = new Dgeni([ pkg]);
+ return dgeni.generate();
+ } catch(x) {
+ console.log(x.stack);
+ throw x;
+ }
+}
+
+
module.exports = {
shred: shred,
shredSingleDir: shredSingleDir,
- createPackage: createPackage,
- resolveOptions: resolveOptions
+ resolveShredOptions: resolveShredOptions,
+ getShredMap: getShredMap
};
-function configure(shredder) {
- var options = shredder.options;
- shredder
+function createShredPackage(shredOptions) {
+ var pkg = new Dgeni.Package('doc-shredder', [
+ // require('dgeni-packages/base') - doesn't work
+ ]);
+ var options = resolveShredOptions(shredOptions);
+
+ initializePackage(pkg)
+ .factory(require('./fileShredder'))
+ .factory(require('./regionExtractor'))
+ .processor(require('./mdWrapperProcessor'))
+
+ .config(function(readFilesProcessor, fileShredder ) {
+ readFilesProcessor.fileReaders = [ fileShredder];
+ })
+ // default configs - may be overriden
+ .config(function(readFilesProcessor) {
+ // Specify the base path used when resolving relative paths to source and output files
+ readFilesProcessor.basePath = options.basePath;
+
+ // Specify collections of source files that should contain the documentation to extract
+ var extns = ['*.js', '*.html', '*.ts', '*.css' ];
+ var includeFiles = extns.map(function(extn) {
+ if (options.includeSubdirs) {
+ return path.join(options.sourceDir, '**', extn);
+ } else {
+ return path.join(options.sourceDir, extn);
+ }
+ });
+ readFilesProcessor.sourceFiles = [ {
+ // Process all candidate files in `src` and its subfolders ...
+ 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
+ } ];
+ })
+ .config(function(writeFilesProcessor) {
+ // Specify where the writeFilesProcessor will write our generated doc files
+ writeFilesProcessor.outputFolder = options.destDir;
+ });
+ return pkg;
+}
+
+var createShredMapPackage = function(mapOptions) {
+ var pkg = new Dgeni.Package('docshred-mapper', [
+ require('dgeni-packages/base'),
+ require('dgeni-packages/nunjucks')
+ ]);
+ var options = resolveMapOptions(mapOptions);
+
+ initializePackage(pkg)
+ .factory(require('./extractPathsReader'))
+ .processor(require('./shredMapProcessor'))
+
+ .config(function(readFilesProcessor, extractPathsReader ) {
+ readFilesProcessor.fileReaders = [ extractPathsReader];
+ })
+ // default configs - may be overriden
+ .config(function(readFilesProcessor) {
+ // Specify the base path used when resolving relative paths to source and output files
+ readFilesProcessor.basePath = options.basePath;
+
+ // Specify collections of source files that should contain the documentation to extract
+ var extns = ['*.jade' ];
+ var includeFiles = extns.map(function(extn) {
+ if (options.includeSubdirs) {
+ return path.join(options.sourceDir, '**', extn);
+ } else {
+ return path.join(options.sourceDir, extn);
+ }
+ });
+ readFilesProcessor.sourceFiles = [ {
+ // Process all candidate files in `src` and its subfolders ...
+ 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
+ } ];
+ })
+ .config(function(writeFilesProcessor) {
+ // Specify where the writeFilesProcessor will write our generated doc files
+ writeFilesProcessor.outputFolder = options.destDir;
+ })
+ .config(function(templateFinder) {
+ // Add a folder to search for our own templates to use when rendering docs
+ templateFinder.templateFolders = [ path.resolve(__dirname) ];
+
+ // Specify how to match docs to templates.
+ // In this case we just use the same static template for all docs
+ templateFinder.templatePatterns = [ '${ doc.docType }.template' ];
+ })
+ .config(function(computePathsProcessor, computeIdsProcessor) {
+ computePathsProcessor.$enabled = false;
+ computeIdsProcessor.$enabled = false;
+ //computePathsProcessor.pathTemplates.push({
+ // docTypes: ['foo'],
+ // pathTemplate: '',
+ // getOutputPath: function () {
+ // },
+ //});
+ //
+ //computeIdsProcessor.idTemplates.push({
+ // docTypes: ['foo'],
+ // getAliases: function (doc) {
+ // return [doc.id];
+ // }
+ //});
+ });
+
+ return pkg;
+}
+
+function initializePackage(pkg) {
+ return pkg
.processor(require('dgeni-packages/base/processors/read-files'))
.processor(require('dgeni-packages/base/processors/write-files'))
.factory(require('dgeni-packages/base/services/writefile'))
@@ -87,50 +213,8 @@ function configure(shredder) {
.processor({ name: 'docs-rendered', $runAfter: ['rendering-docs'] })
.processor({ name: 'writing-files', $runAfter: ['docs-rendered'] })
.processor({ name: 'files-written', $runAfter: ['writing-files'] })
-
- .factory(require('./fileShredder'))
- .factory(require('./regionExtractor'))
- .processor(require('./mdWrapperProcessor'))
-
.config(function(log) {
// Set logging level
log.level = 'info';
})
-
-
- .config(function(readFilesProcessor, fileShredder ) {
- readFilesProcessor.fileReaders = [ fileShredder];
- })
-
- // default configs - may be overriden
- .config(function(readFilesProcessor) {
-
- // Specify the base path used when resolving relative paths to source and output files
- readFilesProcessor.basePath = options.basePath;
-
- // Specify collections of source files that should contain the documentation to extract
- var extns = ['*.js', '*.html', '*.ts', '*.css' ];
- var includeFiles = extns.map(function(extn) {
- if (options.includeSubdirs) {
- return path.join(options.sourceDir, '**', extn);
- } else {
- return path.join(options.sourceDir, extn);
- }
- });
- readFilesProcessor.sourceFiles = [
- {
- // Process all candidate files in `src` and its subfolders ...
- 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
- }
- ];
- })
- .config(function(writeFilesProcessor) {
- // Specify where the writeFilesProcessor will write our generated doc files
- writeFilesProcessor.outputFolder = options.destDir;
- });
- return shredder;
-}
+}
\ No newline at end of file
diff --git a/public/doc-shredder/extractPathsReader.js b/public/doc-shredder/extractPathsReader.js
new file mode 100644
index 0000000000..56515fc9f8
--- /dev/null
+++ b/public/doc-shredder/extractPathsReader.js
@@ -0,0 +1,34 @@
+/**
+ * @dgService htmlFileShredder
+ * @description
+ */
+
+var path = require('canonical-path');
+
+module.exports = function extractPathsReader(log) {
+ var rx = /\s*\+makeTabs\(\s*["'](.*?)["']\s*,\s*["'](.*?)["'].*?\)/g
+ return {
+ name: 'extractPathsReader',
+
+ getDocs: function (fileInfo) {
+ var content = fileInfo.content;
+ var refPaths = [];
+ 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));
+ })
+ }
+ if (refPaths.length) {
+ return [{
+ refPaths: refPaths
+ }];
+ } else {
+ return [];
+ }
+ }
+ }
+}
+
diff --git a/public/doc-shredder/shredMapProcessor.js b/public/doc-shredder/shredMapProcessor.js
new file mode 100644
index 0000000000..17ea5aeddf
--- /dev/null
+++ b/public/doc-shredder/shredMapProcessor.js
@@ -0,0 +1,32 @@
+/**
+ * dgProcessor shredMapProcessor
+ * @description
+ *
+ */
+module.exports = function shredMapProcessor(log) {
+ return {
+ $runAfter: ['readFilesProcessor'],
+ $runBefore: ['rendering-docs'],
+ $process: function(docs) {
+ var docMaps = []
+ docs.forEach(function(doc) {
+ var docMap = {
+ jadePath: doc.fileInfo.filePath,
+ jadeRelativePath: doc.fileInfo.projectRelativePath,
+ refPaths: doc.refPaths
+ }
+ docMaps.push(docMap);
+ });
+ var newDocs = [{
+ docType: 'xref-doc.html',
+ docMaps: docMaps,
+ outputPath: 'xref-doc.html'
+ }, {
+ docType: 'xref-doc.js',
+ json: JSON.stringify(docMaps),
+ outputPath: 'xref-doc.js'
+ }]
+ return newDocs;
+ }
+ };
+};
\ No newline at end of file
diff --git a/public/doc-shredder/test/gulpfile.js b/public/doc-shredder/test/gulpfile.js
index 07cd4e93e6..c61748cdcc 100644
--- a/public/doc-shredder/test/gulpfile.js
+++ b/public/doc-shredder/test/gulpfile.js
@@ -6,7 +6,7 @@ var watch = require('gulp-watch');
var docShredder = require('../doc-shredder');
-var shredOptions = docShredder.resolveOptions({
+var shredOptions = docShredder.resolveShredOptions({
sourceDir: "test_source",
destDir: "test_fragments"
});
@@ -32,6 +32,16 @@ gulp.task('watch', function (cb) {
});
});
+gulp.task('map', function() {
+ var options = {
+ sourceDir: 'test_jade',
+ destDir: 'test_jade'
+ }
+ return docShredder.getShredMap(options).then(function(x) {
+ var docMaps = x.docMaps;
+ })
+
+});
gulp.task('default', ['shred']);
diff --git a/public/doc-shredder/test/report.md b/public/doc-shredder/test/report.md
new file mode 100644
index 0000000000..f2a3725be4
--- /dev/null
+++ b/public/doc-shredder/test/report.md
@@ -0,0 +1,6 @@
+# Jade file -> Example file cross references
+
+ Jade file: - C:/xxx/yyy/zzz
+ References:
+ - a/b/c
+ - b/d/e
\ No newline at end of file
diff --git a/public/doc-shredder/test/test_jade/guides/setupAlt2.jade b/public/doc-shredder/test/test_jade/guides/setupAlt2.jade
new file mode 100644
index 0000000000..f23bdde63d
--- /dev/null
+++ b/public/doc-shredder/test/test_jade/guides/setupAlt2.jade
@@ -0,0 +1,120 @@
+include ../../../../_includes/_util-fns
+
+.l-main-section
+ :markdown
+ ## Install Angular2
+ There are four steps to create any Angular app:
+
+ 1. Create an entry point HTML file where users will start
+ 1. Load the Angular library at the top of the file
+ 1. Make a root component for your application
+ 1. Bootstrap Angular
+
+ You can edit and test out your apps by serving local files with a web server. Follow the steps in the quickstart to get Typescript setup.
+
+ When you're serving local files, edit and save them and start a web server that serves files in that directory. If you have Python installed, you can run a basic HTTP server from the root of your code directory with:
+
+ pre.prettyprint.lang-bash
+ code python -m SimpleHTTPServer 8000
+
+.callout.is-helpful
+ header Typescript vs ES5
+ :markdown
+ Although we work through the examples in TypeScript, you can also use
+ regular ES5. Click the ES5 link in any code box to see the ES5 JavaScript
+ version. Note that in ES5, you'd want to name your files `.js` rather than
+ `.ts`.
+
+.l-main-section
+ :markdown
+ ## Create an entry point
+ Create an `index.html` file and add the Angular library tags and a `main.ts` file where
+ you'll build your first component.
+
+ In the `
templateUrl
property and give it the path to the HTML file.
+
+ .l-sub-section
+ :markdown
+ ### import vs. window.angular
+
+ The main difference between the ES5 and TypeScript versions is the loading of modules.
+
+ **TypeScript**templateUrl
property and give it the path to the HTML file.
+
+ .l-sub-section
+ :markdown
+ ### import vs. window.angular
+
+ The main difference between the ES5 and TypeScript versions is the loading of modules.
+
+ **TypeScript**Reference paths
+Reference paths
+Reference paths
+