chore(doc-gen): automatically update environment and version on the cheatsheet

Closes #515
This commit is contained in:
Peter Bacon Darwin 2015-12-15 11:28:02 +00:00 committed by Naomi Black
parent b11cf9419f
commit 452e7e7729
6 changed files with 18 additions and 11 deletions

View File

@ -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')

View File

@ -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')

View File

@ -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')

View File

@ -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:
'<h2>Angular for {{$ctrl.currentEnvironment}} Cheat Sheet (v{{ $ctrl.version.raw }})</h2>' +
'<br>' +
'<div ng-if="!$ctrl.sections">Loading Cheatsheet...</div>\n' +
'<table ng-repeat="section in $ctrl.sections" ng-cloak>\n' +
'<tr>\n' +

View File

@ -1 +1,5 @@
{$ doc.sections | json $}
{
"currentEnvironment": {$ doc.currentEnvironment | json | trim $},
"version": {$ doc.version.currentVersion | json | indent(2) | trim $},
"sections": {$ doc.sections | json | indent(2) | trim $}
}

View File

@ -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) {