diff --git a/modules/@angular/docs/cheatsheet/bootstrapping.md b/docs/content/cheatsheet/bootstrapping.md similarity index 100% rename from modules/@angular/docs/cheatsheet/bootstrapping.md rename to docs/content/cheatsheet/bootstrapping.md diff --git a/modules/@angular/docs/cheatsheet/built-in-directives.md b/docs/content/cheatsheet/built-in-directives.md similarity index 100% rename from modules/@angular/docs/cheatsheet/built-in-directives.md rename to docs/content/cheatsheet/built-in-directives.md diff --git a/modules/@angular/docs/cheatsheet/class-decorators.md b/docs/content/cheatsheet/class-decorators.md similarity index 100% rename from modules/@angular/docs/cheatsheet/class-decorators.md rename to docs/content/cheatsheet/class-decorators.md diff --git a/modules/@angular/docs/cheatsheet/component-configuration.md b/docs/content/cheatsheet/component-configuration.md similarity index 100% rename from modules/@angular/docs/cheatsheet/component-configuration.md rename to docs/content/cheatsheet/component-configuration.md diff --git a/modules/@angular/docs/cheatsheet/dependency-injection.md b/docs/content/cheatsheet/dependency-injection.md similarity index 100% rename from modules/@angular/docs/cheatsheet/dependency-injection.md rename to docs/content/cheatsheet/dependency-injection.md diff --git a/modules/@angular/docs/cheatsheet/directive-and-component-decorators.md b/docs/content/cheatsheet/directive-and-component-decorators.md similarity index 100% rename from modules/@angular/docs/cheatsheet/directive-and-component-decorators.md rename to docs/content/cheatsheet/directive-and-component-decorators.md diff --git a/modules/@angular/docs/cheatsheet/directive-configuration.md b/docs/content/cheatsheet/directive-configuration.md similarity index 100% rename from modules/@angular/docs/cheatsheet/directive-configuration.md rename to docs/content/cheatsheet/directive-configuration.md diff --git a/modules/@angular/docs/cheatsheet/forms.md b/docs/content/cheatsheet/forms.md similarity index 100% rename from modules/@angular/docs/cheatsheet/forms.md rename to docs/content/cheatsheet/forms.md diff --git a/modules/@angular/docs/cheatsheet/lifecycle hooks.md b/docs/content/cheatsheet/lifecycle hooks.md similarity index 100% rename from modules/@angular/docs/cheatsheet/lifecycle hooks.md rename to docs/content/cheatsheet/lifecycle hooks.md diff --git a/modules/@angular/docs/cheatsheet/ngmodules.md b/docs/content/cheatsheet/ngmodules.md similarity index 100% rename from modules/@angular/docs/cheatsheet/ngmodules.md rename to docs/content/cheatsheet/ngmodules.md diff --git a/modules/@angular/docs/cheatsheet/routing.md b/docs/content/cheatsheet/routing.md similarity index 100% rename from modules/@angular/docs/cheatsheet/routing.md rename to docs/content/cheatsheet/routing.md diff --git a/modules/@angular/docs/cheatsheet/template-syntax.md b/docs/content/cheatsheet/template-syntax.md similarity index 100% rename from modules/@angular/docs/cheatsheet/template-syntax.md rename to docs/content/cheatsheet/template-syntax.md diff --git a/docs/src/app/app.component.ts b/docs/src/app/app.component.ts new file mode 100644 index 0000000000000..f5a791e144b44 --- /dev/null +++ b/docs/src/app/app.component.ts @@ -0,0 +1,44 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ + +import {Component, OnInit, NgZone } from '@angular/core'; +import {FormControl, ReactiveFormsModule} from '@angular/forms'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/switchMap'; +import {QueryResults, SearchWorkerClient} from './search-worker-client'; + + +@Component({ + selector: 'my-app', + template: ` +

Angular Docs Search

+ +
+
Waiting...
+ +
+ ` +}) +export class AppComponent implements OnInit { + searchResult$: Observable; + indexReady: Promise; + searchInput: FormControl; + + constructor(private zone: NgZone) {} + + ngOnInit() { + const searchWorker = new SearchWorkerClient('app/search-worker.js', this.zone); + this.indexReady = searchWorker.ready; + this.searchInput = new FormControl(); + this.searchResult$ = this.searchInput.valueChanges + .switchMap((searchText: string) => searchWorker.search(searchText)); + } +} diff --git a/docs/src/app/main.ts b/docs/src/app/main.ts new file mode 100644 index 0000000000000..0382fb9eee1ce --- /dev/null +++ b/docs/src/app/main.ts @@ -0,0 +1,21 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ +import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; +import {NgModule} from '@angular/core'; +import {BrowserModule} from '@angular/platform-browser'; +import {ReactiveFormsModule} from '@angular/forms'; +import {AppComponent} from 'app/app.component'; + +@NgModule({ + imports: [ BrowserModule, ReactiveFormsModule ], + declarations: [ AppComponent ], + bootstrap: [ AppComponent ] +}) +class AppModule { + +} + +platformBrowserDynamic().bootstrapModule(AppModule); \ No newline at end of file diff --git a/docs/src/app/search-worker-client.ts b/docs/src/app/search-worker-client.ts new file mode 100644 index 0000000000000..a81e3eb3e3bdd --- /dev/null +++ b/docs/src/app/search-worker-client.ts @@ -0,0 +1,97 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ + +import {NgZone} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Subscriber} from 'rxjs/Subscriber'; +import 'rxjs/add/observable/fromPromise'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/switchMap'; + + +export interface QueryResults {} + +export interface ResultsReadyMessage { + type: 'query-results'; + id: number; + query: string; + results: QueryResults; +} + +export class SearchWorkerClient { + ready: Promise; + worker: Worker; + private _queryId = 0; + + constructor(url: string, private zone: NgZone) { + this.worker = new Worker(url); + this.ready = this._waitForIndex(this.worker); + } + + search(query: string) { + return Observable.fromPromise(this.ready) + .switchMap(() => this._createQuery(query)); + } + + private _waitForIndex(worker: Worker) { + return new Promise((resolve, reject) => { + + worker.onmessage = (e) => { + if(e.data.type === 'index-ready') { + resolve(true); + cleanup(); + } + }; + + worker.onerror = (e) => { + reject(e); + cleanup(); + }; + }); + + function cleanup() { + worker.onmessage = null; + worker.onerror = null; + } + } + + private _createQuery(query: string) { + return new Observable((subscriber: Subscriber) => { + + // get a new identifier for this query that we can match to results + const id = this._queryId++; + + const handleMessage = (message: MessageEvent) => { + const {type, id: queryId, results} = message.data as ResultsReadyMessage; + if (type === 'query-results' && id === queryId) { + this.zone.run(() => { + subscriber.next(results); + subscriber.complete(); + }); + } + }; + + const handleError = (error: ErrorEvent) => { + this.zone.run(() => { + subscriber.error(error); + }); + }; + + // Wire up the event listeners for this query + this.worker.addEventListener('message', handleMessage); + this.worker.addEventListener('error', handleError); + + // Post the query to the web worker + this.worker.postMessage({query, id}); + + // At completion/error unwire the event listeners + return () => { + this.worker.removeEventListener('message', handleMessage); + this.worker.removeEventListener('error', handleError); + }; + }); + } +} diff --git a/docs/src/app/search-worker.js b/docs/src/app/search-worker.js new file mode 100644 index 0000000000000..8528060e185d0 --- /dev/null +++ b/docs/src/app/search-worker.js @@ -0,0 +1,63 @@ +'use strict'; + +/* eslint-env worker */ +/* global importScripts, lunr */ + +importScripts('https://unpkg.com/lunr@0.7.2'); + +var index = createIndex(); +var pages = {}; + +makeRequest('search-data.json', loadIndex); + +self.onmessage = handleMessage; + +// Create the lunr index - the docs should be an array of objects, each object containing +// the path and search terms for a page +function createIndex() { + return lunr(/** @this */function() { + this.ref('path'); + this.field('titleWords', {boost: 50}); + this.field('members', {boost: 40}); + this.field('keywords', {boost: 20}); + }); +} + + +// Use XHR to make a request to the server +function makeRequest(url, callback) { + var searchDataRequest = new XMLHttpRequest(); + searchDataRequest.onload = function() { + callback(JSON.parse(this.responseText)); + }; + searchDataRequest.open('GET', url); + searchDataRequest.send(); +} + + +// Create the search index from the searchInfo which contains the information about each page to be indexed +function loadIndex(searchInfo) { + // Store the pages data to be used in mapping query results back to pages + // Add search terms from each page to the search index + searchInfo.forEach(function(page) { + index.add(page); + pages[page.path] = page; + }); + self.postMessage({type: 'index-ready'}); +} + + +// The worker receives a message everytime the web app wants to query the index +function handleMessage(message) { + var id = message.data.id; + var query = message.data.query; + var results = queryIndex(query); + self.postMessage({type: 'query-results', id: id, query: query, results: results}); +} + + +// Query the index and return the processed results +function queryIndex(query) { + // Only return the array of paths to pages + return index.search(query).map(function(hit) { return pages[hit.ref]; }); +} diff --git a/docs/src/app/tsconfig.json b/docs/src/app/tsconfig.json new file mode 100644 index 0000000000000..fef64c141b98c --- /dev/null +++ b/docs/src/app/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "declaration": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "module": "commonjs", + "moduleResolution": "node", + "outDir": "../dist/tools/", + "noImplicitAny": true, + "noFallthroughCasesInSwitch": true, + "paths": { + }, + "rootDir": ".", + "sourceMap": true, + "inlineSources": true, + "lib": ["es6", "dom"], + "target": "es5", + "skipLibCheck": true, + "typeRoots": [ + "../../../node_modules" + ] + }, + "exclude": [ + "node_modules", + "typings-test", + "public_api_guard", + "docs" + ] +} diff --git a/docs/src/index.html b/docs/src/index.html new file mode 100644 index 0000000000000..ce8cd47c9a25c --- /dev/null +++ b/docs/src/index.html @@ -0,0 +1,28 @@ + + + + Hello Angular + + + + + + + + + + + + + + + + + Loading AppComponent content here ... + + + \ No newline at end of file diff --git a/docs/src/systemjs.config.web.js b/docs/src/systemjs.config.web.js new file mode 100644 index 0000000000000..2c1e096785b45 --- /dev/null +++ b/docs/src/systemjs.config.web.js @@ -0,0 +1,64 @@ +/* +Copyright 2016 Google Inc. All Rights Reserved. +Use of this source code is governed by an MIT-style license that +can be found in the LICENSE file at http://angular.io/license +*/ + +System.config({ + // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER + transpiler: 'ts', + typescriptOptions: { + // Copy of compiler options in standard tsconfig.json + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "noImplicitAny": true, + "suppressImplicitAnyIndexErrors": true + }, + meta: { + 'typescript': { + "exports": "ts" + } + }, + paths: { + // paths serve as alias + 'npm:': 'https://unpkg.com/' + }, + // map tells the System loader where to look for things + map: { + // our app is within the app folder + app: 'app', + + // angular bundles + '@angular/core': 'npm:@angular/core/bundles/core.umd.js', + '@angular/common': 'npm:@angular/common/bundles/common.umd.js', + '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', + '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', + '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', + '@angular/http': 'npm:@angular/http/bundles/http.umd.js', + '@angular/router': 'npm:@angular/router/bundles/router.umd.js', + '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', + '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js', + '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js', + + // other libraries + 'rxjs': 'npm:rxjs', + 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js', + 'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js', + 'typescript': 'npm:typescript@2.0.3/lib/typescript.js', + + }, + // packages tells the System loader how to load when no filename and/or no extension + packages: { + app: { + main: './main.ts', + defaultExtension: 'ts' + }, + rxjs: { + defaultExtension: 'js' + } + } +}); diff --git a/docs/templates/api-list-audit.template.json b/docs/templates/api-list-audit.template.json new file mode 100644 index 0000000000000..b0610e16f73ed --- /dev/null +++ b/docs/templates/api-list-audit.template.json @@ -0,0 +1,15 @@ +[{% for module, items in doc.data %} + {% for item in items %} + { + "title": "{$ item.title $}", + "path": "{$ item.exportDoc.path $}", + "docType": "{$ item.docType $}", + "stability": "{$ item.stability $}", + "secure": "{$ item.security $}", + "howToUse": "{$ item.howToUse | replace('"','\\"') $}", + "whatItDoes": {% if item.whatItDoes %}"Exists"{% else %}"Not Done"{% endif %}, + "barrel" : "{$ module | replace("/index", "") $}" + }{% if not loop.last %},{% endif %} + {% endfor %} + {% endfor %} +] \ No newline at end of file diff --git a/docs/templates/api-list-data.template.json b/docs/templates/api-list-data.template.json new file mode 100644 index 0000000000000..b67d0ab6aecb2 --- /dev/null +++ b/docs/templates/api-list-data.template.json @@ -0,0 +1,14 @@ +{ +{%- for module, items in doc.data %} + "{$ module | replace("/index", "") $}" : [{% for item in items %} + { + "title": "{$ item.title $}", + "path": "{$ item.exportDoc.path $}", + "docType": "{$ item.docType $}", + "stability": "{$ item.stability $}", + "secure": "{$ item.security $}", + "barrel" : "{$ module | replace("/index", "") $}" + }{% if not loop.last %},{% endif %} + {% endfor %}]{% if not loop.last %},{% endif %} +{% endfor -%} +} diff --git a/docs/templates/cheatsheet.template.json b/docs/templates/cheatsheet.template.json new file mode 100644 index 0000000000000..72077d8ee3454 --- /dev/null +++ b/docs/templates/cheatsheet.template.json @@ -0,0 +1,5 @@ +{ + "currentEnvironment": {$ doc.currentEnvironment | json | trim $}, + "version": {$ doc.version.currentVersion | json | indent(2) | trim $}, + "sections": {$ doc.sections | json | indent(2) | trim $} +} \ No newline at end of file diff --git a/docs/templates/class.template.html b/docs/templates/class.template.html new file mode 100644 index 0000000000000..dbd548b4f7145 --- /dev/null +++ b/docs/templates/class.template.html @@ -0,0 +1,161 @@ +{% import "lib/githubLinks.html" as github -%} +{% import "lib/paramList.html" as params -%} +{% extends 'layout/base.template.html' -%} + +{% block body %} + + +{% include "layout/_what-it-does.html" %} + +{% include "layout/_security-notes.html" %} + +{% include "layout/_deprecated-notes.html" %} + +{% include "layout/_how-to-use.html" %} + +
+
+

Class Overview

+
+
+ class {$ doc.name $} { + {% if doc.statics.length %} +
+ {% for member in doc.statics %}{% if not member.internal %} +
static
+          
+            {$ member.name | indent(6, false) | trim $}
+          
+          
+            {$ params.paramList(member.parameters) | indent(8, false) | trim $}{$ params.returnType(member.returnType) $}
+          
+      {% endif %}{% endfor %}
+    {% endif %}
+    {% if doc.constructorDoc.name %}
+    
+
+        
+          {$ doc.constructorDoc.name $}
+        
+        
+          {$ params.paramList(doc.constructorDoc.parameters) | indent(8, false) | trim $}
+        
+    {% endif %}
+    {% if doc.members.length %}
+    
+ {% for member in doc.members %}{% if not member.internal %} +
+          
+            {$ member.name | indent(6, false) | trim $}
+          
+          {$ params.paramList(member.parameters) | indent(8, false) | trim $}{$ params.returnType(member.returnType) $}
+        
+ {% endif %}{% endfor %} + {% endif %} +

+ } +

+ +{% block additional %} +{% endblock %} + +
+
+

Class Description

+
+ + +{%- if doc.decorators.length %} +{% block annotations %} +
+
+

Annotations

+
+
+ {%- for decorator in doc.decorators %} +
+        
+          @{$ decorator.name $}{$ params.paramList(decorator.arguments) | indent(10, false) $}
+        
+      
+ {%- if not decorator.notYetDocumented %} + {$ decorator.description | indentForMarkdown(8) | trimBlankLines | marked $} + {% endif %} + {% endfor %} +
+{% endblock %} +{% endif %} + +{%- if doc.constructorDoc and not doc.constructorDoc.internal %} +
+
+

Constructor

+
+
+ +
+      
+        {$ doc.constructorDoc.name $}{$ params.paramList(doc.constructorDoc.parameters) | indent(8, false) | trim $}
+      
+    
+ {%- if not doc.constructorDoc.notYetDocumented %} + {$ doc.constructorDoc.description | replace('### Example', '') | replace('## Example', '') | replace('# Example', '') | trimBlankLines | marked $} + {% endif %} +{% endif %} + +{% if doc.statics.length %} +
+
+

Static Members

+
+