Permalink
Browse files

Exploring windows support: get cake build working.

This gets the windows build of Docco to run over itself, and fixes `cake
build`

Now with 100% more just-hack-it.

The 'spawn' change in Cakefile is because of a windows specific nodejs
limitation: CreateProcessW only works on executable files, so any batch
files or other scripts cannot be launched using it.
  • Loading branch information...
1 parent b2d878b commit 41bad5a1ef2a851bfe00df49903fd4c1aa8b21b7 @justindujardin justindujardin committed Aug 22, 2012
Showing with 26 additions and 52 deletions.
  1. +2 −1 Cakefile
  2. +16 −43 lib/docco.js
  3. +8 −8 src/docco.coffee
View
@@ -8,8 +8,9 @@ option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'
option '-w', '--watch', 'continually build the docco library'
task 'build', 'build the docco library', (options) ->
- coffee = spawn 'coffee', ['-c' + (if options.watch then 'w' else ''), '-o', 'lib', 'src']
+ coffee = spawn 'node', ['./node_modules/coffee-script/bin/coffee','-c' + (if options.watch then 'w' else ''), '-o', 'lib', 'src']
coffee.stdout.on 'data', (data) -> console.log data.toString().trim()
+ coffee.stderr.on 'data', (data) -> console.log data.toString().trim()
task 'install', 'install the `docco` command into /usr/local (or --prefix)', (options) ->
base = options.prefix or '/usr/local'
View
@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.3.3
(function() {
- var commander, defaults, document, ensureDirectory, exec, ext, fs, generateDocumentation, generateHtml, getLanguage, getResource, highlight, highlightEnd, highlightStart, htmlEscape, key, l, languages, parse, path, resolveSource, run, showdown, spawn, template, value, version, _ref, _ref1,
+ var commander, defaults, document, ensureDirectory, exec, ext, fs, generateDocumentation, generateHtml, getLanguage, getResource, highlight, highlightEnd, highlightStart, key, l, languages, parse, path, resolveSource, run, showdown, spawn, template, value, version, _ref, _ref1,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
generateDocumentation = function(source, config, callback) {
@@ -70,8 +70,15 @@
}
return _results;
})()).join(language.docsSplitText);
- pygments.stderr.on('data', function() {});
- pygments.stdin.on('error', function() {});
+ pygments.stderr.on('data', function(error) {
+ if (error) {
+ return console.error(error.toString());
+ }
+ });
+ pygments.stdin.on('error', function(error) {
+ console.error('Could not use Pygments to highlight the source.');
+ return process.exit(1);
+ });
pygments.stdout.on('data', function(result) {
if (result) {
return output += result;
@@ -80,19 +87,7 @@
pygments.on('exit', function() {
var codeFragments, docsFragments, i, _i, _len;
output = output.replace(highlightStart, '').replace(highlightEnd, '');
- if (output === '') {
- codeFragments = (function() {
- var _i, _len, _results;
- _results = [];
- for (_i = 0, _len = sections.length; _i < _len; _i++) {
- section = sections[_i];
- _results.push(htmlEscape(section.codeText));
- }
- return _results;
- })();
- } else {
- codeFragments = output.split(language.codeSplitHtml);
- }
+ codeFragments = output.split(language.codeSplitHtml);
docsFragments = showdown.makeHtml(docs).split(language.docsSplitHtml);
for (i = _i = 0, _len = sections.length; _i < _len; i = ++_i) {
section = sections[i];
@@ -107,10 +102,6 @@
}
};
- htmlEscape = function(string) {
- return string.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g, '&#x2F;');
- };
-
generateHtml = function(source, sections, config) {
var dest, destination, html, title;
destination = function(filepath) {
@@ -154,34 +145,17 @@
l.commentFilter = /(^#![/]|^\s*#\{)/;
l.codeSplitText = "\n" + l.symbol + "DIVIDER\n";
l.codeSplitHtml = RegExp("\\n*<span\\sclass=\"c1?\">" + l.symbol + "DIVIDER<\\/span>\\n*");
- l.docsSplitText = "\n#" + l.name + "DOCDIVIDER\n";
+ l.docsSplitText = "\n# " + l.name + "DOCDIVIDER\n";
l.docsSplitHtml = RegExp("<h1>" + l.name + "DOCDIVIDER</h1>");
}
getLanguage = function(source) {
return languages[path.extname(source)];
};
- ensureDirectory = function(dir, cb, made) {
- var mode;
- if (made == null) {
- made = null;
- }
- mode = parseInt('0777', 8);
- return fs.mkdir(dir, mode, function(er) {
- if (!er) {
- return cb(null, made || dir);
- }
- if (er.code === 'ENOENT') {
- return ensureDirectory(path.dirname(dir), function(er, made) {
- if (er) {
- return cb(er, made);
- } else {
- return ensureDirectory(dir, cb, made);
- }
- });
- }
- return cb(er, made);
+ ensureDirectory = function(dir, callback) {
+ return fs.mkdir(dir, function() {
+ return callback();
});
};
@@ -293,8 +267,7 @@
resolveSource: resolveSource,
version: version,
defaults: defaults,
- languages: languages,
- ensureDirectory: ensureDirectory
+ languages: languages
};
for (key in _ref1) {
value = _ref1[key];
View
@@ -124,7 +124,7 @@ highlight = (source, sections, callback) ->
if output is ''
codeFragments = (htmlEscape section.codeText for section in sections)
else
- codeFragments = output.split language.codeSplitHtml
+ codeFragments = output.split language.codeSplitHtml
docsFragments = showdown.makeHtml(docs).split language.docsSplitHtml
for section, i in sections
@@ -327,12 +327,12 @@ resolveSource = (source) ->
# Information about docco, and functions for programatic usage.
exports[key] = value for key, value of {
- run : run
- document : document
- parse : parse
- resolveSource : resolveSource
- version : version
- defaults : defaults
- languages : languages
+ run : run
+ document : document
+ parse : parse
+ resolveSource : resolveSource
+ version : version
+ defaults : defaults
+ languages : languages
ensureDirectory: ensureDirectory
}

0 comments on commit 41bad5a

Please sign in to comment.