Skip to content
Browse files

Added .m as Objective-C

  • Loading branch information...
1 parent bc21835 commit 063b74d4af4781e53a886bfd6f7fda9a38f263cb @txgruppi txgruppi committed Dec 28, 2012
Showing with 44 additions and 20 deletions.
  1. +41 −19 lib/docco.js
  2. +3 −1 resources/languages.json
View
60 lib/docco.js
@@ -1,11 +1,14 @@
+// Generated by CoffeeScript 1.4.0
(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, _ref2;
- var __hasProp = Object.prototype.hasOwnProperty, __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (__hasProp.call(this, i) && this[i] === item) return i; } return -1; };
+ 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,
+ __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) {
return fs.readFile(source, function(error, buffer) {
var code, sections;
- if (error) throw error;
+ if (error) {
+ throw error;
+ }
code = buffer.toString();
sections = parse(source, code);
return highlight(source, sections, function() {
@@ -22,6 +25,7 @@
language = getLanguage(source);
hasCode = docsText = codeText = '';
save = function(docsText, codeText) {
+ console.log(docsText);
return sections.push({
docsText: docsText,
codeText: codeText
@@ -70,10 +74,12 @@
pygments.stderr.on('data', function() {});
pygments.stdin.on('error', function() {});
pygments.stdout.on('data', function(result) {
- if (result) return output += result;
+ if (result) {
+ return output += result;
+ }
});
pygments.on('exit', function() {
- var codeFragments, docsFragments, i, section, _len;
+ var codeFragments, docsFragments, i, _i, _len;
output = output.replace(highlightStart, '').replace(highlightEnd, '');
if (output === '') {
codeFragments = (function() {
@@ -89,7 +95,7 @@
codeFragments = output.split(language.codeSplitHtml);
}
docsFragments = showdown.makeHtml(docs).split(language.docsSplitHtml);
- for (i = 0, _len = sections.length; i < _len; i++) {
+ for (i = _i = 0, _len = sections.length; _i < _len; i = ++_i) {
section = sections[i];
section.codeHtml = highlightStart + codeFragments[i] + highlightEnd;
section.docsHtml = docsFragments[i];
@@ -159,10 +165,14 @@
ensureDirectory = function(dir, cb, made) {
var mode;
- if (made == null) made = null;
+ 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) {
+ return cb(null, made || dir);
+ }
if (er.code === 'ENOENT') {
return ensureDirectory(path.dirname(dir), function(er, made) {
if (er) {
@@ -193,7 +203,9 @@
};
run = function(args) {
- if (args == null) args = process.argv;
+ if (args == null) {
+ args = process.argv;
+ }
commander.version(version).usage("[options] <filePattern ...>").option("-c, --css [file]", "use a custom css file", defaults.css).option("-o, --output [path]", "use a custom output path", defaults.output).option("-t, --template [file]", "use a custom .jst template", defaults.template).parse(args).name = "docco";
if (commander.args.length) {
return document(commander.args.slice(), commander);
@@ -203,9 +215,13 @@
};
document = function(sources, options, callback) {
- var config, doccoStyles, key, m, resolved, src, value, _i, _j, _len, _len2;
- if (options == null) options = {};
- if (callback == null) callback = null;
+ var config, doccoStyles, key, m, resolved, src, value, _i, _j, _len, _len1;
+ if (options == null) {
+ options = {};
+ }
+ if (callback == null) {
+ callback = null;
+ }
config = {};
for (key in defaults) {
value = defaults[key];
@@ -225,7 +241,7 @@
config.sources = resolved.filter(function(source) {
return getLanguage(source);
}).sort();
- for (_j = 0, _len2 = resolved.length; _j < _len2; _j++) {
+ for (_j = 0, _len1 = resolved.length; _j < _len1; _j++) {
m = resolved[_j];
if (__indexOf.call(config.sources, m) < 0) {
console.log("docco: skipped unknown type (" + m + ")");
@@ -238,7 +254,9 @@
fs.writeFileSync(path.join(config.output, path.basename(config.css)), doccoStyles);
files = config.sources.slice();
nextFile = function() {
- if ((callback != null) && !files.length) callback();
+ if ((callback != null) && !files.length) {
+ callback();
+ }
if (files.length) {
return generateDocumentation(files.shift(), config, nextFile);
}
@@ -249,7 +267,9 @@
resolveSource = function(source) {
var file, file_path, files, regex, regex_str;
- if (!source.match(/([\*\?])/)) return source;
+ if (!source.match(/([\*\?])/)) {
+ return source;
+ }
regex_str = path.basename(source).replace(/\./g, "\\$&").replace(/\*/, ".*").replace(/\?/, ".");
regex = new RegExp('^(' + regex_str + ')$');
file_path = path.dirname(source);
@@ -259,13 +279,15 @@
_results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
- if (file.match(regex)) _results.push(path.join(file_path, file));
+ if (file.match(regex)) {
+ _results.push(path.join(file_path, file));
+ }
}
return _results;
})();
};
- _ref2 = {
+ _ref1 = {
run: run,
document: document,
parse: parse,
@@ -275,8 +297,8 @@
languages: languages,
ensureDirectory: ensureDirectory
};
- for (key in _ref2) {
- value = _ref2[key];
+ for (key in _ref1) {
+ value = _ref1[key];
exports[key] = value;
}
View
4 resources/languages.json
@@ -39,5 +39,7 @@
".markdown":
{"name" : "text", "symbol" : ""},
".less":
- {"name" : "scss", "symbol": "//"}
+ {"name" : "scss", "symbol": "//"},
+ ".m":
+ {"name" : "objc", "symbol": "//"}
}

0 comments on commit 063b74d

Please sign in to comment.
Something went wrong with that request. Please try again.