chore(doc-gen): allow dart cheatsheet to be generated

This commit is contained in:
Peter Bacon Darwin
2015-12-08 20:23:43 +00:00
committed by Naomi Black
parent 652bf47de4
commit 8459a4dd5c
11 changed files with 73 additions and 19 deletions
+12 -2
View File
@@ -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';
}
});
+1
View File
@@ -16,6 +16,7 @@ script(src="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular
<!-- Angular.io Site JS -->
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")
+4
View File
@@ -5,6 +5,10 @@
"title": "Step By Step Guide"
},
"cheatsheet": {
"title": "Angular Cheat Sheet"
},
"setup": {
"title": "Getting Started"
},
@@ -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')
+4
View File
@@ -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."
@@ -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')
+1 -8
View File
@@ -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')
@@ -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
*
@@ -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:
'<div ng-if="!$ctrl.sections">Loading Cheatsheet...</div>\n' +
'<table ng-repeat="section in $ctrl.sections" ng-cloak>\n' +
'<tr>\n' +
' <th>{{section.name}}</th>\n' +
' <th ng-bind-html="$ctrl.getSafeHtml(section.description)"></th>\n' +
'</tr>\n' +
'<tr ng-repeat="child in section.items">\n' +
' <td><code bold="child.bold" ng-compile="true">{{child.syntax}}</code></td>\n' +
' <td ng-bind-html="$ctrl.getSafeHtml(child.description)"></td>\n' +
'</tr>\n' +
'</table>'
};
});
@@ -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) {
@@ -9,7 +9,7 @@ module.exports = function createCheatsheetDoc(createDocMessage, renderMarkdown)
var cheatsheetDoc = {
id: 'cheatsheet',
aliases: ['cheatsheet'],
docType: 'json-data',
docType: 'cheatsheet-data',
sections: []
};