mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-19 12:01:07 +00:00
feat(doc): generate both normal and debug version of index.html
- index.html has manifest file and angular.min.js - index-jq.html has manifest file, angular.min.js and jquery.min.js - index-debug.html has angular.js - index-jq-debug.html has angular.js and jquery.min.js
This commit is contained in:
parent
08a33e7bb3
commit
19401280ae
4 changed files with 66 additions and 12 deletions
|
|
@ -15,4 +15,20 @@ describe('writer', function(){
|
||||||
expect(toString(['abc',{}])).toEqual('abc{}');
|
expect(toString(['abc',{}])).toEqual('abc{}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('replace method', function() {
|
||||||
|
var content,
|
||||||
|
replacements;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
content = 'angular super jQuery manifest';
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should replace placeholders', function() {
|
||||||
|
replacements = {'angular': 'ng', 'jQuery': 'jqlite','notHere': 'here'};
|
||||||
|
|
||||||
|
content = writer.replace(content, replacements);
|
||||||
|
expect(content).toBe('ng super jqlite manifest');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,30 @@ function writeTheRest(writesFuture) {
|
||||||
|
|
||||||
writesFuture.push(writer.copyDir('img'));
|
writesFuture.push(writer.copyDir('img'));
|
||||||
writesFuture.push(writer.copyDir('examples'));
|
writesFuture.push(writer.copyDir('examples'));
|
||||||
writesFuture.push(writer.copyTpl('index.html'));
|
|
||||||
writesFuture.push(writer.copy('docs/src/templates/index.html',
|
var manifest = 'manifest="appcache.manifest"',
|
||||||
'build/docs/index-jq.html',
|
jq = '<script src="jquery.min.js"></script>',
|
||||||
'<!-- jquery place holder -->',
|
ngMin = '<script src="../angular.min.js" ng:autobind></script>',
|
||||||
'<script src=\"jquery.min.js\"><\/script>'));
|
ng = '<script src="../angular.js" ng:autobind></script>'
|
||||||
|
|
||||||
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index.html',
|
||||||
|
writer.replace, {'doc:manifest': manifest,
|
||||||
|
'<!-- angular script place holder -->': ngMin}));
|
||||||
|
|
||||||
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq.html',
|
||||||
|
writer.replace, {'doc:manifest': manifest,
|
||||||
|
'<!-- angular script place holder -->': ngMin,
|
||||||
|
'<!-- jquery place holder -->': jq}));
|
||||||
|
|
||||||
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-debug.html',
|
||||||
|
writer.replace, {'doc:manifest': '',
|
||||||
|
'<!-- angular script place holder -->': ng}));
|
||||||
|
|
||||||
|
writesFuture.push(writer.copy('docs/src/templates/index.html', 'build/docs/index-jq-debug.html',
|
||||||
|
writer.replace, {'doc:manifest': '',
|
||||||
|
'<!-- angular script place holder -->': ng,
|
||||||
|
'<!-- jquery place holder -->': jq}));
|
||||||
|
|
||||||
writesFuture.push(writer.copyTpl('offline.html'));
|
writesFuture.push(writer.copyTpl('offline.html'));
|
||||||
writesFuture.push(writer.copyTpl('docs-scenario.html'));
|
writesFuture.push(writer.copyTpl('docs-scenario.html'));
|
||||||
writesFuture.push(writer.copyTpl('jquery.min.js'));
|
writesFuture.push(writer.copyTpl('jquery.min.js'));
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<html xmlns:ng="http://angularjs.org/"
|
<html xmlns:ng="http://angularjs.org/"
|
||||||
xmlns:doc="http://docs.angularjs.org/"
|
xmlns:doc="http://docs.angularjs.org/"
|
||||||
ng:controller="DocsController"
|
ng:controller="DocsController"
|
||||||
manifest="appcache.manifest">
|
doc:manifest>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<title ng:bind-template="AngularJS: {{partialTitle}}">AngularJS</title>
|
<title ng:bind-template="AngularJS: {{partialTitle}}">AngularJS</title>
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
|
|
||||||
<script src="syntaxhighlighter/syntaxhighlighter-combined.js"></script>
|
<script src="syntaxhighlighter/syntaxhighlighter-combined.js"></script>
|
||||||
<!-- jquery place holder -->
|
<!-- jquery place holder -->
|
||||||
<script src="../angular.min.js" ng:autobind></script>
|
<!-- angular script place holder -->
|
||||||
<script src="docs-combined.js"></script>
|
<script src="docs-combined.js"></script>
|
||||||
<script src="docs-keywords.js"></script>
|
<script src="docs-keywords.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -44,16 +44,35 @@ exports.copyTpl = function(filename) {
|
||||||
return exports.copy('docs/src/templates/' + filename, OUTPUT_DIR + filename);
|
return exports.copy('docs/src/templates/' + filename, OUTPUT_DIR + filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.copy = function (from, to, replacementKey, replacement) {
|
/* Copy files from one place to another.
|
||||||
// Have to use rb (read binary), char 'r' is infered by library.
|
* @param from{string} path of the source file to be copied
|
||||||
return qfs.read(from,'b').then(function(content) {
|
* @param to{string} path of where the copied file should be stored
|
||||||
if(replacementKey && replacement) {
|
* @param transform{function=} transfromation function to be applied before return
|
||||||
content = content.toString().replace(replacementKey, replacement);
|
*/
|
||||||
|
exports.copy = function(from, to, transform) {
|
||||||
|
var args = Array.prototype.slice.call(arguments, 3);
|
||||||
|
|
||||||
|
// We have to use binary reading, Since some characters are unicode.
|
||||||
|
return qfs.read(from, 'b').then(function(content) {
|
||||||
|
if (transform) {
|
||||||
|
args.unshift(content.toString());
|
||||||
|
content = transform.apply(null, args);
|
||||||
}
|
}
|
||||||
qfs.write(to, content);
|
qfs.write(to, content);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Replace placeholders in content accordingly
|
||||||
|
* @param content{string} content to be modified
|
||||||
|
* @param replacements{obj} key and value pairs in which key will be replaced with value in content
|
||||||
|
*/
|
||||||
|
exports.replace = function(content, replacements) {
|
||||||
|
for(key in replacements) {
|
||||||
|
content = content.replace(key, replacements[key]);
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
exports.copyDir = function copyDir(dir) {
|
exports.copyDir = function copyDir(dir) {
|
||||||
return qfs.listDirectoryTree('docs/' + dir).then(function(dirs) {
|
return qfs.listDirectoryTree('docs/' + dir).then(function(dirs) {
|
||||||
var done;
|
var done;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue