From 8459a4dd5c5c8e6a94cca8ee27ac6203c06eaae7 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 8 Dec 2015 20:23:43 +0000 Subject: [PATCH] chore(doc-gen): allow dart cheatsheet to be generated --- gulpfile.js | 14 ++++++++-- public/_includes/_scripts-include.jade | 1 + public/docs/dart/latest/guide/_data.json | 4 +++ public/docs/dart/latest/guide/cheatsheet.jade | 9 +++++++ public/docs/js/latest/guide/_data.json | 4 +++ public/docs/js/latest/guide/cheatsheet.jade | 9 +++++++ public/docs/ts/latest/guide/cheatsheet.jade | 9 +------ .../js/controllers/app-controller.js | 8 ------ public/resources/js/directives/cheatsheet.js | 26 +++++++++++++++++++ tools/api-builder/angular.io-package/index.js | 6 +++++ .../processors/createCheatsheetDoc.js | 2 +- 11 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 public/docs/dart/latest/guide/cheatsheet.jade create mode 100644 public/docs/js/latest/guide/cheatsheet.jade create mode 100644 public/resources/js/directives/cheatsheet.js diff --git a/gulpfile.js b/gulpfile.js index 63d827211b..2dee1d40d4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -122,6 +122,10 @@ gulp.task('build-plunkers', function() { return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log }); }); +gulp.task('build-dart-cheatsheet', [], function() { + return buildApiDocs('dart'); +}); + gulp.task('git-changed-examples', ['_shred-devguide-examples'], function(){ var after, sha, messageSuffix; if (argv.after) { @@ -330,15 +334,21 @@ function devGuideExamplesWatch(shredOptions, postShredAction) { // Generate the API docs for the specified language, if not specified then it defaults to ts function buildApiDocs(targetLanguage) { - var ALLOWED_LANGUAGES = ['ts', 'js']; + var ALLOWED_LANGUAGES = ['ts', 'js', 'dart']; + var GENERATE_API_LANGUAGES = ['ts', 'js']; checkAngularProjectPath(); try { // Build a specialized package to generate different versions of the API docs var package = new Package('apiDocs', [require(path.resolve(TOOLS_PATH, 'api-builder/angular.io-package'))]); - package.config(function(targetEnvironments, writeFilesProcessor) { + package.config(function(targetEnvironments, writeFilesProcessor, readTypeScriptModules) { ALLOWED_LANGUAGES.forEach(function(target) { targetEnvironments.addAllowed(target); }); if (targetLanguage) { targetEnvironments.activate(targetLanguage); + + if (GENERATE_API_LANGUAGES.indexOf(targetLanguage) === -1) { + // Don't read TypeScript modules if we are not generating API docs - Dart I am looking at you! + readTypeScriptModules.$enabled = false; + } writeFilesProcessor.outputFolder = targetLanguage + '/latest/api'; } }); diff --git a/public/_includes/_scripts-include.jade b/public/_includes/_scripts-include.jade index c0b2805a44..f3b8c46ccc 100644 --- a/public/_includes/_scripts-include.jade +++ b/public/_includes/_scripts-include.jade @@ -16,6 +16,7 @@ script(src="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular script(src="/resources/js/site.js") script(src="/resources/js/controllers/app-controller.js") +script(src="/resources/js/directives/cheatsheet.js") script(src="/resources/js/directives/bio.js") script(src="/resources/js/directives/code.js") script(src="/resources/js/directives/code-tabs.js") diff --git a/public/docs/dart/latest/guide/_data.json b/public/docs/dart/latest/guide/_data.json index 0435656f90..12fcf7ed9c 100644 --- a/public/docs/dart/latest/guide/_data.json +++ b/public/docs/dart/latest/guide/_data.json @@ -5,6 +5,10 @@ "title": "Step By Step Guide" }, + "cheatsheet": { + "title": "Angular Cheat Sheet" + }, + "setup": { "title": "Getting Started" }, diff --git a/public/docs/dart/latest/guide/cheatsheet.jade b/public/docs/dart/latest/guide/cheatsheet.jade new file mode 100644 index 0000000000..b5366aed77 --- /dev/null +++ b/public/docs/dart/latest/guide/cheatsheet.jade @@ -0,0 +1,9 @@ +.banner + p.text-body This cheat sheet is provisional and may change. Angular 2 is currently in Developer Preview. + +article(class="l-content-small grid-fluid docs-content") + .cheatsheet + h2 Angular for Dart Cheat Sheet (v2.0.0-alpha.44) + br + br + ngio-cheatsheet(src='./cheatsheet.json') diff --git a/public/docs/js/latest/guide/_data.json b/public/docs/js/latest/guide/_data.json index 0bcaee890c..2d50d8fd90 100644 --- a/public/docs/js/latest/guide/_data.json +++ b/public/docs/js/latest/guide/_data.json @@ -5,6 +5,10 @@ "title": "Developer Guide" }, + "cheatsheet": { + "title": "Angular Cheat Sheet" + }, + "displaying-data": { "title": "Displaying Data", "intro": "Displaying data is job number one for any good application. In Angular, you bind data to elements in HTML templates and Angular automatically updates the UI as data changes." diff --git a/public/docs/js/latest/guide/cheatsheet.jade b/public/docs/js/latest/guide/cheatsheet.jade new file mode 100644 index 0000000000..12e5a4cb11 --- /dev/null +++ b/public/docs/js/latest/guide/cheatsheet.jade @@ -0,0 +1,9 @@ +.banner + p.text-body This cheat sheet is provisional and may change. Angular 2 is currently in Developer Preview. + +article(class="l-content-small grid-fluid docs-content") + .cheatsheet + h2 Angular for JavaScript Cheat Sheet (v2.0.0-alpha.44) + br + br + ngio-cheatsheet(src='./cheatsheet.json') diff --git a/public/docs/ts/latest/guide/cheatsheet.jade b/public/docs/ts/latest/guide/cheatsheet.jade index 3db12ade7d..36975c286b 100644 --- a/public/docs/ts/latest/guide/cheatsheet.jade +++ b/public/docs/ts/latest/guide/cheatsheet.jade @@ -16,11 +16,4 @@ article(class="l-content-small grid-fluid docs-content") br br - table(ng-repeat='section in appCtrl.cheatsheet' ng-cloak) - tr - th {{section.name}} - th(ng-bind-html="appCtrl.getSafeHtml(section.description)") - tr(ng-repeat='child in section.items') - td - code(bold='child.bold',ng-compile) {{child.syntax}} - td(ng-bind-html="appCtrl.getSafeHtml(child.description)") + ngio-cheatsheet(src='./cheatsheet.json') diff --git a/public/resources/js/controllers/app-controller.js b/public/resources/js/controllers/app-controller.js index f3cc3b1ee0..e4e9ddf043 100644 --- a/public/resources/js/controllers/app-controller.js +++ b/public/resources/js/controllers/app-controller.js @@ -31,10 +31,6 @@ angularIO.controller('AppCtrl', ['$mdDialog', '$timeout', '$http', '$sce', funct vm.apiList = response.data; }); - $http.get('/resources/js/cheatsheet.json').then(function(response) { - vm.cheatsheet = response.data; - }); - vm.showDocsNav = false; vm.showMainNav = false; vm.showMenu = false; @@ -72,10 +68,6 @@ angularIO.controller('AppCtrl', ['$mdDialog', '$timeout', '$http', '$sce', funct vm.apiType = ''; vm.apiFilter = ''; - vm.getSafeHtml = function(html) { - return $sce.trustAsHtml(html); - }; - /* * Prettify Code * diff --git a/public/resources/js/directives/cheatsheet.js b/public/resources/js/directives/cheatsheet.js new file mode 100644 index 0000000000..c0c7ce3725 --- /dev/null +++ b/public/resources/js/directives/cheatsheet.js @@ -0,0 +1,26 @@ +angularIO.directive('ngioCheatsheet', function() { + return { + controllerAs: '$ctrl', + controller: function($http, $attrs, $sce) { + var $ctrl = this; + $http.get($attrs.src).then(function(response) { + $ctrl.sections = response.data; + }); + $ctrl.getSafeHtml = function(html) { + return $sce.trustAsHtml(html); + }; + }, + template: + '
Loading Cheatsheet...
\n' + + '\n' + + '\n' + + ' \n' + + ' \n' + + '\n' + + '\n' + + ' \n' + + ' \n' + + '\n' + + '
{{section.name}}
{{child.syntax}}
' + }; +}); \ No newline at end of file diff --git a/tools/api-builder/angular.io-package/index.js b/tools/api-builder/angular.io-package/index.js index b0ac6194cb..e60b9bb1a1 100644 --- a/tools/api-builder/angular.io-package/index.js +++ b/tools/api-builder/angular.io-package/index.js @@ -101,6 +101,12 @@ module.exports = new Package('angular.io', [basePackage, targetPackage, cheatshe pathTemplate: path.resolve(PUBLIC_PATH, 'resources/js/${id}'), outputPathTemplate: '${path}.json' }); + + computePathsProcessor.pathTemplates.push({ + docTypes: ['cheatsheet-data'], + pathTemplate: '../guide/cheatsheet.json', + outputPathTemplate: '${path}' + }); }) .config(function(getLinkInfo) { diff --git a/tools/api-builder/cheatsheet-package/processors/createCheatsheetDoc.js b/tools/api-builder/cheatsheet-package/processors/createCheatsheetDoc.js index 6a575103a1..679c714463 100644 --- a/tools/api-builder/cheatsheet-package/processors/createCheatsheetDoc.js +++ b/tools/api-builder/cheatsheet-package/processors/createCheatsheetDoc.js @@ -9,7 +9,7 @@ module.exports = function createCheatsheetDoc(createDocMessage, renderMarkdown) var cheatsheetDoc = { id: 'cheatsheet', aliases: ['cheatsheet'], - docType: 'json-data', + docType: 'cheatsheet-data', sections: [] };