aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2012-08-28 12:53:30 -0700
committerIgor Minar2012-08-28 16:08:03 -0700
commitb36acbc8577d087bde48ff6045d6188cd515b8b7 (patch)
tree04178e274ecad25c176b46a2e86dc029af35d689
parenta4fea38b94da3012798b69dd2e785cf9c3be5e1f (diff)
downloadangular.js-b36acbc8577d087bde48ff6045d6188cd515b8b7.tar.bz2
chore(docs): use symlinks to build docs
so that we can just edit source files without rebuilding docs. this works for all docs files, except for those that are generated or rewritten during build.
-rwxr-xr-xdocs/src/gen-docs.js47
-rw-r--r--docs/src/templates/index.html2
-rw-r--r--docs/src/writer.js50
3 files changed, 53 insertions, 46 deletions
diff --git a/docs/src/gen-docs.js b/docs/src/gen-docs.js
index aac9134b..e0a67dc6 100755
--- a/docs/src/gen-docs.js
+++ b/docs/src/gen-docs.js
@@ -12,8 +12,10 @@ process.on('uncaughtException', function(err) {
var start = now();
var docs;
-writer.makeDir('build/docs/syntaxhighlighter').then(function() {
- console.log('Generating Angular Reference Documentation...');
+writer.makeDir('build/docs/', true).then(function() {
+ return writer.makeDir('build/docs/partials/');
+}).then(function() {
+ console.log('Generating AngularJS Reference Documentation...');
return reader.collect();
}).then(function generateHtmlDocPartials(docs_) {
docs = docs_;
@@ -41,8 +43,10 @@ writer.makeDir('build/docs/syntaxhighlighter').then(function() {
function writeTheRest(writesFuture) {
var metadata = ngdoc.metadata(docs);
- writesFuture.push(writer.copyDir('img'));
- writesFuture.push(writer.copyDir('font'));
+ writesFuture.push(writer.symlinkTemplate('css'));
+ writesFuture.push(writer.symlinkTemplate('font'));
+ writesFuture.push(writer.symlinkTemplate('img'));
+ writesFuture.push(writer.symlinkTemplate('js'));
var manifest = 'manifest="/build/docs/appcache.manifest"';
@@ -66,38 +70,27 @@ function writeTheRest(writesFuture) {
writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-jq-debug.html',
writer.replace, {'doc:manifest': ''}));
- writesFuture.push(writer.copyTpl('offline.html'));
- writesFuture.push(writer.copyTpl('docs-scenario.html'));
- writesFuture.push(writer.copyTpl('js/jquery.min.js'));
- writesFuture.push(writer.copyTpl('js/jquery.js'));
+ writesFuture.push(writer.symlinkTemplate('offline.html'));
- writesFuture.push(writer.output('js/docs-keywords.js',
+ writesFuture.push(writer.copyTemplate('docs-scenario.html')); // will be rewritten, don't symlink
+ writesFuture.push(writer.output('docs-scenario.js', ngdoc.scenarios(docs)));
+
+ writesFuture.push(writer.output('docs-keywords.js',
['NG_PAGES=', JSON.stringify(metadata).replace(/{/g, '\n{'), ';']));
writesFuture.push(writer.output('sitemap.xml', new SiteMap(docs).render()));
- writesFuture.push(writer.output('docs-scenario.js', ngdoc.scenarios(docs)));
+
writesFuture.push(writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n'));
writesFuture.push(writer.output('appcache.manifest',appCache()));
- writesFuture.push(writer.copyTpl('.htaccess'));
+ writesFuture.push(writer.copyTemplate('.htaccess')); // will be rewritten, don't symlink
- writesFuture.push(writer.copy('docs/src/templates/js/docs.js', 'js/docs.js'));
-
- writesFuture.push(writer.copy('docs/src/templates/css/bootstrap.min.css', 'css/bootstrap.min.css'));
- writesFuture.push(writer.copy('docs/src/templates/css/docs.css', 'css/docs.css'));
- writesFuture.push(writer.copy('docs/src/templates/css/font-awesome.css', 'css/font-awesome.css'));
-
- writesFuture.push(writer.copyTpl('font/fontawesome-webfont.eot'));
- writesFuture.push(writer.copyTpl('font/fontawesome-webfont.svg'));
- writesFuture.push(writer.copyTpl('font/fontawesome-webfont.svgz'));
- writesFuture.push(writer.copyTpl('font/fontawesome-webfont.ttf'));
- writesFuture.push(writer.copyTpl('font/fontawesome-webfont.woff'));
-
- writesFuture.push(writer.copyTpl('app.yaml'));
- writesFuture.push(writer.copyTpl('index.yaml'));
- writesFuture.push(writer.copyTpl('favicon.ico'));
- writesFuture.push(writer.copyTpl('main.py'));
+ writesFuture.push(writer.symlinkTemplate('app.yaml'));
+ writesFuture.push(writer.symlinkTemplate('index.yaml'));
+ writesFuture.push(writer.symlinkTemplate('favicon.ico'));
+ writesFuture.push(writer.symlinkTemplate('main.py'));
}
function now() { return new Date().getTime(); }
function noop() {};
+
diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html
index b16f44de..0eda918c 100644
--- a/docs/src/templates/index.html
+++ b/docs/src/templates/index.html
@@ -42,7 +42,7 @@
addTag('script', {src: path('angular-bootstrap.js') }, sync);
addTag('script', {src: path('angular-bootstrap-prettify.js') }, sync);
addTag('script', {src: 'js/docs.js'}, sync);
- addTag('script', {src: 'js/docs-keywords.js'}, sync);
+ addTag('script', {src: 'docs-keywords.js'}, sync);
function path(name) {
if (gae) {
diff --git a/docs/src/writer.js b/docs/src/writer.js
index e99ad73e..6ca1dbab 100644
--- a/docs/src/writer.js
+++ b/docs/src/writer.js
@@ -4,7 +4,7 @@
*/
var qfs = require('q-fs');
var Q = require('qq');
-var OUTPUT_DIR = "build/docs/";
+var OUTPUT_DIR = 'build/docs/';
var fs = require('fs');
exports.output = output;
@@ -17,29 +17,27 @@ function output(file, content) {
};
//recursively create directory
-exports.makeDir = function(path) {
- var parts = path.split(/\//);
+exports.makeDir = function(p) {
+ var parts = p.split(/\//);
var path = ".";
- //Sequentially create directories
- var done = Q.defer();
- (function createPart() {
- if(!parts.length) {
- done.resolve();
- } else {
- path += "/" + parts.shift();
- qfs.isDirectory(path).then(function(isDir) {
- if(!isDir) {
- qfs.makeDirectory(path);
+ // Recursively rebuild directory structure
+ return qfs.exists(p).
+ then(function createPart(exists) {
+ if(!exists && parts.length) {
+ path += "/" + parts.shift();
+ return qfs.exists(path).then(function(exists) {
+ if (!exists) {
+ return qfs.makeDirectory(path).then(createPart, createPart);
+ } else {
+ return createPart();
+ }
+ });
}
- createPart();
});
- }
- })();
- return done.promise;
};
-exports.copyTpl = function(filename) {
+exports.copyTemplate = function(filename) {
return exports.copy('docs/src/templates/' + filename, filename);
};
@@ -59,8 +57,23 @@ exports.copy = function(from, to, transform) {
}
return output(to, content);
});
+};
+
+
+exports.symlinkTemplate= symlinkTemplate;
+function symlinkTemplate(filename) {
+ var dest = OUTPUT_DIR + filename,
+ dirDepth = dest.split('/').length,
+ src = Array(dirDepth).join('../') + 'docs/src/templates/' + filename;
+
+ return qfs.exists(dest).then(function(exists) {
+ if (!exists) {
+ qfs.symbolicLink(dest, src);
+ }
+ });
}
+
/* 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
@@ -132,3 +145,4 @@ exports.toString = function toString(obj) {
function noop() {};
+