From 452e7e7729ae2d38621c9d1039f95db34157346e Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 15 Dec 2015 11:28:02 +0000 Subject: [PATCH] chore(doc-gen): automatically update environment and version on the cheatsheet Closes #515 --- public/docs/dart/latest/guide/cheatsheet.jade | 2 -- public/docs/js/latest/guide/cheatsheet.jade | 2 -- public/docs/ts/latest/guide/cheatsheet.jade | 3 --- public/resources/js/directives/cheatsheet.js | 6 +++++- .../templates/cheatsheet.template.html | 6 +++++- .../processors/createCheatsheetDoc.js | 10 ++++++++-- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/public/docs/dart/latest/guide/cheatsheet.jade b/public/docs/dart/latest/guide/cheatsheet.jade index 82ee894512..ea9bd4bae5 100644 --- a/public/docs/dart/latest/guide/cheatsheet.jade +++ b/public/docs/dart/latest/guide/cheatsheet.jade @@ -3,6 +3,4 @@ article(class="l-content-small grid-fluid docs-content") .cheatsheet - h2 Angular for Dart Cheat Sheet (v2.0.0-alpha.54) - br ngio-cheatsheet(src='./cheatsheet.json') diff --git a/public/docs/js/latest/guide/cheatsheet.jade b/public/docs/js/latest/guide/cheatsheet.jade index 1a8bfeff93..ea9bd4bae5 100644 --- a/public/docs/js/latest/guide/cheatsheet.jade +++ b/public/docs/js/latest/guide/cheatsheet.jade @@ -3,6 +3,4 @@ article(class="l-content-small grid-fluid docs-content") .cheatsheet - h2 Angular for JavaScript Cheat Sheet (v2.0.0-alpha.54) - 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 0471d249fa..ea9bd4bae5 100644 --- a/public/docs/ts/latest/guide/cheatsheet.jade +++ b/public/docs/ts/latest/guide/cheatsheet.jade @@ -3,7 +3,4 @@ article(class="l-content-small grid-fluid docs-content") .cheatsheet - h2 Angular for TypeScript Cheat Sheet (v2.0.0-alpha.54) - br - ngio-cheatsheet(src='./cheatsheet.json') diff --git a/public/resources/js/directives/cheatsheet.js b/public/resources/js/directives/cheatsheet.js index c0c7ce3725..6b2ba9d9fe 100644 --- a/public/resources/js/directives/cheatsheet.js +++ b/public/resources/js/directives/cheatsheet.js @@ -4,13 +4,17 @@ angularIO.directive('ngioCheatsheet', function() { controller: function($http, $attrs, $sce) { var $ctrl = this; $http.get($attrs.src).then(function(response) { - $ctrl.sections = response.data; + $ctrl.currentEnvironment = response.data.currentEnvironment; + $ctrl.version = response.data.version; + $ctrl.sections = response.data.sections; }); $ctrl.getSafeHtml = function(html) { return $sce.trustAsHtml(html); }; }, template: + '

Angular for {{$ctrl.currentEnvironment}} Cheat Sheet (v{{ $ctrl.version.raw }})

' + + '
' + '
Loading Cheatsheet...
\n' + '\n' + '\n' + diff --git a/tools/api-builder/angular.io-package/templates/cheatsheet.template.html b/tools/api-builder/angular.io-package/templates/cheatsheet.template.html index 8a955a2529..72077d8ee3 100644 --- a/tools/api-builder/angular.io-package/templates/cheatsheet.template.html +++ b/tools/api-builder/angular.io-package/templates/cheatsheet.template.html @@ -1 +1,5 @@ -{$ doc.sections | json $} \ No newline at end of file +{ + "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/tools/api-builder/cheatsheet-package/processors/createCheatsheetDoc.js b/tools/api-builder/cheatsheet-package/processors/createCheatsheetDoc.js index 679c714463..80528d9abf 100644 --- a/tools/api-builder/cheatsheet-package/processors/createCheatsheetDoc.js +++ b/tools/api-builder/cheatsheet-package/processors/createCheatsheetDoc.js @@ -1,16 +1,22 @@ var _ = require('lodash'); -module.exports = function createCheatsheetDoc(createDocMessage, renderMarkdown) { +module.exports = function createCheatsheetDoc(createDocMessage, renderMarkdown, versionInfo, targetEnvironments) { return { $runAfter: ['processing-docs'], $runBefore: ['docs-processed'], $process: function(docs) { + var currentEnvironment = targetEnvironments.isActive('ts') && 'TypeScript' || + targetEnvironments.isActive('js') && 'JavaScript' || + targetEnvironments.isActive('dart') && 'Dart'; + var cheatsheetDoc = { id: 'cheatsheet', aliases: ['cheatsheet'], docType: 'cheatsheet-data', - sections: [] + sections: [], + version: versionInfo, + currentEnvironment: currentEnvironment }; docs = docs.filter(function(doc) {