Browse Source
Former-commit-id: 53204a1c85ee275ae507727bbfb1292cb18e1e4b Former-commit-id: 25894a4dc640eb51105e5ee1e0dfa0d88045823ebeta
Jack Lukic
12 years ago
62 changed files with 5839 additions and 0 deletions
@ -0,0 +1 @@ |
|||
/node_modules/ |
@ -0,0 +1,33 @@ |
|||
module.exports = function(grunt) { |
|||
|
|||
// Project configuration.
|
|||
grunt.initConfig({ |
|||
clean: { tests: ["docs"] }, |
|||
docco: { |
|||
tests: { |
|||
src: ['test/**/*.js', 'test/**/*.coffee'], |
|||
dest: "docs/" |
|||
}, |
|||
'custom-css-test': { |
|||
src: ['test/**/*.js'], |
|||
dest: 'docs/', |
|||
options: { |
|||
css: 'test/fixtures/custom.css' |
|||
} |
|||
} |
|||
}, |
|||
nodeunit: { |
|||
tests: ['test/*_test.js'] |
|||
} |
|||
}); |
|||
|
|||
// Load local tasks.
|
|||
grunt.loadTasks('tasks'); |
|||
grunt.loadNpmTasks('grunt-contrib-nodeunit'); |
|||
grunt.loadNpmTasks('grunt-contrib-clean'); |
|||
grunt.registerTask('test', ['clean:tests', 'docco', 'nodeunit:tests']); |
|||
|
|||
// Default task.
|
|||
grunt.registerTask('default', ['lint', 'docco']); |
|||
|
|||
}; |
@ -0,0 +1,22 @@ |
|||
Copyright (c) 2012 David Souther |
|||
|
|||
Permission is hereby granted, free of charge, to any person |
|||
obtaining a copy of this software and associated documentation |
|||
files (the "Software"), to deal in the Software without |
|||
restriction, including without limitation the rights to use, |
|||
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the |
|||
Software is furnished to do so, subject to the following |
|||
conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be |
|||
included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|||
OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,38 @@ |
|||
# grunt-docco |
|||
|
|||
Grunt Docco plugin. |
|||
|
|||
## Getting Started |
|||
Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-docco` |
|||
|
|||
Then add this line to your project's `grunt.js` gruntfile: |
|||
|
|||
```javascript |
|||
grunt.loadNpmTasks('grunt-docco'); |
|||
``` |
|||
|
|||
[grunt]: https://github.com/cowboy/grunt |
|||
[getting_started]: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md |
|||
|
|||
## Documentation |
|||
``` |
|||
docco: { |
|||
debug: { |
|||
src: ['test/**/*.js'], |
|||
options: { |
|||
output: 'docs/' |
|||
} |
|||
} |
|||
} |
|||
|
|||
``` |
|||
|
|||
## Contributing |
|||
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt][grunt]. |
|||
|
|||
## Release History |
|||
_(Nothing yet)_ |
|||
|
|||
## License |
|||
Copyright (c) 2012 David Souther |
|||
Licensed under the MIT license. |
@ -0,0 +1 @@ |
|||
../docco/bin/docco |
@ -0,0 +1,5 @@ |
|||
.DS_Store |
|||
output |
|||
docs |
|||
test/data |
|||
node_modules |
@ -0,0 +1,107 @@ |
|||
Docco = require './src/docco' |
|||
CoffeeScript = require 'coffee-script' |
|||
{spawn, exec} = require 'child_process' |
|||
fs = require 'fs' |
|||
path = require 'path' |
|||
|
|||
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.stdout.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' |
|||
lib = base + '/lib/docco' |
|||
exec([ |
|||
'mkdir -p ' + lib |
|||
'cp -rf bin README resources vendor lib ' + lib |
|||
'ln -sf ' + lib + '/bin/docco ' + base + '/bin/docco' |
|||
].join(' && '), (err, stdout, stderr) -> |
|||
if err then console.error stderr |
|||
) |
|||
|
|||
task 'doc', 'rebuild the Docco documentation', -> |
|||
exec([ |
|||
'bin/docco src/docco.coffee' |
|||
'sed "s/docco.css/resources\\/docco.css/" < docs/docco.html > index.html' |
|||
'rm -r docs' |
|||
].join(' && '), (err) -> |
|||
throw err if err |
|||
) |
|||
|
|||
task 'test', 'run the Docco test suite', -> |
|||
runTests Docco |
|||
|
|||
# Simple test runner, borrowed from [CoffeeScript](http://coffeescript.org/). |
|||
runTests = (Docco) -> |
|||
startTime = Date.now() |
|||
currentFile = null |
|||
passedTests = 0 |
|||
failures = [] |
|||
|
|||
global[name] = func for name, func of require 'assert' |
|||
|
|||
# Convenience alias. |
|||
global.Docco = Docco |
|||
|
|||
# Our test helper function for delimiting different test cases. |
|||
global.test = (description, fn) -> |
|||
try |
|||
fn.test = {description, currentFile} |
|||
fn.call(fn) |
|||
++passedTests |
|||
catch e |
|||
e.description = description if description? |
|||
e.source = fn.toString() if fn.toString? |
|||
failures.push filename: currentFile, error: e |
|||
|
|||
# See http://wiki.ecmascript.org/doku.php?id=harmony:egal |
|||
egal = (a, b) -> |
|||
if a is b |
|||
a isnt 0 or 1/a is 1/b |
|||
else |
|||
a isnt a and b isnt b |
|||
|
|||
# A recursive functional equivalence helper; uses egal for testing equivalence. |
|||
arrayEgal = (a, b) -> |
|||
if egal a, b then yes |
|||
else if a instanceof Array and b instanceof Array |
|||
return no unless a.length is b.length |
|||
return no for el, idx in a when not arrayEgal el, b[idx] |
|||
yes |
|||
|
|||
global.eq = (a, b, msg) -> ok egal(a, b), msg |
|||
global.arrayEq = (a, b, msg) -> ok arrayEgal(a,b), msg |
|||
|
|||
# When all the tests have run, collect and print errors. |
|||
# If a stacktrace is available, output the compiled function source. |
|||
process.on 'exit', -> |
|||
time = ((Date.now() - startTime) / 1000).toFixed(2) |
|||
message = "passed #{passedTests} tests in #{time} seconds" |
|||
return console.log(message) unless failures.length |
|||
console.log "failed #{failures.length} and #{message}" |
|||
for fail in failures |
|||
{error, filename} = fail |
|||
jsFilename = filename.replace(/\.coffee$/,'.js') |
|||
match = error.stack?.match(new RegExp(fail.file+":(\\d+):(\\d+)")) |
|||
match = error.stack?.match(/on line (\d+):/) unless match |
|||
[match, line, col] = match if match |
|||
console.log '' |
|||
console.log " #{error.description}" |
|||
console.log " #{error.stack}" |
|||
console.log " #{jsFilename}: line #{line ? 'unknown'}, column #{col ? 'unknown'}" |
|||
console.log " #{error.source}" if error.source |
|||
return |
|||
|
|||
# Run every test in the `test` folder, recording failures. |
|||
files = fs.readdirSync 'test' |
|||
for file in files when file.match /\.coffee$/i |
|||
currentFile = filename = path.join 'test', file |
|||
code = fs.readFileSync filename |
|||
try |
|||
CoffeeScript.run code.toString(), {filename} |
|||
catch error |
|||
failures.push {filename, error} |
|||
return !failures.length |
@ -0,0 +1,25 @@ |
|||
____ |
|||
/\ _`\ |
|||
\ \ \/\ \ ___ ___ ___ ___ |
|||
\ \ \ \ \ / __`\ /'___\ /'___\ / __`\ |
|||
\ \ \_\ \ /\ \ \ \ /\ \__/ /\ \__/ /\ \ \ \ |
|||
\ \____/ \ \____/ \ \____\ \ \____\ \ \____/ |
|||
\/___/ \/___/ \/____/ \/____/ \/___/ |
|||
|
|||
|
|||
Docco is a quick-and-dirty, hundred-line-long, literate-programming-style |
|||
documentation generator. For more information, see: |
|||
|
|||
http://jashkenas.github.com/docco/ |
|||
|
|||
$ docco |
|||
|
|||
Usage: docco [options] <filePattern ...> |
|||
|
|||
Options: |
|||
|
|||
-h, --help output usage information |
|||
-V, --version output the version number |
|||
-c, --css [file] use a custom css file |
|||
-o, --output [path] use a custom output path |
|||
-t, --template [file] use a custom .jst template |
@ -0,0 +1,6 @@ |
|||
#!/usr/bin/env node |
|||
|
|||
var path = require('path'); |
|||
var fs = require('fs'); |
|||
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib'); |
|||
require(lib + '/docco.js').run(); |
@ -0,0 +1 @@ |
|||
64d70f4ebbe38d5c3c2f03ca26c2e1d1b6279367 |
@ -0,0 +1,265 @@ |
|||
// Generated by CoffeeScript 1.3.3
|
|||
(function() { |
|||
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) { |
|||
return fs.readFile(source, function(error, buffer) { |
|||
var code, sections; |
|||
if (error) { |
|||
throw error; |
|||
} |
|||
code = buffer.toString(); |
|||
sections = parse(source, code); |
|||
return highlight(source, sections, function() { |
|||
generateHtml(source, sections, config); |
|||
return callback(); |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
parse = function(source, code) { |
|||
var codeText, docsText, hasCode, language, line, lines, save, sections, _i, _len; |
|||
lines = code.split('\n'); |
|||
sections = []; |
|||
language = getLanguage(source); |
|||
hasCode = docsText = codeText = ''; |
|||
save = function(docsText, codeText) { |
|||
return sections.push({ |
|||
docsText: docsText, |
|||
codeText: codeText |
|||
}); |
|||
}; |
|||
for (_i = 0, _len = lines.length; _i < _len; _i++) { |
|||
line = lines[_i]; |
|||
if (line.match(language.commentMatcher) && !line.match(language.commentFilter)) { |
|||
if (hasCode) { |
|||
save(docsText, codeText); |
|||
hasCode = docsText = codeText = ''; |
|||
} |
|||
docsText += line.replace(language.commentMatcher, '') + '\n'; |
|||
} else { |
|||
hasCode = true; |
|||
codeText += line + '\n'; |
|||
} |
|||
} |
|||
save(docsText, codeText); |
|||
return sections; |
|||
}; |
|||
|
|||
highlight = function(source, sections, callback) { |
|||
var language, output, pygments, section, text; |
|||
language = getLanguage(source); |
|||
pygments = spawn('pygmentize', ['-l', language.name, '-f', 'html', '-O', 'encoding=utf-8,tabsize=2']); |
|||
output = ''; |
|||
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; |
|||
} |
|||
}); |
|||
pygments.on('exit', function() { |
|||
var fragments, i, section, _i, _len; |
|||
output = output.replace(highlightStart, '').replace(highlightEnd, ''); |
|||
fragments = output.split(language.dividerHtml); |
|||
for (i = _i = 0, _len = sections.length; _i < _len; i = ++_i) { |
|||
section = sections[i]; |
|||
section.codeHtml = highlightStart + fragments[i] + highlightEnd; |
|||
section.docsHtml = showdown.makeHtml(section.docsText); |
|||
} |
|||
return callback(); |
|||
}); |
|||
if (pygments.stdin.writable) { |
|||
text = (function() { |
|||
var _i, _len, _results; |
|||
_results = []; |
|||
for (_i = 0, _len = sections.length; _i < _len; _i++) { |
|||
section = sections[_i]; |
|||
_results.push(section.codeText); |
|||
} |
|||
return _results; |
|||
})(); |
|||
pygments.stdin.write(text.join(language.dividerText)); |
|||
return pygments.stdin.end(); |
|||
} |
|||
}; |
|||
|
|||
generateHtml = function(source, sections, config) { |
|||
var dest, destination, html, title; |
|||
destination = function(filepath) { |
|||
return path.join(config.output, path.basename(filepath, path.extname(filepath)) + '.html'); |
|||
}; |
|||
title = path.basename(source); |
|||
dest = destination(source); |
|||
html = config.doccoTemplate({ |
|||
title: title, |
|||
sections: sections, |
|||
sources: config.sources, |
|||
path: path, |
|||
destination: destination, |
|||
css: path.basename(config.css) |
|||
}); |
|||
console.log("docco: " + source + " -> " + dest); |
|||
return fs.writeFileSync(dest, html); |
|||
}; |
|||
|
|||
fs = require('fs'); |
|||
|
|||
path = require('path'); |
|||
|
|||
showdown = require('./../vendor/showdown').Showdown; |
|||
|
|||
_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec; |
|||
|
|||
commander = require('commander'); |
|||
|
|||
getResource = function(name) { |
|||
var fullPath; |
|||
fullPath = path.join(__dirname, '..', 'resources', name); |
|||
return fs.readFileSync(fullPath).toString(); |
|||
}; |
|||
|
|||
languages = JSON.parse(getResource('languages.json')); |
|||
|
|||
for (ext in languages) { |
|||
l = languages[ext]; |
|||
l.commentMatcher = RegExp("^\\s*" + l.symbol + "\\s?"); |
|||
l.commentFilter = /(^#![/]|^\s*#\{)/; |
|||
l.dividerText = "\n" + l.symbol + "DIVIDER\n"; |
|||
l.dividerHtml = RegExp("\\n*<span\\sclass=\"c1?\">" + l.symbol + "DIVIDER<\\/span>\\n*"); |
|||
} |
|||
|
|||
getLanguage = function(source) { |
|||
return languages[path.extname(source)]; |
|||
}; |
|||
|
|||
ensureDirectory = function(dir, callback) { |
|||
return exec("mkdir -p " + dir, function() { |
|||
return callback(); |
|||
}); |
|||
}; |
|||
|
|||
template = function(str) { |
|||
return new Function('obj', 'var p=[],print=function(){p.push.apply(p,arguments);};' + 'with(obj){p.push(\'' + str.replace(/[\r\t\n]/g, " ").replace(/'(?=[^<]*%>)/g, "\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g, "',$1,'").split('<%').join("');").split('%>').join("p.push('") + "');}return p.join('');"); |
|||
}; |
|||
|
|||
highlightStart = '<div class="highlight"><pre>'; |
|||
|
|||
highlightEnd = '</pre></div>'; |
|||
|
|||
version = JSON.parse(fs.readFileSync("" + __dirname + "/../package.json")).version; |
|||
|
|||
defaults = { |
|||
template: "" + __dirname + "/../resources/docco.jst", |
|||
css: "" + __dirname + "/../resources/docco.css", |
|||
output: "docs/" |
|||
}; |
|||
|
|||
run = function(args) { |
|||
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); |
|||
} else { |
|||
return console.log(commander.helpInformation()); |
|||
} |
|||
}; |
|||
|
|||
document = function(sources, options, callback) { |
|||
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]; |
|||
config[key] = defaults[key]; |
|||
} |
|||
if (key in defaults) { |
|||
for (key in options) { |
|||
value = options[key]; |
|||
config[key] = value; |
|||
} |
|||
} |
|||
resolved = []; |
|||
for (_i = 0, _len = sources.length; _i < _len; _i++) { |
|||
src = sources[_i]; |
|||
resolved = resolved.concat(resolveSource(src)); |
|||
} |
|||
config.sources = resolved.filter(function(source) { |
|||
return getLanguage(source); |
|||
}).sort(); |
|||
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 + ")"); |
|||
} |
|||
} |
|||
config.doccoTemplate = template(fs.readFileSync(config.template).toString()); |
|||
doccoStyles = fs.readFileSync(config.css).toString(); |
|||
return ensureDirectory(config.output, function() { |
|||
var files, nextFile; |
|||
fs.writeFileSync(path.join(config.output, path.basename(config.css)), doccoStyles); |
|||
files = config.sources.slice(); |
|||
nextFile = function() { |
|||
if ((callback != null) && !files.length) { |
|||
callback(); |
|||
} |
|||
if (files.length) { |
|||
return generateDocumentation(files.shift(), config, nextFile); |
|||
} |
|||
}; |
|||
return nextFile(); |
|||
}); |
|||
}; |
|||
|
|||
resolveSource = function(source) { |
|||
var file, file_path, files, regex, regex_str; |
|||
if (!source.match(/([\*\?])/)) { |
|||
return source; |
|||
} |
|||
regex_str = path.basename(source).replace(/\./g, "\\$&").replace(/\*/, ".*").replace(/\?/, "."); |
|||
regex = new RegExp('^(' + regex_str + ')$'); |
|||
file_path = path.dirname(source); |
|||
files = fs.readdirSync(file_path); |
|||
return (function() { |
|||
var _i, _len, _results; |
|||
_results = []; |
|||
for (_i = 0, _len = files.length; _i < _len; _i++) { |
|||
file = files[_i]; |
|||
if (file.match(regex)) { |
|||
_results.push(path.join(file_path, file)); |
|||
} |
|||
} |
|||
return _results; |
|||
})(); |
|||
}; |
|||
|
|||
_ref1 = { |
|||
run: run, |
|||
document: document, |
|||
parse: parse, |
|||
resolveSource: resolveSource, |
|||
version: version, |
|||
defaults: defaults, |
|||
languages: languages |
|||
}; |
|||
for (key in _ref1) { |
|||
value = _ref1[key]; |
|||
exports[key] = value; |
|||
} |
|||
|
|||
}).call(this); |
@ -0,0 +1,4 @@ |
|||
support |
|||
test |
|||
examples |
|||
*.sock |
@ -0,0 +1,4 @@ |
|||
language: node_js |
|||
node_js: |
|||
- 0.4 |
|||
- 0.6 |
@ -0,0 +1,152 @@ |
|||
|
|||
1.1.1 / 2012-11-20 |
|||
================== |
|||
|
|||
* add more sub-command padding |
|||
* fix .usage() when args are present. Closes #106 |
|||
|
|||
1.1.0 / 2012-11-16 |
|||
================== |
|||
|
|||
* add git-style executable subcommand support. Closes #94 |
|||
|
|||
1.0.5 / 2012-10-09 |
|||
================== |
|||
|
|||
* fix `--name` clobbering. Closes #92 |
|||
* fix examples/help. Closes #89 |
|||
|
|||
1.0.4 / 2012-09-03 |
|||
================== |
|||
|
|||
* add `outputHelp()` method. |
|||
|
|||
1.0.3 / 2012-08-30 |
|||
================== |
|||
|
|||
* remove invalid .version() defaulting |
|||
|
|||
1.0.2 / 2012-08-24 |
|||
================== |
|||
|
|||
* add `--foo=bar` support [arv] |
|||
* fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus] |
|||
|
|||
1.0.1 / 2012-08-03 |
|||
================== |
|||
|
|||
* fix issue #56 |
|||
* fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode()) |
|||
|
|||
1.0.0 / 2012-07-05 |
|||
================== |
|||
|
|||
* add support for optional option descriptions |
|||
* add defaulting of `.version()` to package.json's version |
|||
|
|||
0.6.1 / 2012-06-01 |
|||
================== |
|||
|
|||
* Added: append (yes or no) on confirmation |
|||
* Added: allow node.js v0.7.x |
|||
|
|||
0.6.0 / 2012-04-10 |
|||
================== |
|||
|
|||
* Added `.prompt(obj, callback)` support. Closes #49 |
|||
* Added default support to .choose(). Closes #41 |
|||
* Fixed the choice example |
|||
|
|||
0.5.1 / 2011-12-20 |
|||
================== |
|||
|
|||
* Fixed `password()` for recent nodes. Closes #36 |
|||
|
|||
0.5.0 / 2011-12-04 |
|||
================== |
|||
|
|||
* Added sub-command option support [itay] |
|||
|
|||
0.4.3 / 2011-12-04 |
|||
================== |
|||
|
|||
* Fixed custom help ordering. Closes #32 |
|||
|
|||
0.4.2 / 2011-11-24 |
|||
================== |
|||
|
|||
* Added travis support |
|||
* Fixed: line-buffered input automatically trimmed. Closes #31 |
|||
|
|||
0.4.1 / 2011-11-18 |
|||
================== |
|||
|
|||
* Removed listening for "close" on --help |
|||
|
|||
0.4.0 / 2011-11-15 |
|||
================== |
|||
|
|||
* Added support for `--`. Closes #24 |
|||
|
|||
0.3.3 / 2011-11-14 |
|||
================== |
|||
|
|||
* Fixed: wait for close event when writing help info [Jerry Hamlet] |
|||
|
|||
0.3.2 / 2011-11-01 |
|||
================== |
|||
|
|||
* Fixed long flag definitions with values [felixge] |
|||
|
|||
0.3.1 / 2011-10-31 |
|||
================== |
|||
|
|||
* Changed `--version` short flag to `-V` from `-v` |
|||
* Changed `.version()` so it's configurable [felixge] |
|||
|
|||
0.3.0 / 2011-10-31 |
|||
================== |
|||
|
|||
* Added support for long flags only. Closes #18 |
|||
|
|||
0.2.1 / 2011-10-24 |
|||
================== |
|||
|
|||
* "node": ">= 0.4.x < 0.7.0". Closes #20 |
|||
|
|||
0.2.0 / 2011-09-26 |
|||
================== |
|||
|
|||
* Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs] |
|||
|
|||
0.1.0 / 2011-08-24 |
|||
================== |
|||
|
|||
* Added support for custom `--help` output |
|||
|
|||
0.0.5 / 2011-08-18 |
|||
================== |
|||
|
|||
* Changed: when the user enters nothing prompt for password again |
|||
* Fixed issue with passwords beginning with numbers [NuckChorris] |
|||
|
|||
0.0.4 / 2011-08-15 |
|||
================== |
|||
|
|||
* Fixed `Commander#args` |
|||
|
|||
0.0.3 / 2011-08-15 |
|||
================== |
|||
|
|||
* Added default option value support |
|||
|
|||
0.0.2 / 2011-08-15 |
|||
================== |
|||
|
|||
* Added mask support to `Command#password(str[, mask], fn)` |
|||
* Added `Command#password(str, fn)` |
|||
|
|||
0.0.1 / 2010-01-03 |
|||
================== |
|||
|
|||
* Initial release |
@ -0,0 +1,7 @@ |
|||
|
|||
TESTS = $(shell find test/test.*.js) |
|||
|
|||
test: |
|||
@./test/run $(TESTS) |
|||
|
|||
.PHONY: test |
@ -0,0 +1,270 @@ |
|||
# Commander.js |
|||
|
|||
The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/visionmedia/commander). |
|||
|
|||
[![Build Status](https://secure.travis-ci.org/visionmedia/commander.js.png)](http://travis-ci.org/visionmedia/commander.js) |
|||
|
|||
## Installation |
|||
|
|||
$ npm install commander |
|||
|
|||
## Option parsing |
|||
|
|||
Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options. |
|||
|
|||
```js |
|||
#!/usr/bin/env node |
|||
|
|||
/** |
|||
* Module dependencies. |
|||
*/ |
|||
|
|||
var program = require('commander'); |
|||
|
|||
program |
|||
.version('0.0.1') |
|||
.option('-p, --peppers', 'Add peppers') |
|||
.option('-P, --pineapple', 'Add pineapple') |
|||
.option('-b, --bbq', 'Add bbq sauce') |
|||
.option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble') |
|||
.parse(process.argv); |
|||
|
|||
console.log('you ordered a pizza with:'); |
|||
if (program.peppers) console.log(' - peppers'); |
|||
if (program.pineapple) console.log(' - pineappe'); |
|||
if (program.bbq) console.log(' - bbq'); |
|||
console.log(' - %s cheese', program.cheese); |
|||
``` |
|||
|
|||
Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc. |
|||
|
|||
## Automated --help |
|||
|
|||
The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free: |
|||
|
|||
``` |
|||
$ ./examples/pizza --help |
|||
|
|||
Usage: pizza [options] |
|||
|
|||
Options: |
|||
|
|||
-V, --version output the version number |
|||
-p, --peppers Add peppers |
|||
-P, --pineapple Add pineappe |
|||
-b, --bbq Add bbq sauce |
|||
-c, --cheese <type> Add the specified type of cheese [marble] |
|||
-h, --help output usage information |
|||
|
|||
``` |
|||
|
|||
## Coercion |
|||
|
|||
```js |
|||
function range(val) { |
|||
return val.split('..').map(Number); |
|||
} |
|||
|
|||
function list(val) { |
|||
return val.split(','); |
|||
} |
|||
|
|||
program |
|||
.version('0.0.1') |
|||
.usage('[options] <file ...>') |
|||
.option('-i, --integer <n>', 'An integer argument', parseInt) |
|||
.option('-f, --float <n>', 'A float argument', parseFloat) |
|||
.option('-r, --range <a>..<b>', 'A range', range) |
|||
.option('-l, --list <items>', 'A list', list) |
|||
.option('-o, --optional [value]', 'An optional value') |
|||
.parse(process.argv); |
|||
|
|||
console.log(' int: %j', program.integer); |
|||
console.log(' float: %j', program.float); |
|||
console.log(' optional: %j', program.optional); |
|||
program.range = program.range || []; |
|||
console.log(' range: %j..%j', program.range[0], program.range[1]); |
|||
console.log(' list: %j', program.list); |
|||
console.log(' args: %j', program.args); |
|||
``` |
|||
|
|||
## Custom help |
|||
|
|||
You can display arbitrary `-h, --help` information |
|||
by listening for "--help". Commander will automatically |
|||
exit once you are done so that the remainder of your program |
|||
does not execute causing undesired behaviours, for example |
|||
in the following executable "stuff" will not output when |
|||
`--help` is used. |
|||
|
|||
```js |
|||
#!/usr/bin/env node |
|||
|
|||
/** |
|||
* Module dependencies. |
|||
*/ |
|||
|
|||
var program = require('../'); |
|||
|
|||
function list(val) { |
|||
return val.split(',').map(Number); |
|||
} |
|||
|
|||
program |
|||
.version('0.0.1') |
|||
.option('-f, --foo', 'enable some foo') |
|||
.option('-b, --bar', 'enable some bar') |
|||
.option('-B, --baz', 'enable some baz'); |
|||
|
|||
// must be before .parse() since |
|||
// node's emit() is immediate |
|||
|
|||
program.on('--help', function(){ |
|||
console.log(' Examples:'); |
|||
console.log(''); |
|||
console.log(' $ custom-help --help'); |
|||
console.log(' $ custom-help -h'); |
|||
console.log(''); |
|||
}); |
|||
|
|||
program.parse(process.argv); |
|||
|
|||
console.log('stuff'); |
|||
``` |
|||
|
|||
yielding the following help output: |
|||
|
|||
``` |
|||
|
|||
Usage: custom-help [options] |
|||
|
|||
Options: |
|||
|
|||
-h, --help output usage information |
|||
-V, --version output the version number |
|||
-f, --foo enable some foo |
|||
-b, --bar enable some bar |
|||
-B, --baz enable some baz |
|||
|
|||
Examples: |
|||
|
|||
$ custom-help --help |
|||
$ custom-help -h |
|||
|
|||
``` |
|||
|
|||
## .prompt(msg, fn) |
|||
|
|||
Single-line prompt: |
|||
|
|||
```js |
|||
program.prompt('name: ', function(name){ |
|||
console.log('hi %s', name); |
|||
}); |
|||
``` |
|||
|
|||
Multi-line prompt: |
|||
|
|||
```js |
|||
program.prompt('description:', function(name){ |
|||
console.log('hi %s', name); |
|||
}); |
|||
``` |
|||
|
|||
Coercion: |
|||
|
|||
```js |
|||
program.prompt('Age: ', Number, function(age){ |
|||
console.log('age: %j', age); |
|||
}); |
|||
``` |
|||
|
|||
```js |
|||
program.prompt('Birthdate: ', Date, function(date){ |
|||
console.log('date: %s', date); |
|||
}); |
|||
``` |
|||
|
|||
## .password(msg[, mask], fn) |
|||
|
|||
Prompt for password without echoing: |
|||
|
|||
```js |
|||
program.password('Password: ', function(pass){ |
|||
console.log('got "%s"', pass); |
|||
process.stdin.destroy(); |
|||
}); |
|||
``` |
|||
|
|||
Prompt for password with mask char "*": |
|||
|
|||
```js |
|||
program.password('Password: ', '*', function(pass){ |
|||
console.log('got "%s"', pass); |
|||
process.stdin.destroy(); |
|||
}); |
|||
``` |
|||
|
|||
## .confirm(msg, fn) |
|||
|
|||
Confirm with the given `msg`: |
|||
|
|||
```js |
|||
program.confirm('continue? ', function(ok){ |
|||
console.log(' got %j', ok); |
|||
}); |
|||
``` |
|||
|
|||
## .choose(list, fn) |
|||
|
|||
Let the user choose from a `list`: |
|||
|
|||
```js |
|||
var list = ['tobi', 'loki', 'jane', 'manny', 'luna']; |
|||
|
|||
console.log('Choose the coolest pet:'); |
|||
program.choose(list, function(i){ |
|||
console.log('you chose %d "%s"', i, list[i]); |
|||
}); |
|||
``` |
|||
|
|||
## .outputHelp() |
|||
|
|||
Output help information without exiting. |
|||
|
|||
## .help() |
|||
|
|||
Output help information and exit immediately. |
|||
|
|||
## Links |
|||
|
|||
- [API documentation](http://visionmedia.github.com/commander.js/) |
|||
- [ascii tables](https://github.com/LearnBoost/cli-table) |
|||
- [progress bars](https://github.com/visionmedia/node-progress) |
|||
- [more progress bars](https://github.com/substack/node-multimeter) |
|||
- [examples](https://github.com/visionmedia/commander.js/tree/master/examples) |
|||
|
|||
## License |
|||
|
|||
(The MIT License) |
|||
|
|||
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca> |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining |
|||
a copy of this software and associated documentation files (the |
|||
'Software'), to deal in the Software without restriction, including |
|||
without limitation the rights to use, copy, modify, merge, publish, |
|||
distribute, sublicense, and/or sell copies of the Software, and to |
|||
permit persons to whom the Software is furnished to do so, subject to |
|||
the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be |
|||
included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
File diff suppressed because it is too large
@ -0,0 +1,101 @@ |
|||
keypress |
|||
======== |
|||
### Make any Node ReadableStream emit "keypress" events |
|||
|
|||
|
|||
Previous to Node `v0.8.x`, there was an undocumented `"keypress"` event that |
|||
`process.stdin` would emit when it was a TTY. Some people discovered this hidden |
|||
gem, and started using it in their own code. |
|||
|
|||
Now in Node `v0.8.x`, this `"keypress"` event does not get emitted by default, |
|||
but rather only when it is being used in conjuction with the `readline` (or by |
|||
extension, the `repl`) module. |
|||
|
|||
This module is the exact logic from the node `v0.8.x` releases ripped out into its |
|||
own module. |
|||
|
|||
__Bonus:__ Now with mouse support! |
|||
|
|||
Installation |
|||
------------ |
|||
|
|||
Install with `npm`: |
|||
|
|||
``` bash |
|||
$ npm install keypress |
|||
``` |
|||
|
|||
Or add it to the `"dependencies"` section of your _package.json_ file. |
|||
|
|||
|
|||
Example |
|||
------- |
|||
|
|||
#### Listening for "keypress" events |
|||
|
|||
``` js |
|||
var keypress = require('keypress'); |
|||
|
|||
// make `process.stdin` begin emitting "keypress" events |
|||
keypress(process.stdin); |
|||
|
|||
// listen for the "keypress" event |
|||
process.stdin.on('keypress', function (ch, key) { |
|||
console.log('got "keypress"', key); |
|||
if (key && key.ctrl && key.name == 'c') { |
|||
process.stdin.pause(); |
|||
} |
|||
}); |
|||
|
|||
process.stdin.setRawMode(true); |
|||
process.stdin.resume(); |
|||
``` |
|||
|
|||
#### Listening for "mousepress" events |
|||
|
|||
``` js |
|||
var keypress = require('keypress'); |
|||
|
|||
// make `process.stdin` begin emitting "mousepress" (and "keypress") events |
|||
keypress(process.stdin); |
|||
|
|||
// you must enable the mouse events before they will begin firing |
|||
keypress.enableMouse(process.stdout); |
|||
|
|||
process.stdin.on('mousepress', function (info) { |
|||
console.log('got "mousepress" event at %d x %d', info.x, info.y); |
|||
}); |
|||
|
|||
process.on('exit', function () { |
|||
// disable mouse on exit, so that the state |
|||
// is back to normal for the terminal |
|||
keypress.disableMouse(process.stdout); |
|||
}); |
|||
``` |
|||
|
|||
|
|||
License |
|||
------- |
|||
|
|||
(The MIT License) |
|||
|
|||
Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net> |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining |
|||
a copy of this software and associated documentation files (the |
|||
'Software'), to deal in the Software without restriction, including |
|||
without limitation the rights to use, copy, modify, merge, publish, |
|||
distribute, sublicense, and/or sell copies of the Software, and to |
|||
permit persons to whom the Software is furnished to do so, subject to |
|||
the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be |
|||
included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,346 @@ |
|||
|
|||
/** |
|||
* This module offers the internal "keypress" functionality from node-core's |
|||
* `readline` module, for your own programs and modules to use. |
|||
* |
|||
* Usage: |
|||
* |
|||
* require('keypress')(process.stdin); |
|||
* |
|||
* process.stdin.on('keypress', function (ch, key) { |
|||
* console.log(ch, key); |
|||
* if (key.ctrl && key.name == 'c') { |
|||
* process.stdin.pause(); |
|||
* } |
|||
* }); |
|||
* proces.stdin.resume(); |
|||
*/ |
|||
var exports = module.exports = keypress; |
|||
|
|||
exports.enableMouse = function (stream) { |
|||
stream.write('\x1b' +'[?1000h') |
|||
} |
|||
|
|||
exports.disableMouse = function (stream) { |
|||
stream.write('\x1b' +'[?1000l') |
|||
} |
|||
|
|||
|
|||
/** |
|||
* accepts a readable Stream instance and makes it emit "keypress" events |
|||
*/ |
|||
|
|||
function keypress(stream) { |
|||
if (isEmittingKeypress(stream)) return; |
|||
stream._emitKeypress = true; |
|||
|
|||
function onData(b) { |
|||
if (stream.listeners('keypress').length > 0) { |
|||
emitKey(stream, b); |
|||
} else { |
|||
// Nobody's watching anyway
|
|||
stream.removeListener('data', onData); |
|||
stream.on('newListener', onNewListener); |
|||
} |
|||
} |
|||
|
|||
function onNewListener(event) { |
|||
if (event == 'keypress') { |
|||
stream.on('data', onData); |
|||
stream.removeListener('newListener', onNewListener); |
|||
} |
|||
} |
|||
|
|||
if (stream.listeners('keypress').length > 0) { |
|||
stream.on('data', onData); |
|||
} else { |
|||
stream.on('newListener', onNewListener); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Returns `true` if the stream is already emitting "keypress" events. |
|||
* `false` otherwise. |
|||
*/ |
|||
|
|||
function isEmittingKeypress(stream) { |
|||
var rtn = stream._emitKeypress; |
|||
if (!rtn) { |
|||
// hack: check for the v0.6.x "data" event
|
|||
stream.listeners('data').forEach(function (l) { |
|||
if (l.name == 'onData' && /emitKey/.test(l.toString())) { |
|||
rtn = true; |
|||
stream._emitKeypress = true; |
|||
} |
|||
}); |
|||
} |
|||
if (!rtn) { |
|||
// hack: check for the v0.6.x "newListener" event
|
|||
stream.listeners('newListener').forEach(function (l) { |
|||
if (l.name == 'onNewListener' && /keypress/.test(l.toString())) { |
|||
rtn = true; |
|||
stream._emitKeypress = true; |
|||
} |
|||
}); |
|||
} |
|||
return rtn; |
|||
} |
|||
|
|||
|
|||
/* |
|||
Some patterns seen in terminal key escape codes, derived from combos seen |
|||
at http://www.midnight-commander.org/browser/lib/tty/key.c
|
|||
|
|||
ESC letter |
|||
ESC [ letter |
|||
ESC [ modifier letter |
|||
ESC [ 1 ; modifier letter |
|||
ESC [ num char |
|||
ESC [ num ; modifier char |
|||
ESC O letter |
|||
ESC O modifier letter |
|||
ESC O 1 ; modifier letter |
|||
ESC N letter |
|||
ESC [ [ num ; modifier char |
|||
ESC [ [ 1 ; modifier letter |
|||
ESC ESC [ num char |
|||
ESC ESC O letter |
|||
|
|||
- char is usually ~ but $ and ^ also happen with rxvt |
|||
- modifier is 1 + |
|||
(shift * 1) + |
|||
(left_alt * 2) + |
|||
(ctrl * 4) + |
|||
(right_alt * 8) |
|||
- two leading ESCs apparently mean the same as one leading ESC |
|||
*/ |
|||
|
|||
// Regexes used for ansi escape code splitting
|
|||
var metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/; |
|||
var functionKeyCodeRe = |
|||
/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/; |
|||
|
|||
function emitKey(stream, s) { |
|||
var ch, |
|||
key = { |
|||
name: undefined, |
|||
ctrl: false, |
|||
meta: false, |
|||
shift: false |
|||
}, |
|||
parts; |
|||
|
|||
if (Buffer.isBuffer(s)) { |
|||
if (s[0] > 127 && s[1] === undefined) { |
|||
s[0] -= 128; |
|||
s = '\x1b' + s.toString(stream.encoding || 'utf-8'); |
|||
} else { |
|||
s = s.toString(stream.encoding || 'utf-8'); |
|||
} |
|||
} |
|||
|
|||
key.sequence = s; |
|||
|
|||
if (s === '\r' || s === '\n') { |
|||
// enter
|
|||
key.name = 'enter'; |
|||
|
|||
} else if (s === '\t') { |
|||
// tab
|
|||
key.name = 'tab'; |
|||
|
|||
} else if (s === '\b' || s === '\x7f' || |
|||
s === '\x1b\x7f' || s === '\x1b\b') { |
|||
// backspace or ctrl+h
|
|||
key.name = 'backspace'; |
|||
key.meta = (s.charAt(0) === '\x1b'); |
|||
|
|||
} else if (s === '\x1b' || s === '\x1b\x1b') { |
|||
// escape key
|
|||
key.name = 'escape'; |
|||
key.meta = (s.length === 2); |
|||
|
|||
} else if (s === ' ' || s === '\x1b ') { |
|||
key.name = 'space'; |
|||
key.meta = (s.length === 2); |
|||
|
|||
} else if (s <= '\x1a') { |
|||
// ctrl+letter
|
|||
key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1); |
|||
key.ctrl = true; |
|||
|
|||
} else if (s.length === 1 && s >= 'a' && s <= 'z') { |
|||
// lowercase letter
|
|||
key.name = s; |
|||
|
|||
} else if (s.length === 1 && s >= 'A' && s <= 'Z') { |
|||
// shift+letter
|
|||
key.name = s.toLowerCase(); |
|||
key.shift = true; |
|||
|
|||
} else if (parts = metaKeyCodeRe.exec(s)) { |
|||
// meta+character key
|
|||
key.name = parts[1].toLowerCase(); |
|||
key.meta = true; |
|||
key.shift = /^[A-Z]$/.test(parts[1]); |
|||
|
|||
} else if (parts = functionKeyCodeRe.exec(s)) { |
|||
// ansi escape sequence
|
|||
|
|||
// reassemble the key code leaving out leading \x1b's,
|
|||
// the modifier key bitflag and any meaningless "1;" sequence
|
|||
var code = (parts[1] || '') + (parts[2] || '') + |
|||
(parts[4] || '') + (parts[6] || ''), |
|||
modifier = (parts[3] || parts[5] || 1) - 1; |
|||
|
|||
// Parse the key modifier
|
|||
key.ctrl = !!(modifier & 4); |
|||
key.meta = !!(modifier & 10); |
|||
key.shift = !!(modifier & 1); |
|||
key.code = code; |
|||
|
|||
// Parse the key itself
|
|||
switch (code) { |
|||
/* xterm/gnome ESC O letter */ |
|||
case 'OP': key.name = 'f1'; break; |
|||
case 'OQ': key.name = 'f2'; break; |
|||
case 'OR': key.name = 'f3'; break; |
|||
case 'OS': key.name = 'f4'; break; |
|||
|
|||
/* xterm/rxvt ESC [ number ~ */ |
|||
case '[11~': key.name = 'f1'; break; |
|||
case '[12~': key.name = 'f2'; break; |
|||
case '[13~': key.name = 'f3'; break; |
|||
case '[14~': key.name = 'f4'; break; |
|||
|
|||
/* from Cygwin and used in libuv */ |
|||
case '[[A': key.name = 'f1'; break; |
|||
case '[[B': key.name = 'f2'; break; |
|||
case '[[C': key.name = 'f3'; break; |
|||
case '[[D': key.name = 'f4'; break; |
|||
case '[[E': key.name = 'f5'; break; |
|||
|
|||
/* common */ |
|||
case '[15~': key.name = 'f5'; break; |
|||
case '[17~': key.name = 'f6'; break; |
|||
case '[18~': key.name = 'f7'; break; |
|||
case '[19~': key.name = 'f8'; break; |
|||
case '[20~': key.name = 'f9'; break; |
|||
case '[21~': key.name = 'f10'; break; |
|||
case '[23~': key.name = 'f11'; break; |
|||
case '[24~': key.name = 'f12'; break; |
|||
|
|||
/* xterm ESC [ letter */ |
|||
case '[A': key.name = 'up'; break; |
|||
case '[B': key.name = 'down'; break; |
|||
case '[C': key.name = 'right'; break; |
|||
case '[D': key.name = 'left'; break; |
|||
case '[E': key.name = 'clear'; break; |
|||
case '[F': key.name = 'end'; break; |
|||
case '[H': key.name = 'home'; break; |
|||
|
|||
/* xterm/gnome ESC O letter */ |
|||
case 'OA': key.name = 'up'; break; |
|||
case 'OB': key.name = 'down'; break; |
|||
case 'OC': key.name = 'right'; break; |
|||
case 'OD': key.name = 'left'; break; |
|||
case 'OE': key.name = 'clear'; break; |
|||
case 'OF': key.name = 'end'; break; |
|||
case 'OH': key.name = 'home'; break; |
|||
|
|||
/* xterm/rxvt ESC [ number ~ */ |
|||
case '[1~': key.name = 'home'; break; |
|||
case '[2~': key.name = 'insert'; break; |
|||
case '[3~': key.name = 'delete'; break; |
|||
case '[4~': key.name = 'end'; break; |
|||
case '[5~': key.name = 'pageup'; break; |
|||
case '[6~': key.name = 'pagedown'; break; |
|||
|
|||
/* putty */ |
|||
case '[[5~': key.name = 'pageup'; break; |
|||
case '[[6~': key.name = 'pagedown'; break; |
|||
|
|||
/* rxvt */ |
|||
case '[7~': key.name = 'home'; break; |
|||
case '[8~': key.name = 'end'; break; |
|||
|
|||
/* rxvt keys with modifiers */ |
|||
case '[a': key.name = 'up'; key.shift = true; break; |
|||
case '[b': key.name = 'down'; key.shift = true; break; |
|||
case '[c': key.name = 'right'; key.shift = true; break; |
|||
case '[d': key.name = 'left'; key.shift = true; break; |
|||
case '[e': key.name = 'clear'; key.shift = true; break; |
|||
|
|||
case '[2$': key.name = 'insert'; key.shift = true; break; |
|||
case '[3$': key.name = 'delete'; key.shift = true; break; |
|||
case '[5$': key.name = 'pageup'; key.shift = true; break; |
|||
case '[6$': key.name = 'pagedown'; key.shift = true; break; |
|||
case '[7$': key.name = 'home'; key.shift = true; break; |
|||
case '[8$': key.name = 'end'; key.shift = true; break; |
|||
|
|||
case 'Oa': key.name = 'up'; key.ctrl = true; break; |
|||
case 'Ob': key.name = 'down'; key.ctrl = true; break; |
|||
case 'Oc': key.name = 'right'; key.ctrl = true; break; |
|||
case 'Od': key.name = 'left'; key.ctrl = true; break; |
|||
case 'Oe': key.name = 'clear'; key.ctrl = true; break; |
|||
|
|||
case '[2^': key.name = 'insert'; key.ctrl = true; break; |
|||
case '[3^': key.name = 'delete'; key.ctrl = true; break; |
|||
case '[5^': key.name = 'pageup'; key.ctrl = true; break; |
|||
case '[6^': key.name = 'pagedown'; key.ctrl = true; break; |
|||
case '[7^': key.name = 'home'; key.ctrl = true; break; |
|||
case '[8^': key.name = 'end'; key.ctrl = true; break; |
|||
|
|||
/* misc. */ |
|||
case '[Z': key.name = 'tab'; key.shift = true; break; |
|||
default: key.name = 'undefined'; break; |
|||
|
|||
} |
|||
} else if (s.length > 1 && s[0] !== '\x1b') { |
|||
// Got a longer-than-one string of characters.
|
|||
// Probably a paste, since it wasn't a control sequence.
|
|||
Array.prototype.forEach.call(s, function(c) { |
|||
emitKey(stream, c); |
|||
}); |
|||
return; |
|||
} |
|||
|
|||
if (key.code == '[M') { |
|||
key.name = 'mouse'; |
|||
var s = key.sequence; |
|||
var b = s.charCodeAt(3); |
|||
key.x = s.charCodeAt(4) - 040; |
|||
key.y = s.charCodeAt(5) - 040; |
|||
|
|||
key.scroll = 0; |
|||
|
|||
key.ctrl = !!(1<<4 & b); |
|||
key.meta = !!(1<<3 & b); |
|||
key.shift = !!(1<<2 & b); |
|||
|
|||
key.release = (3 & b) === 3; |
|||
|
|||
if (1<<6 & b) { //scroll
|
|||
key.scroll = 1 & b ? 1 : -1; |
|||
} |
|||
|
|||
if (!key.release && !key.scroll) { |
|||
key.button = b & 3; |
|||
} |
|||
} |
|||
|
|||
// Don't emit a key if no name was found
|
|||
if (key.name === undefined) { |
|||
key = undefined; |
|||
} |
|||
|
|||
if (s.length === 1) { |
|||
ch = s; |
|||
} |
|||
|
|||
if (key && key.name == 'mouse') { |
|||
stream.emit('mousepress', key) |
|||
} else if (key || ch) { |
|||
stream.emit('keypress', ch, key); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
{ |
|||
"name": "keypress", |
|||
"version": "0.1.0", |
|||
"description": "Make any Node ReadableStream emit \"keypress\" events", |
|||
"author": { |
|||
"name": "Nathan Rajlich", |
|||
"email": "nathan@tootallnate.net", |
|||
"url": "http://tootallnate.net" |
|||
}, |
|||
"main": "index.js", |
|||
"scripts": { |
|||
"test": "echo \"Error: no test specified\" && exit 1" |
|||
}, |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/TooTallNate/keypress.git" |
|||
}, |
|||
"keywords": [ |
|||
"keypress", |
|||
"readline", |
|||
"core" |
|||
], |
|||
"license": "MIT", |
|||
"readme": "keypress\n========\n### Make any Node ReadableStream emit \"keypress\" events\n\n\nPrevious to Node `v0.8.x`, there was an undocumented `\"keypress\"` event that\n`process.stdin` would emit when it was a TTY. Some people discovered this hidden\ngem, and started using it in their own code.\n\nNow in Node `v0.8.x`, this `\"keypress\"` event does not get emitted by default,\nbut rather only when it is being used in conjuction with the `readline` (or by\nextension, the `repl`) module.\n\nThis module is the exact logic from the node `v0.8.x` releases ripped out into its\nown module.\n\n__Bonus:__ Now with mouse support!\n\nInstallation\n------------\n\nInstall with `npm`:\n\n``` bash\n$ npm install keypress\n```\n\nOr add it to the `\"dependencies\"` section of your _package.json_ file.\n\n\nExample\n-------\n\n#### Listening for \"keypress\" events\n\n``` js\nvar keypress = require('keypress');\n\n// make `process.stdin` begin emitting \"keypress\" events\nkeypress(process.stdin);\n\n// listen for the \"keypress\" event\nprocess.stdin.on('keypress', function (ch, key) {\n console.log('got \"keypress\"', key);\n if (key && key.ctrl && key.name == 'c') {\n process.stdin.pause();\n }\n});\n\nprocess.stdin.setRawMode(true);\nprocess.stdin.resume();\n```\n\n#### Listening for \"mousepress\" events\n\n``` js\nvar keypress = require('keypress');\n\n// make `process.stdin` begin emitting \"mousepress\" (and \"keypress\") events\nkeypress(process.stdin);\n\n// you must enable the mouse events before they will begin firing\nkeypress.enableMouse(process.stdout);\n\nprocess.stdin.on('mousepress', function (info) {\n console.log('got \"mousepress\" event at %d x %d', info.x, info.y);\n});\n\nprocess.on('exit', function () {\n // disable mouse on exit, so that the state\n // is back to normal for the terminal\n keypress.disableMouse(process.stdout);\n});\n```\n\n\nLicense\n-------\n\n(The MIT License)\n\nCopyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", |
|||
"readmeFilename": "README.md", |
|||
"bugs": { |
|||
"url": "https://github.com/TooTallNate/keypress/issues" |
|||
}, |
|||
"_id": "keypress@0.1.0", |
|||
"_from": "keypress@0.1.x" |
|||
} |
@ -0,0 +1,28 @@ |
|||
|
|||
var keypress = require('./') |
|||
keypress(process.stdin) |
|||
|
|||
if (process.stdin.setRawMode) |
|||
process.stdin.setRawMode(true) |
|||
else |
|||
require('tty').setRawMode(true) |
|||
|
|||
process.stdin.on('keypress', function (c, key) { |
|||
console.log(0, c, key) |
|||
if (key && key.ctrl && key.name == 'c') { |
|||
process.stdin.pause() |
|||
} |
|||
}) |
|||
process.stdin.on('mousepress', function (mouse) { |
|||
console.log(mouse) |
|||
}) |
|||
|
|||
keypress.enableMouse(process.stdout) |
|||
process.on('exit', function () { |
|||
//disable mouse on exit, so that the state is back to normal
|
|||
//for the terminal.
|
|||
keypress.disableMouse(process.stdout) |
|||
}) |
|||
|
|||
process.stdin.resume() |
|||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,37 @@ |
|||
{ |
|||
"name": "docco", |
|||
"description": "The Quick and Dirty Literate Programming Documentation Generator", |
|||
"keywords": [ |
|||
"documentation", |
|||
"docs", |
|||
"generator", |
|||
"coffeescript" |
|||
], |
|||
"author": { |
|||
"name": "Jeremy Ashkenas" |
|||
}, |
|||
"version": "0.4.0", |
|||
"licenses": [ |
|||
{ |
|||
"type": "MIT", |
|||
"url": "http://opensource.org/licenses/mit-license.php" |
|||
} |
|||
], |
|||
"engines": { |
|||
"node": ">=0.2.0" |
|||
}, |
|||
"directories": { |
|||
"lib": "./lib" |
|||
}, |
|||
"dependencies": { |
|||
"commander": ">=0.5.2" |
|||
}, |
|||
"main": "./lib/docco", |
|||
"bin": { |
|||
"docco": "./bin/docco" |
|||
}, |
|||
"readme": " ____ \n/\\ _`\\ \n\\ \\ \\/\\ \\ ___ ___ ___ ___ \n \\ \\ \\ \\ \\ / __`\\ /'___\\ /'___\\ / __`\\ \n \\ \\ \\_\\ \\ /\\ \\ \\ \\ /\\ \\__/ /\\ \\__/ /\\ \\ \\ \\\n \\ \\____/ \\ \\____/ \\ \\____\\ \\ \\____\\ \\ \\____/\n \\/___/ \\/___/ \\/____/ \\/____/ \\/___/ \n\n\nDocco is a quick-and-dirty, hundred-line-long, literate-programming-style\ndocumentation generator. For more information, see:\n\nhttp://jashkenas.github.com/docco/\n\n$ docco \n\n Usage: docco [options] <filePattern ...>\n\n Options:\n\n -h, --help output usage information\n -V, --version output the version number\n -c, --css [file] use a custom css file\n -o, --output [path] use a custom output path\n -t, --template [file] use a custom .jst template", |
|||
"readmeFilename": "README", |
|||
"_id": "docco@0.4.0", |
|||
"_from": "docco@~0.4.0" |
|||
} |
@ -0,0 +1,26 @@ |
|||
#### Default Template |
|||
|
|||
`docco.jst` and `docco.css` comprise the default Docco template, which |
|||
outputs ready-to-go HTML files for you to upload to you webserver. |
|||
|
|||
You can use the default template simply by invoking Docco |
|||
|
|||
docco src/*.coffee |
|||
|
|||
#### Pagelet Template |
|||
|
|||
`pagelet.jst` and `pagelet.css` output HTML that can be incorporated |
|||
into an existing DOM. |
|||
|
|||
If you are running from the docco directory |
|||
|
|||
docco src/*.coffee -t resources/pagelet.jst -c resources/pagelet.css |
|||
|
|||
...will generate a custom output of a CSS file that contains only the syntax |
|||
highlighting styles, and HTML files describing the sources. |
|||
|
|||
- Each page emits a `<ul class="sections">` element that contains all of the |
|||
sections of generated HTML, for both the docs and highlighted code. |
|||
- If there is more than one source input, a `<ul class="file_list">` will be |
|||
emitted, containing information about the source path and html page path for |
|||
each source. |
@ -0,0 +1,192 @@ |
|||
/*--------------------- Layout and Typography ----------------------------*/ |
|||
body { |
|||
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif; |
|||
font-size: 15px; |
|||
line-height: 22px; |
|||
color: #252519; |
|||
margin: 0; padding: 0; |
|||
} |
|||
a { |
|||
color: #261a3b; |
|||
} |
|||
a:visited { |
|||
color: #261a3b; |
|||
} |
|||
p { |
|||
margin: 0 0 15px 0; |
|||
} |
|||
h1, h2, h3, h4, h5, h6 { |
|||
margin: 0px 0 15px 0; |
|||
} |
|||
h1 { |
|||
margin-top: 40px; |
|||
} |
|||
hr { |
|||
border: 0 none; |
|||
border-top: 1px solid #e5e5ee; |
|||
height: 1px; |
|||
margin: 20px 0; |
|||
} |
|||
#container { |
|||
position: relative; |
|||
} |
|||
#background { |
|||
position: fixed; |
|||
top: 0; left: 525px; right: 0; bottom: 0; |
|||
background: #f5f5ff; |
|||
border-left: 1px solid #e5e5ee; |
|||
z-index: -1; |
|||
} |
|||
#jump_to, #jump_page { |
|||
background: white; |
|||
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; |
|||
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; |
|||
font: 10px Arial; |
|||
text-transform: uppercase; |
|||
cursor: pointer; |
|||
text-align: right; |
|||
} |
|||
#jump_to, #jump_wrapper { |
|||
position: fixed; |
|||
right: 0; top: 0; |
|||
padding: 5px 10px; |
|||
} |
|||
#jump_wrapper { |
|||
padding: 0; |
|||
display: none; |
|||
} |
|||
#jump_to:hover #jump_wrapper { |
|||
display: block; |
|||
} |
|||
#jump_page { |
|||
padding: 5px 0 3px; |
|||
margin: 0 0 25px 25px; |
|||
} |
|||
#jump_page .source { |
|||
display: block; |
|||
padding: 5px 10px; |
|||
text-decoration: none; |
|||
border-top: 1px solid #eee; |
|||
} |
|||
#jump_page .source:hover { |
|||
background: #f5f5ff; |
|||
} |
|||
#jump_page .source:first-child { |
|||
} |
|||
table td { |
|||
border: 0; |
|||
outline: 0; |
|||
} |
|||
td.docs, th.docs { |
|||
max-width: 450px; |
|||
min-width: 450px; |
|||
min-height: 5px; |
|||
padding: 10px 25px 1px 50px; |
|||
overflow-x: hidden; |
|||
vertical-align: top; |
|||
text-align: left; |
|||
} |
|||
.docs pre { |
|||
margin: 15px 0 15px; |
|||
padding-left: 15px; |
|||
} |
|||
.docs p tt, .docs p code { |
|||
background: #f8f8ff; |
|||
border: 1px solid #dedede; |
|||
font-size: 12px; |
|||
padding: 0 0.2em; |
|||
} |
|||
.pilwrap { |
|||
position: relative; |
|||
} |
|||
.pilcrow { |
|||
font: 12px Arial; |
|||
text-decoration: none; |
|||
color: #454545; |
|||
position: absolute; |
|||
top: 3px; left: -20px; |
|||
padding: 1px 2px; |
|||
opacity: 0; |
|||
-webkit-transition: opacity 0.2s linear; |
|||
} |
|||
td.docs:hover .pilcrow { |
|||
opacity: 1; |
|||
} |
|||
td.code, th.code { |
|||
padding: 14px 15px 16px 25px; |
|||
width: 100%; |
|||
vertical-align: top; |
|||
background: #f5f5ff; |
|||
border-left: 1px solid #e5e5ee; |
|||
} |
|||
pre, tt, code { |
|||
font-size: 12px; line-height: 18px; |
|||
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace; |
|||
margin: 0; padding: 0; |
|||
} |
|||
|
|||
|
|||
/*---------------------- Syntax Highlighting -----------------------------*/ |
|||
td.linenos { background-color: #f0f0f0; padding-right: 10px; } |
|||
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } |
|||
body .hll { background-color: #ffffcc } |
|||
body .c { color: #408080; font-style: italic } /* Comment */ |
|||
body .err { border: 1px solid #FF0000 } /* Error */ |
|||
body .k { color: #954121 } /* Keyword */ |
|||
body .o { color: #666666 } /* Operator */ |
|||
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */ |
|||
body .cp { color: #BC7A00 } /* Comment.Preproc */ |
|||
body .c1 { color: #408080; font-style: italic } /* Comment.Single */ |
|||
body .cs { color: #408080; font-style: italic } /* Comment.Special */ |
|||
body .gd { color: #A00000 } /* Generic.Deleted */ |
|||
body .ge { font-style: italic } /* Generic.Emph */ |
|||
body .gr { color: #FF0000 } /* Generic.Error */ |
|||
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */ |
|||
body .gi { color: #00A000 } /* Generic.Inserted */ |
|||
body .go { color: #808080 } /* Generic.Output */ |
|||
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ |
|||
body .gs { font-weight: bold } /* Generic.Strong */ |
|||
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ |
|||
body .gt { color: #0040D0 } /* Generic.Traceback */ |
|||
body .kc { color: #954121 } /* Keyword.Constant */ |
|||
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */ |
|||
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */ |
|||
body .kp { color: #954121 } /* Keyword.Pseudo */ |
|||
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */ |
|||
body .kt { color: #B00040 } /* Keyword.Type */ |
|||
body .m { color: #666666 } /* Literal.Number */ |
|||
body .s { color: #219161 } /* Literal.String */ |
|||
body .na { color: #7D9029 } /* Name.Attribute */ |
|||
body .nb { color: #954121 } /* Name.Builtin */ |
|||
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */ |
|||
body .no { color: #880000 } /* Name.Constant */ |
|||
body .nd { color: #AA22FF } /* Name.Decorator */ |
|||
body .ni { color: #999999; font-weight: bold } /* Name.Entity */ |
|||
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ |
|||
body .nf { color: #0000FF } /* Name.Function */ |
|||
body .nl { color: #A0A000 } /* Name.Label */ |
|||
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ |
|||
body .nt { color: #954121; font-weight: bold } /* Name.Tag */ |
|||
body .nv { color: #19469D } /* Name.Variable */ |
|||
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ |
|||
body .w { color: #bbbbbb } /* Text.Whitespace */ |
|||
body .mf { color: #666666 } /* Literal.Number.Float */ |
|||
body .mh { color: #666666 } /* Literal.Number.Hex */ |
|||
body .mi { color: #666666 } /* Literal.Number.Integer */ |
|||
body .mo { color: #666666 } /* Literal.Number.Oct */ |
|||
body .sb { color: #219161 } /* Literal.String.Backtick */ |
|||
body .sc { color: #219161 } /* Literal.String.Char */ |
|||
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */ |
|||
body .s2 { color: #219161 } /* Literal.String.Double */ |
|||
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ |
|||
body .sh { color: #219161 } /* Literal.String.Heredoc */ |
|||
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ |
|||
body .sx { color: #954121 } /* Literal.String.Other */ |
|||
body .sr { color: #BB6688 } /* Literal.String.Regex */ |
|||
body .s1 { color: #219161 } /* Literal.String.Single */ |
|||
body .ss { color: #19469D } /* Literal.String.Symbol */ |
|||
body .bp { color: #954121 } /* Name.Builtin.Pseudo */ |
|||
body .vc { color: #19469D } /* Name.Variable.Class */ |
|||
body .vg { color: #19469D } /* Name.Variable.Global */ |
|||
body .vi { color: #19469D } /* Name.Variable.Instance */ |
|||
body .il { color: #666666 } /* Literal.Number.Integer.Long */ |
@ -0,0 +1,58 @@ |
|||
<!DOCTYPE html> |
|||
|
|||
<html> |
|||
<head> |
|||
<title><%= title %></title> |
|||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
|||
<link rel="stylesheet" media="all" href="<%= css %>" /> |
|||
</head> |
|||
<body> |
|||
<div id="container"> |
|||
<div id="background"></div> |
|||
<% if (sources.length > 1) { %> |
|||
<div id="jump_to"> |
|||
Jump To … |
|||
<div id="jump_wrapper"> |
|||
<div id="jump_page"> |
|||
<% for (var i=0, l=sources.length; i<l; i++) { %> |
|||
<% var source = sources[i]; %> |
|||
<a class="source" href="<%= path.basename(destination(source)) %>"> |
|||
<%= path.basename(source) %> |
|||
</a> |
|||
<% } %> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<% } %> |
|||
<table cellpadding="0" cellspacing="0"> |
|||
<thead> |
|||
<tr> |
|||
<th class="docs"> |
|||
<h1> |
|||
<%= title %> |
|||
</h1> |
|||
</th> |
|||
<th class="code"> |
|||
</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<% for (var i=0, l=sections.length; i<l; i++) { %> |
|||
<% var section = sections[i]; %> |
|||
<tr id="section-<%= i + 1 %>"> |
|||
<td class="docs"> |
|||
<div class="pilwrap"> |
|||
<a class="pilcrow" href="#section-<%= i + 1 %>">¶</a> |
|||
</div> |
|||
<%= section.docsHtml %> |
|||
</td> |
|||
<td class="code"> |
|||
<%= section.codeHtml %> |
|||
</td> |
|||
</tr> |
|||
<% } %> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</body> |
|||
</html> |
@ -0,0 +1,31 @@ |
|||
{ ".coffee" : |
|||
{"name" : "coffee-script", "symbol" : "#"}, |
|||
".rb": |
|||
{"name" : "ruby", "symbol" : "#"}, |
|||
".py": |
|||
{"name": "python", "symbol" : "#"}, |
|||
".feature": |
|||
{"name" : "gherkin", "symbol" : "#"}, |
|||
".yaml": |
|||
{"name" : "yaml", "symbol" : "#"}, |
|||
".tex": |
|||
{"name" : "tex", "symbol" : "%"}, |
|||
".latex": |
|||
{"name" : "tex", "symbol" : "%"}, |
|||
".js": |
|||
{"name" : "javascript", "symbol" : "//"}, |
|||
".c": |
|||
{"name" : "c", "symbol" : "//"}, |
|||
".h": |
|||
{"name" : "c", "symbol" : "//"}, |
|||
".cpp": |
|||
{"name" : "cpp", "symbol" : "//"}, |
|||
".php": |
|||
{"name" : "php", "symbol" : "//"}, |
|||
".hs": |
|||
{"name" : "haskell", "symbol" : "--"}, |
|||
".erl": |
|||
{"name" : "erlang", "symbol" : "%"}, |
|||
".hrl": |
|||
{"name" : "erlang", "symbol" : "%"} |
|||
} |
@ -0,0 +1,64 @@ |
|||
/*---------------------- Syntax Highlighting -----------------------------*/ |
|||
td.linenos { background-color: #f0f0f0; padding-right: 10px; } |
|||
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } |
|||
body .hll { background-color: #ffffcc } |
|||
body .c { color: #408080; font-style: italic } /* Comment */ |
|||
body .err { border: 1px solid #FF0000 } /* Error */ |
|||
body .k { color: #954121 } /* Keyword */ |
|||
body .o { color: #666666 } /* Operator */ |
|||
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */ |
|||
body .cp { color: #BC7A00 } /* Comment.Preproc */ |
|||
body .c1 { color: #408080; font-style: italic } /* Comment.Single */ |
|||
body .cs { color: #408080; font-style: italic } /* Comment.Special */ |
|||
body .gd { color: #A00000 } /* Generic.Deleted */ |
|||
body .ge { font-style: italic } /* Generic.Emph */ |
|||
body .gr { color: #FF0000 } /* Generic.Error */ |
|||
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */ |
|||
body .gi { color: #00A000 } /* Generic.Inserted */ |
|||
body .go { color: #808080 } /* Generic.Output */ |
|||
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ |
|||
body .gs { font-weight: bold } /* Generic.Strong */ |
|||
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ |
|||
body .gt { color: #0040D0 } /* Generic.Traceback */ |
|||
body .kc { color: #954121 } /* Keyword.Constant */ |
|||
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */ |
|||
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */ |
|||
body .kp { color: #954121 } /* Keyword.Pseudo */ |
|||
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */ |
|||
body .kt { color: #B00040 } /* Keyword.Type */ |
|||
body .m { color: #666666 } /* Literal.Number */ |
|||
body .s { color: #219161 } /* Literal.String */ |
|||
body .na { color: #7D9029 } /* Name.Attribute */ |
|||
body .nb { color: #954121 } /* Name.Builtin */ |
|||
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */ |
|||
body .no { color: #880000 } /* Name.Constant */ |
|||
body .nd { color: #AA22FF } /* Name.Decorator */ |
|||
body .ni { color: #999999; font-weight: bold } /* Name.Entity */ |
|||
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ |
|||
body .nf { color: #0000FF } /* Name.Function */ |
|||
body .nl { color: #A0A000 } /* Name.Label */ |
|||
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ |
|||
body .nt { color: #954121; font-weight: bold } /* Name.Tag */ |
|||
body .nv { color: #19469D } /* Name.Variable */ |
|||
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ |
|||
body .w { color: #bbbbbb } /* Text.Whitespace */ |
|||
body .mf { color: #666666 } /* Literal.Number.Float */ |
|||
body .mh { color: #666666 } /* Literal.Number.Hex */ |
|||
body .mi { color: #666666 } /* Literal.Number.Integer */ |
|||
body .mo { color: #666666 } /* Literal.Number.Oct */ |
|||
body .sb { color: #219161 } /* Literal.String.Backtick */ |
|||
body .sc { color: #219161 } /* Literal.String.Char */ |
|||
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */ |
|||
body .s2 { color: #219161 } /* Literal.String.Double */ |
|||
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ |
|||
body .sh { color: #219161 } /* Literal.String.Heredoc */ |
|||
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ |
|||
body .sx { color: #954121 } /* Literal.String.Other */ |
|||
body .sr { color: #BB6688 } /* Literal.String.Regex */ |
|||
body .s1 { color: #219161 } /* Literal.String.Single */ |
|||
body .ss { color: #19469D } /* Literal.String.Symbol */ |
|||
body .bp { color: #954121 } /* Name.Builtin.Pseudo */ |
|||
body .vc { color: #19469D } /* Name.Variable.Class */ |
|||
body .vg { color: #19469D } /* Name.Variable.Global */ |
|||
body .vi { color: #19469D } /* Name.Variable.Instance */ |
|||
body .il { color: #666666 } /* Literal.Number.Integer.Long */ |
@ -0,0 +1,28 @@ |
|||
<!-- Generally you won't want to include the CSS file directly in a pagelet, but for this example it's fine.--> |
|||
<link rel="stylesheet" media="all" href="<%= css %>" /> |
|||
|
|||
<% if (sources.length > 1) { %> |
|||
<!-- Docco [file list] --> |
|||
<ul class="related"> |
|||
<% for (var i=0, l=sources.length; i<l; i++) { %> |
|||
<% var source = sources[i]; %> |
|||
<li> |
|||
<span class="name"><%= path.basename(source) %></span> |
|||
<span class="path"><%= path.basename(destination(source)) %></span> |
|||
</li> |
|||
<% } %> |
|||
</ul> |
|||
<% } %> |
|||
|
|||
<!-- Docco [section list] --> |
|||
<ul class="sections"> |
|||
<% for (var i=0, l=sections.length; i<l; i++) { %> |
|||
<% var section = sections[i]; %> |
|||
<li class="section-<%= i %>"> |
|||
<span class="docs"><%= section.docs_html %></span> |
|||
<span class="code"><%= section.code_html %></span> |
|||
</li> |
|||
<% } %> |
|||
</ul> |
|||
|
|||
|
@ -0,0 +1,312 @@ |
|||
# **Docco** is a quick-and-dirty, hundred-line-long, literate-programming-style |
|||
# documentation generator. It produces HTML |
|||
# that displays your comments alongside your code. Comments are passed through |
|||
# [Markdown](http://daringfireball.net/projects/markdown/syntax), and code is |
|||
# passed through [Pygments](http://pygments.org/) syntax highlighting. |
|||
# This page is the result of running Docco against its own source file. |
|||
# |
|||
# If you install Docco, you can run it from the command-line: |
|||
# |
|||
# docco src/*.coffee |
|||
# |
|||
# ...will generate an HTML documentation page for each of the named source files, |
|||
# with a menu linking to the other pages, saving it into a `docs` folder. |
|||
# |
|||
# The [source for Docco](http://github.com/jashkenas/docco) is available on GitHub, |
|||
# and released under the MIT license. |
|||
# |
|||
# To install Docco, first make sure you have [Node.js](http://nodejs.org/), |
|||
# [Pygments](http://pygments.org/) (install the latest dev version of Pygments |
|||
# from [its Mercurial repo](https://bitbucket.org/birkenfeld/pygments-main)), and |
|||
# [CoffeeScript](http://coffeescript.org/). Then, with NPM: |
|||
# |
|||
# sudo npm install -g docco |
|||
# |
|||
# Docco can be used to process CoffeeScript, JavaScript, Ruby, Python, or TeX files. |
|||
# Only single-line comments are processed -- block comments are ignored. |
|||
# |
|||
#### Partners in Crime: |
|||
# |
|||
# * If **Node.js** doesn't run on your platform, or you'd prefer a more |
|||
# convenient package, get [Ryan Tomayko](http://github.com/rtomayko)'s |
|||
# [Rocco](http://rtomayko.github.com/rocco/rocco.html), the Ruby port that's |
|||
# available as a gem. |
|||
# |
|||
# * If you're writing shell scripts, try |
|||
# [Shocco](http://rtomayko.github.com/shocco/), a port for the **POSIX shell**, |
|||
# also by Mr. Tomayko. |
|||
# |
|||
# * If Python's more your speed, take a look at |
|||
# [Nick Fitzgerald](http://github.com/fitzgen)'s [Pycco](http://fitzgen.github.com/pycco/). |
|||
# |
|||
# * For **Clojure** fans, [Fogus](http://blog.fogus.me/)'s |
|||
# [Marginalia](http://fogus.me/fun/marginalia/) is a bit of a departure from |
|||
# "quick-and-dirty", but it'll get the job done. |
|||
# |
|||
# * **Lua** enthusiasts can get their fix with |
|||
# [Robert Gieseke](https://github.com/rgieseke)'s [Locco](http://rgieseke.github.com/locco/). |
|||
# |
|||
# * And if you happen to be a **.NET** |
|||
# aficionado, check out [Don Wilson](https://github.com/dontangg)'s |
|||
# [Nocco](http://dontangg.github.com/nocco/). |
|||
|
|||
#### Main Documentation Generation Functions |
|||
|
|||
# Generate the documentation for a source file by reading it in, splitting it |
|||
# up into comment/code sections, highlighting them for the appropriate language, |
|||
# and merging them into an HTML template. |
|||
generateDocumentation = (source, config, callback) -> |
|||
fs.readFile source, (error, buffer) -> |
|||
throw error if error |
|||
code = buffer.toString() |
|||
sections = parse source, code |
|||
highlight source, sections, -> |
|||
generateHtml source, sections, config |
|||
callback() |
|||
|
|||
# Given a string of source code, parse out each comment and the code that |
|||
# follows it, and create an individual **section** for it. |
|||
# Sections take the form: |
|||
# |
|||
# { |
|||
# docsText: ... |
|||
# docsHtml: ... |
|||
# codeText: ... |
|||
# codeHtml: ... |
|||
# } |
|||
# |
|||
parse = (source, code) -> |
|||
lines = code.split '\n' |
|||
sections = [] |
|||
language = getLanguage source |
|||
hasCode = docsText = codeText = '' |
|||
|
|||
save = (docsText, codeText) -> |
|||
sections.push {docsText, codeText} |
|||
|
|||
for line in lines |
|||
if line.match(language.commentMatcher) and not line.match(language.commentFilter) |
|||
if hasCode |
|||
save docsText, codeText |
|||
hasCode = docsText = codeText = '' |
|||
docsText += line.replace(language.commentMatcher, '') + '\n' |
|||
else |
|||
hasCode = yes |
|||
codeText += line + '\n' |
|||
save docsText, codeText |
|||
sections |
|||
|
|||
# Highlights a single chunk of CoffeeScript code, using **Pygments** over stdio, |
|||
# and runs the text of its corresponding comment through **Markdown**, using |
|||
# [Showdown.js](http://attacklab.net/showdown/). |
|||
# |
|||
# We process the entire file in a single call to Pygments by inserting little |
|||
# marker comments between each section and then splitting the result string |
|||
# wherever our markers occur. |
|||
highlight = (source, sections, callback) -> |
|||
language = getLanguage source |
|||
pygments = spawn 'pygmentize', [ |
|||
'-l', language.name, |
|||
'-f', 'html', |
|||
'-O', 'encoding=utf-8,tabsize=2' |
|||
] |
|||
output = '' |
|||
|
|||
pygments.stderr.on 'data', (error) -> |
|||
console.error error.toString() if error |
|||
|
|||
pygments.stdin.on 'error', (error) -> |
|||
console.error 'Could not use Pygments to highlight the source.' |
|||
process.exit 1 |
|||
|
|||
pygments.stdout.on 'data', (result) -> |
|||
output += result if result |
|||
|
|||
pygments.on 'exit', -> |
|||
output = output.replace(highlightStart, '').replace(highlightEnd, '') |
|||
fragments = output.split language.dividerHtml |
|||
for section, i in sections |
|||
section.codeHtml = highlightStart + fragments[i] + highlightEnd |
|||
section.docsHtml = showdown.makeHtml section.docsText |
|||
callback() |
|||
|
|||
if pygments.stdin.writable |
|||
text = (section.codeText for section in sections) |
|||
pygments.stdin.write text.join language.dividerText |
|||
pygments.stdin.end() |
|||
|
|||
# Once all of the code is finished highlighting, we can generate the HTML file by |
|||
# passing the completed sections into the template, and then writing the file to |
|||
# the specified output path. |
|||
generateHtml = (source, sections, config) -> |
|||
destination = (filepath) -> |
|||
path.join(config.output, path.basename(filepath, path.extname(filepath)) + '.html') |
|||
title = path.basename source |
|||
dest = destination source |
|||
html = config.doccoTemplate { |
|||
title : title, |
|||
sections : sections, |
|||
sources : config.sources, |
|||
path : path, |
|||
destination: destination |
|||
css : path.basename(config.css) |
|||
} |
|||
console.log "docco: #{source} -> #{dest}" |
|||
fs.writeFileSync dest, html |
|||
|
|||
#### Helpers & Setup |
|||
|
|||
# Require our external dependencies, including **Showdown.js** |
|||
# (the JavaScript implementation of Markdown). |
|||
fs = require 'fs' |
|||
path = require 'path' |
|||
showdown = require('./../vendor/showdown').Showdown |
|||
{spawn, exec} = require 'child_process' |
|||
commander = require 'commander' |
|||
|
|||
# Read resource file and return its content. |
|||
getResource = (name) -> |
|||
fullPath = path.join __dirname, '..', 'resources', name |
|||
fs.readFileSync(fullPath).toString() |
|||
|
|||
# Languages are stored in JSON format in the file `resources/languages.json` |
|||
# Each item maps the file extension to the name of the Pygments lexer and the |
|||
# symbol that indicates a comment. To add a new language, modify the file. |
|||
languages = JSON.parse getResource 'languages.json' |
|||
|
|||
# Build out the appropriate matchers and delimiters for each language. |
|||
for ext, l of languages |
|||
|
|||
# Does the line begin with a comment? |
|||
l.commentMatcher = ///^\s*#{l.symbol}\s?/// |
|||
|
|||
# Ignore [hashbangs](http://en.wikipedia.org/wiki/Shebang_(Unix\)) |
|||
# and interpolations... |
|||
l.commentFilter = /(^#![/]|^\s*#\{)/ |
|||
|
|||
# The dividing token we feed into Pygments, to delimit the boundaries between |
|||
# sections. |
|||
l.dividerText = "\n#{l.symbol}DIVIDER\n" |
|||
|
|||
# The mirror of `dividerText` that we expect Pygments to return. We can split |
|||
# on this to recover the original sections. |
|||
# Note: the class is "c" for Python and "c1" for the other languages |
|||
l.dividerHtml = ///\n*<span\sclass="c1?">#{l.symbol}DIVIDER<\/span>\n*/// |
|||
|
|||
# Get the current language we're documenting, based on the extension. |
|||
getLanguage = (source) -> languages[path.extname(source)] |
|||
|
|||
# Ensure that the destination directory exists. |
|||
ensureDirectory = (dir, callback) -> |
|||
exec "mkdir -p #{dir}", -> callback() |
|||
|
|||
# Micro-templating, originally by John Resig, borrowed by way of |
|||
# [Underscore.js](http://documentcloud.github.com/underscore/). |
|||
template = (str) -> |
|||
new Function 'obj', |
|||
'var p=[],print=function(){p.push.apply(p,arguments);};' + |
|||
'with(obj){p.push(\'' + |
|||
str.replace(/[\r\t\n]/g, " ") |
|||
.replace(/'(?=[^<]*%>)/g,"\t") |
|||
.split("'").join("\\'") |
|||
.split("\t").join("'") |
|||
.replace(/<%=(.+?)%>/g, "',$1,'") |
|||
.split('<%').join("');") |
|||
.split('%>').join("p.push('") + |
|||
"');}return p.join('');" |
|||
|
|||
# The start of each Pygments highlight block. |
|||
highlightStart = '<div class="highlight"><pre>' |
|||
|
|||
# The end of each Pygments highlight block. |
|||
highlightEnd = '</pre></div>' |
|||
|
|||
# Extract the docco version from `package.json` |
|||
version = JSON.parse(fs.readFileSync("#{__dirname}/../package.json")).version |
|||
|
|||
# Default configuration options. |
|||
defaults = |
|||
template: "#{__dirname}/../resources/docco.jst" |
|||
css : "#{__dirname}/../resources/docco.css" |
|||
output : "docs/" |
|||
|
|||
|
|||
# ### Run from Commandline |
|||
|
|||
# Run Docco from a set of command line arguments. |
|||
# |
|||
# 1. Parse command line using [Commander JS](https://github.com/visionmedia/commander.js). |
|||
# 2. Document sources, or print the usage help if none are specified. |
|||
run = (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 |
|||
document(commander.args.slice(),commander) |
|||
else |
|||
console.log commander.helpInformation() |
|||
|
|||
# ### Document Sources |
|||
|
|||
# Run Docco over a list of `sources` with the given `options`. |
|||
# |
|||
# 1. Construct config to use by taking `defaults` first, then merging in `options` |
|||
# 2. Generate the resolved source list, filtering out unknown types. |
|||
# 3. Load the specified template and css files. |
|||
# 4. Ensure the output path is created, write out the CSS file, |
|||
# document each source, and invoke the completion callback if it is specified. |
|||
document = (sources, options = {}, callback = null) -> |
|||
config = {} |
|||
config[key] = defaults[key] for key,value of defaults |
|||
config[key] = value for key,value of options if key of defaults |
|||
|
|||
resolved = [] |
|||
resolved = resolved.concat(resolveSource(src)) for src in sources |
|||
config.sources = resolved.filter((source) -> getLanguage source).sort() |
|||
console.log "docco: skipped unknown type (#{m})" for m in resolved when m not in config.sources |
|||
|
|||
config.doccoTemplate = template fs.readFileSync(config.template).toString() |
|||
doccoStyles = fs.readFileSync(config.css).toString() |
|||
|
|||
ensureDirectory config.output, -> |
|||
fs.writeFileSync path.join(config.output,path.basename(config.css)), doccoStyles |
|||
files = config.sources.slice() |
|||
nextFile = -> |
|||
callback() if callback? and not files.length |
|||
generateDocumentation files.shift(), config, nextFile if files.length |
|||
nextFile() |
|||
|
|||
# ### Resolve Wildcard Source Inputs |
|||
|
|||
# Resolve a wildcard `source` input to the files it matches. |
|||
# |
|||
# 1. If the input contains no wildcard characters, just return it. |
|||
# 2. Convert the wildcard match to a regular expression, and return |
|||
# an array of files in the path that match it. |
|||
resolveSource = (source) -> |
|||
return source if not source.match(/([\*\?])/) |
|||
regex_str = path.basename(source) |
|||
.replace(/\./g, "\\$&") |
|||
.replace(/\*/,".*") |
|||
.replace(/\?/,".") |
|||
regex = new RegExp('^(' + regex_str + ')$') |
|||
file_path = path.dirname(source) |
|||
files = fs.readdirSync file_path |
|||
return (path.join(file_path,file) for file in files when file.match regex) |
|||
|
|||
# ### Exports |
|||
|
|||
# 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 |
|||
} |
@ -0,0 +1,13 @@ |
|||
## Docco Comment Parser Test Data |
|||
|
|||
This directory contains test data files to verify that single-line |
|||
comments are parsed as expected. Each source file contains code |
|||
and comments in the language it is testing, with the first comment |
|||
being an integer value that is the number of expected comments in the file. |
|||
|
|||
### Results as a custom CSV template |
|||
|
|||
The file `comments.jst` in this directory is used when running docco over |
|||
the example source files, and it breaks the doc blocks into a CSV list |
|||
of doc texts. This CSV list is loaded by the comments parser test, and |
|||
used to validate the expected output. |
@ -0,0 +1,8 @@ |
|||
// 1
|
|||
#include <stdio.h> |
|||
int main() |
|||
{ |
|||
const char *world = "World!"; |
|||
printf("Hello %s\n",world); |
|||
return 0; |
|||
} |
@ -0,0 +1,11 @@ |
|||
//
|
|||
// 1
|
|||
//
|
|||
#ifndef _C_HEADER_ |
|||
#define _C_HEADER_ |
|||
typedef struct MyDescriptor |
|||
{ |
|||
int size; |
|||
const char*data; |
|||
} MyDescriptor; |
|||
#endif |
@ -0,0 +1,18 @@ |
|||
# 3 |
|||
world = "World!" |
|||
|
|||
console.log "Hello #{world}" |
|||
|
|||
### |
|||
This file will report 3 comments when parsed because the |
|||
single line comment parser will match the '#' at the beginning |
|||
and end of the block comment. |
|||
|
|||
As a result, all of this text will be considered code. It's |
|||
not a good situation, but that's how `docco` works. |
|||
### |
|||
|
|||
|
|||
console.log "// Comment" |
|||
|
|||
console.log "### Comment ###" |
@ -0,0 +1,11 @@ |
|||
<% |
|||
var comments = []; |
|||
for (var i=0, l=sections.length; i<l; i++) { |
|||
var section = sections[i]; |
|||
comments.push(section.docsText.replace(/[\n|,]/g,'').trim()); |
|||
} |
|||
var output = comments.join(','); |
|||
if(comments.length==1) |
|||
output += ','; |
|||
%> |
|||
<%= output %> |
@ -0,0 +1,8 @@ |
|||
// 1
|
|||
var world = "World!"; |
|||
/* |
|||
|
|||
Comment |
|||
|
|||
*/ |
|||
console.log("Hello " + world); |
@ -0,0 +1,11 @@ |
|||
# 1 |
|||
|
|||
|
|||
def main(): |
|||
""" |
|||
|
|||
Comment |
|||
|
|||
""" |
|||
world = 'World!' |
|||
print 'Hello %s' % world |
@ -0,0 +1,8 @@ |
|||
# 1 |
|||
world = "World!" |
|||
=begin |
|||
|
|||
Comment |
|||
|
|||
=end |
|||
puts 'Hello %s' % world |
@ -0,0 +1,13 @@ |
|||
\documentclass[12pt]{article} |
|||
\usepackage{verbatim} |
|||
% 1 |
|||
\title{Hello World!} |
|||
\date{} |
|||
\begin{document} |
|||
\maketitle |
|||
\begin{comment} |
|||
|
|||
Comment |
|||
|
|||
\end{comment} |
|||
\end{document} |
@ -0,0 +1,86 @@ |
|||
|
|||
{spawn, exec} = require 'child_process' |
|||
path = require 'path' |
|||
fs = require 'fs' |
|||
|
|||
# Determine the test and resources paths |
|||
testPath = path.dirname fs.realpathSync(__filename) |
|||
dataPath = path.join testPath, "data" |
|||
resourcesPath = path.normalize path.join(testPath,"/../resources") |
|||
|
|||
# Run a Docco pass and check that the number of output files |
|||
# is equal to what is expected. |
|||
testDoccoRun = (testName,sources,options=null,callback=null) -> |
|||
destPath = path.join dataPath, testName |
|||
cleanup = (callback) -> exec "rm -rf #{destPath}", callback |
|||
cleanup -> |
|||
options?.output = destPath |
|||
Docco.document sources, options, -> |
|||
files = [] |
|||
files = files.concat(Docco.resolveSource(src)) for src in sources |
|||
expected = files.length + 1 |
|||
found = fs.readdirSync(destPath).length |
|||
eq found, expected, "find expected output (#{expected} files) - (#{found})" |
|||
callback() if callback? |
|||
|
|||
# **Custom jst template files should be supported** |
|||
test "custom JST template file", -> |
|||
testDoccoRun "custom_jst", |
|||
["#{testPath}/*.coffee"], |
|||
template: "#{resourcesPath}/pagelet.jst" |
|||
|
|||
# **Custom CSS files should be supported** |
|||
test "custom CSS file", -> |
|||
testDoccoRun "custom_css", |
|||
["#{testPath}/*.coffee"], |
|||
css: "#{resourcesPath}/pagelet.css" |
|||
|
|||
# **Comments should be parsed properly** |
|||
# |
|||
# There are special data files located in `test/comments` for each supported |
|||
# language. The first comment in each file corresponds to the expected number |
|||
# of comments to be parsed from its contents. |
|||
# |
|||
# This test iterates over all the known Docco languages, and tests the ones |
|||
# that have a corresponding data file in `test/comments`. |
|||
test "single line comment parsing", -> |
|||
commentsPath = path.join testPath, "comments" |
|||
options = template: "#{commentsPath}/comments.jst" |
|||
languageKeys = (ext for ext,l of Docco.languages) |
|||
|
|||
testNextLanguage = (keys,callback) -> |
|||
return callback?() if not keys.length |
|||
|
|||
extension = keys.shift() |
|||
language = Docco.languages[extension] |
|||
languageExample = path.join commentsPath, "#{language.name}#{extension}" |
|||
languageTest = "comments_test/#{language.name}" |
|||
languagePath = path.join dataPath, languageTest |
|||
languageOutput = path.join languagePath, "#{language.name}.html" |
|||
|
|||
# *Skip over this language if there is no corresponding test* |
|||
return testNextLanguage(keys, callback) if not path.existsSync languageExample |
|||
|
|||
testDoccoRun languageTest, [languageExample], options, -> |
|||
eq true, path.existsSync(languageOutput), "#{languageOutput} -> output file created properly" |
|||
|
|||
content = fs.readFileSync(languageOutput).toString() |
|||
comments = (c.trim() for c in content.split(',') when c.trim() != '') |
|||
|
|||
eq true, comments.length >= 1, 'expect at least the descriptor comment' |
|||
|
|||
expected = parseInt(comments[0]) |
|||
|
|||
eq comments.length, expected, [ |
|||
"" |
|||
"#{path.basename(languageOutput)} comments" |
|||
"------------------------" |
|||
" expected : #{expected}" |
|||
" found : #{comments.length}" |
|||
].join '\n' |
|||
|
|||
testNextLanguage keys, callback |
|||
|
|||
# *Kick off the first language test* |
|||
testNextLanguage languageKeys.slice() |
|||
|
File diff suppressed because it is too large
@ -0,0 +1,3 @@ |
|||
pygments-server.js |
|||
pygments-test.js |
|||
Rakefile |
@ -0,0 +1,20 @@ |
|||
Copyright (c) Pavan Kumar Sunkara |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining |
|||
a copy of this software and associated documentation files (the |
|||
"Software"), to deal in the Software without restriction, including |
|||
without limitation the rights to use, copy, modify, merge, publish, |
|||
distribute, sublicense, and/or sell copies of the Software, and to |
|||
permit persons to whom the Software is furnished to do so, subject to |
|||
the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be |
|||
included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
|||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
|||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,73 @@ |
|||
# Pygments |
|||
|
|||
A pygments wrapper for node.js |
|||
|
|||
## Installation |
|||
|
|||
### Installing npm (node package manager) |
|||
``` |
|||
curl http://npmjs.org/install.sh | sh |
|||
``` |
|||
|
|||
### Installing pygments |
|||
``` |
|||
[sudo] npm install pygments |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
### colorize(target, lexer, format, callback, [options]); |
|||
|
|||
* Default lexer is `js` |
|||
* Default format is `html` |
|||
|
|||
#### Highlight code |
|||
|
|||
```javascript |
|||
var highlight = require('pygments').colorize; |
|||
|
|||
highlight('puts "Hello World"', 'ruby', 'console', function(data) { |
|||
console.log(data); |
|||
}); |
|||
``` |
|||
|
|||
#### Highlight a file |
|||
|
|||
```javascript |
|||
var highlight = require('pygments').colorize; |
|||
|
|||
highlight('/home/pkumar/package.json', null, 'html', function(data) { |
|||
console.log(data); |
|||
}); |
|||
``` |
|||
|
|||
If you want to highlight string `/home/pkumar/package.json` itself, |
|||
|
|||
```javascript |
|||
var highlight = require('pygments').colorize; |
|||
|
|||
highlight('/home/pkumar/package.json', null, 'html', function(data) { |
|||
console.log(data); |
|||
}, {'force': true}); |
|||
``` |
|||
|
|||
## Run Tests |
|||
|
|||
All of the pygments tests are written in [vows][4], and cover all of the use cases described above. |
|||
|
|||
``` |
|||
npm test |
|||
``` |
|||
|
|||
## License |
|||
|
|||
See LICENSE for details. |
|||
|
|||
## Contact |
|||
|
|||
Pavan Kumar Sunkara |
|||
|
|||
[pavan [dot] sss1991 [at] gmail [dot] com][email] |
|||
|
|||
[email]: mailto:pavan.sss1991@gmail.com |
|||
[4]: http://vowsjs.org |
@ -0,0 +1,3 @@ |
|||
test/ |
|||
Rakefile |
|||
docs/ |
@ -0,0 +1,22 @@ |
|||
Copyright (c) 2009-2012 Jeremy Ashkenas, DocumentCloud |
|||
|
|||
Permission is hereby granted, free of charge, to any person |
|||
obtaining a copy of this software and associated documentation |
|||
files (the "Software"), to deal in the Software without |
|||
restriction, including without limitation the rights to use, |
|||
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the |
|||
Software is furnished to do so, subject to the following |
|||
conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be |
|||
included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|||
OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,19 @@ |
|||
__ |
|||
/\ \ __ |
|||
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____ |
|||
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\ |
|||
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\ |
|||
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/ |
|||
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/ |
|||
\ \____/ |
|||
\/___/ |
|||
|
|||
Underscore.js is a utility-belt library for JavaScript that provides |
|||
support for the usual functional suspects (each, map, reduce, filter...) |
|||
without extending any core JavaScript objects. |
|||
|
|||
For Docs, License, Tests, and pre-packed downloads, see: |
|||
http://documentcloud.github.com/underscore/ |
|||
|
|||
Many thanks to our contributors: |
|||
https://github.com/documentcloud/underscore/contributors |
@ -0,0 +1 @@ |
|||
52c9671222c6c6e86b8e7f5320a63f8e62995136 |
@ -0,0 +1 @@ |
|||
module.exports = require('./underscore'); |
@ -0,0 +1,29 @@ |
|||
{ |
|||
"name": "underscore", |
|||
"description": "JavaScript's functional programming helper library.", |
|||
"homepage": "http://documentcloud.github.com/underscore/", |
|||
"keywords": [ |
|||
"util", |
|||
"functional", |
|||
"server", |
|||
"client", |
|||
"browser" |
|||
], |
|||
"author": { |
|||
"name": "Jeremy Ashkenas", |
|||
"email": "jeremy@documentcloud.org" |
|||
}, |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/documentcloud/underscore.git" |
|||
}, |
|||
"main": "underscore.js", |
|||
"version": "1.3.1", |
|||
"readme": " __ \n /\\ \\ __ \n __ __ ___ \\_\\ \\ __ _ __ ____ ___ ___ _ __ __ /\\_\\ ____ \n /\\ \\/\\ \\ /' _ `\\ /'_ \\ /'__`\\/\\ __\\/ ,__\\ / ___\\ / __`\\/\\ __\\/'__`\\ \\/\\ \\ /',__\\ \n \\ \\ \\_\\ \\/\\ \\/\\ \\/\\ \\ \\ \\/\\ __/\\ \\ \\//\\__, `\\/\\ \\__//\\ \\ \\ \\ \\ \\//\\ __/ __ \\ \\ \\/\\__, `\\\n \\ \\____/\\ \\_\\ \\_\\ \\___,_\\ \\____\\\\ \\_\\\\/\\____/\\ \\____\\ \\____/\\ \\_\\\\ \\____\\/\\_\\ _\\ \\ \\/\\____/\n \\/___/ \\/_/\\/_/\\/__,_ /\\/____/ \\/_/ \\/___/ \\/____/\\/___/ \\/_/ \\/____/\\/_//\\ \\_\\ \\/___/ \n \\ \\____/ \n \\/___/\n \nUnderscore.js is a utility-belt library for JavaScript that provides \nsupport for the usual functional suspects (each, map, reduce, filter...) \nwithout extending any core JavaScript objects.\n\nFor Docs, License, Tests, and pre-packed downloads, see:\nhttp://documentcloud.github.com/underscore/\n\nMany thanks to our contributors:\nhttps://github.com/documentcloud/underscore/contributors\n", |
|||
"readmeFilename": "README.md", |
|||
"bugs": { |
|||
"url": "https://github.com/documentcloud/underscore/issues" |
|||
}, |
|||
"_id": "underscore@1.3.1", |
|||
"_from": "underscore@1.3.1" |
|||
} |
@ -0,0 +1 @@ |
|||
73ad2d7c8eebce69b4f46f31c0a1a8c2d523bc0d |
@ -0,0 +1,31 @@ |
|||
// Underscore.js 1.3.1
|
|||
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
|||
// Underscore is freely distributable under the MIT license.
|
|||
// Portions of Underscore are inspired or borrowed from Prototype,
|
|||
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
|||
// For all details and documentation:
|
|||
// http://documentcloud.github.com/underscore
|
|||
(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== |
|||
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, |
|||
h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= |
|||
b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a== |
|||
null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= |
|||
function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= |
|||
e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= |
|||
function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})}); |
|||
return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, |
|||
c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest= |
|||
b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]); |
|||
return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c, |
|||
d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g}; |
|||
var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a, |
|||
c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true: |
|||
a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}}; |
|||
b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, |
|||
1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; |
|||
b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; |
|||
b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), |
|||
function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ |
|||
u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= |
|||
function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= |
|||
true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); |
@ -0,0 +1 @@ |
|||
208d4cd890c3183d946092ebe982738ade565061 |
@ -0,0 +1,53 @@ |
|||
{ |
|||
"name": "pygments", |
|||
"version": "0.1.3", |
|||
"author": { |
|||
"name": "Pavan Kumar Sunkara", |
|||
"email": "pavan.sss1991@gmail.com", |
|||
"url": "pksunkara.github.com" |
|||
}, |
|||
"description": "A pygments wrapper for nodejs", |
|||
"main": "pygments", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/pksunkara/pygments.js.git" |
|||
}, |
|||
"keywords": [ |
|||
"pygments", |
|||
"wrapper", |
|||
"syntax", |
|||
"highlighting" |
|||
], |
|||
"homepage": "http://pksunkara.github.com/pygments.js", |
|||
"scripts": { |
|||
"test": "vows pygments-test.js --spec" |
|||
}, |
|||
"contributors": [ |
|||
{ |
|||
"name": "Pavan Kumar Sunkara", |
|||
"email": "pavan.sss1991@gmail.com" |
|||
} |
|||
], |
|||
"dependencies": { |
|||
"underscore": "1.3.1" |
|||
}, |
|||
"devDependencies": { |
|||
"vows": "0.6.x" |
|||
}, |
|||
"engines": { |
|||
"node": ">=0.4" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/pksunkara/pygments.js/issues" |
|||
}, |
|||
"licenses": [ |
|||
{ |
|||
"type": "MIT", |
|||
"url": "https://github.com/pksunkara/pygments.js/raw/master/LICENSE" |
|||
} |
|||
], |
|||
"readme": "# Pygments\n\nA pygments wrapper for node.js\n\n## Installation\n\n### Installing npm (node package manager)\n```\n curl http://npmjs.org/install.sh | sh\n```\n\n### Installing pygments\n```\n [sudo] npm install pygments\n```\n\n## Usage\n\n### colorize(target, lexer, format, callback, [options]);\n\n* Default lexer is `js`\n* Default format is `html`\n\n#### Highlight code\n\n```javascript\nvar highlight = require('pygments').colorize;\n\nhighlight('puts \"Hello World\"', 'ruby', 'console', function(data) {\n console.log(data);\n});\n```\n\n#### Highlight a file\n\n```javascript\nvar highlight = require('pygments').colorize;\n\nhighlight('/home/pkumar/package.json', null, 'html', function(data) {\n console.log(data);\n});\n```\n\nIf you want to highlight string `/home/pkumar/package.json` itself,\n\n```javascript\nvar highlight = require('pygments').colorize;\n\nhighlight('/home/pkumar/package.json', null, 'html', function(data) {\n console.log(data);\n}, {'force': true});\n```\n\n## Run Tests\n\nAll of the pygments tests are written in [vows][4], and cover all of the use cases described above.\n\n```\n npm test\n```\n\n## License\n\nSee LICENSE for details.\n\n## Contact\n\nPavan Kumar Sunkara\n\n[pavan [dot] sss1991 [at] gmail [dot] com][email]\n\n[email]: mailto:pavan.sss1991@gmail.com\n[4]: http://vowsjs.org\n", |
|||
"readmeFilename": "README.md", |
|||
"_id": "pygments@0.1.3", |
|||
"_from": "pygments@~0.1.3" |
|||
} |
@ -0,0 +1,125 @@ |
|||
/* |
|||
* pygments.js: A node.js wrapper for pygments |
|||
* |
|||
* (C) 2011, Pavan Kumar Sunkara |
|||
* |
|||
*/ |
|||
'use strict'; |
|||
var spawn = require('child_process').spawn, |
|||
exists = require('path').existsSync, |
|||
fs = require('fs'); |
|||
|
|||
var _ = require('underscore'); |
|||
|
|||
var pygments = {}; |
|||
|
|||
//
|
|||
// Default timeout threshold for pygments
|
|||
//
|
|||
pygments.timeout = 10; |
|||
|
|||
//
|
|||
// Default binary path for pygmentize
|
|||
//
|
|||
pygments.bin = 'pygmentize'; |
|||
|
|||
//
|
|||
// ### function colorize
|
|||
// #### @target {String} Target to be highlighted
|
|||
// #### @lexer {String} Lexer to use for highlighting
|
|||
// #### @format {String} Format for the output
|
|||
// #### @options {Object} Other options
|
|||
//
|
|||
pygments.colorize = function(target, lexer, format, callback, options) { |
|||
options = options || {}; |
|||
if(lexer) options['l'] = lexer; |
|||
if(format) options['f'] = format; |
|||
options = this.merge_options(options); |
|||
target = this.stringize(target, (options['force'])); |
|||
delete options['force']; |
|||
|
|||
this.execute(target, options, callback); |
|||
}; |
|||
|
|||
//
|
|||
// ### function execute
|
|||
// #### @target {String} Target to be highlighted
|
|||
// #### @options {Object} Options
|
|||
//
|
|||
pygments.execute = function(target, options, callback) { |
|||
var pyg = spawn(this.bin, this.convert_options(options)); |
|||
var chunks = []; |
|||
pyg.stdout.on('data', function(chunk) { |
|||
chunks.push(chunk); |
|||
}); |
|||
pyg.stderr.on('data', function (data) { |
|||
console.log(data.toString()); |
|||
}); |
|||
pyg.on('exit', function() { |
|||
var length = 0; |
|||
chunks.forEach(function(chunk) { |
|||
length += chunk.length; |
|||
}); |
|||
var content = new Buffer(length); |
|||
var index = 0; |
|||
chunks.forEach(function(chunk) { |
|||
chunk.copy(content, index, 0, chunk.length); |
|||
index += chunk.length; |
|||
}); |
|||
callback(content.toString()); |
|||
}); |
|||
pyg.stdin.write(target); |
|||
pyg.stdin.end(); |
|||
}; |
|||
|
|||
//
|
|||
// ### function convert_options
|
|||
// #### @options {Object} Options to be converted
|
|||
//
|
|||
pygments.convert_options = function(options) { |
|||
var cmd = []; |
|||
for(var option in options) { |
|||
validate_args(option, options[option]); |
|||
cmd.push("-"+option + options[option]); |
|||
} |
|||
return cmd; |
|||
}; |
|||
|
|||
//
|
|||
// ### function merge_options
|
|||
// #### @opts {Object} Options to be merged
|
|||
//
|
|||
pygments.merge_options = function(options) { |
|||
var default_options = { |
|||
'force': false, |
|||
'l': 'js', |
|||
'f': 'html', |
|||
'O': 'encoding=utf-8' |
|||
}; |
|||
return _.defaults(options, default_options); |
|||
}; |
|||
|
|||
//
|
|||
// ### function stringize
|
|||
// #### @target {String} Target to be highlighted
|
|||
// #### @force {Boolean} Force the target to be string
|
|||
//
|
|||
pygments.stringize = function(target, force) { |
|||
force = (force===undefined ? false : force); |
|||
if(exists(target) && !force) { |
|||
var target_stats = fs.statSync(target); |
|||
if(target_stats.isFile()) { |
|||
var target_fd = fs.openSync(target, 'r'); |
|||
target = fs.readSync(target_fd, target_stats['size'], null)[0]; |
|||
fs.closeSync(target_fd); |
|||
} |
|||
} |
|||
return target; |
|||
}; |
|||
|
|||
var validate_args = function(flag, value) { |
|||
if(!flag.match(/^[a-z]+$/i)) throw new Error("Flag is invalid: " + flag); |
|||
if(!value.match(/^[a-z0-9\-\_\+\=\#\,\s]+$/i)) throw new Error("Flag value is invalid: -"+flag+" "+value); |
|||
}; |
|||
|
|||
module.exports = pygments; |
@ -0,0 +1,47 @@ |
|||
{ |
|||
"name": "grunt-docco", |
|||
"description": "Grunt Docco plugin.", |
|||
"version": "0.2.0", |
|||
"homepage": "https://github.com/DavidSouther/grunt-docco", |
|||
"author": { |
|||
"name": "David Souther", |
|||
"email": "davidsouther@gmail.com", |
|||
"url": "http://www.davidsouther.com" |
|||
}, |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/DavidSouther/grunt-docco.git" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/DavidSouther/grunt-docco/issues" |
|||
}, |
|||
"licenses": [ |
|||
{ |
|||
"type": "MIT", |
|||
"url": "https://github.com/DavidSouther/grunt-docco/blob/master/LICENSE-MIT" |
|||
} |
|||
], |
|||
"engines": { |
|||
"node": "*" |
|||
}, |
|||
"scripts": { |
|||
"test": "grunt test" |
|||
}, |
|||
"dependencies": { |
|||
"grunt": "~0.4.0", |
|||
"docco": "~0.4.0", |
|||
"pygments": "~0.1.3" |
|||
}, |
|||
"devDependencies": { |
|||
"rimraf": "~2.0.2", |
|||
"grunt-contrib-nodeunit": "~0.1.2", |
|||
"grunt-contrib-clean": "~0.4.0" |
|||
}, |
|||
"keywords": [ |
|||
"gruntplugin" |
|||
], |
|||
"readme": "# grunt-docco\n\nGrunt Docco plugin.\n\n## Getting Started\nInstall this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-docco`\n\nThen add this line to your project's `grunt.js` gruntfile:\n\n```javascript\ngrunt.loadNpmTasks('grunt-docco');\n```\n\n[grunt]: https://github.com/cowboy/grunt\n[getting_started]: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md\n\n## Documentation\n```\ndocco: {\n debug: {\n src: ['test/**/*.js'],\n options: {\n output: 'docs/'\n }\n }\n}\n\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt][grunt].\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2012 David Souther \nLicensed under the MIT license.\n", |
|||
"readmeFilename": "README.md", |
|||
"_id": "grunt-docco@0.2.0", |
|||
"_from": "grunt-docco@" |
|||
} |
@ -0,0 +1,23 @@ |
|||
// grunt-docco
|
|||
// https://github.com/DavidSouther/grunt-docco
|
|||
//
|
|||
// Copyright (c) 2012 David Souther
|
|||
// Licensed under the MIT license.
|
|||
|
|||
"use strict"; |
|||
var docco = require('docco'); |
|||
|
|||
module.exports = function(grunt) { |
|||
grunt.registerMultiTask('docco', 'Docco processor.', function() { |
|||
var task = this, |
|||
fdone = 0, |
|||
flength = this.files.length, |
|||
done = this.async(); |
|||
|
|||
this.files.forEach(function(file) { |
|||
docco.document(file.src, task.options({ output: file.dest }), function(){ |
|||
if(++fdone === flength) done(); |
|||
}); |
|||
}); |
|||
}); |
|||
}; |
@ -0,0 +1,32 @@ |
|||
"use strict"; |
|||
var grunt = require('grunt'); |
|||
var rr = require("rimraf"); |
|||
|
|||
exports.docco = { |
|||
tearDown: function (callback) { |
|||
rr('docs', function(){}); |
|||
callback(); |
|||
}, |
|||
|
|||
tests: function(test) { |
|||
|
|||
var css = grunt.file.read("docs/docco.css"); |
|||
var html = grunt.file.read("docs/docco.html"); |
|||
|
|||
test.expect(2); |
|||
test.ok(css.length > 0, "Should create CSS."); |
|||
test.ok(html.length > 0, "Should create HTML."); |
|||
test.done(); |
|||
}, |
|||
|
|||
testCustomCss: function(test) { |
|||
|
|||
var css = grunt.file.read("docs/custom.css"); |
|||
var html = grunt.file.read("docs/docco_test.html"); |
|||
|
|||
test.expect(2); |
|||
test.ok(css.length > 0, "Should use custom.css"); |
|||
test.ok(html.length > 0, "Should create HTML."); |
|||
test.done(); |
|||
} |
|||
}; |
@ -0,0 +1 @@ |
|||
h1 { color: red; } |
@ -0,0 +1,2 @@ |
|||
# Comment |
|||
function(){} |
@ -0,0 +1,500 @@ |
|||
/*--------------------- Typography ----------------------------*/ |
|||
|
|||
@font-face { |
|||
font-family: 'aller-light'; |
|||
src: url('public/fonts/aller-light.eot'); |
|||
src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'), |
|||
url('public/fonts/aller-light.woff') format('woff'), |
|||
url('public/fonts/aller-light.ttf') format('truetype'); |
|||
font-weight: normal; |
|||
font-style: normal; |
|||
} |
|||
|
|||
@font-face { |
|||
font-family: 'aller-bold'; |
|||
src: url('public/fonts/aller-bold.eot'); |
|||
src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'), |
|||
url('public/fonts/aller-bold.woff') format('woff'), |
|||
url('public/fonts/aller-bold.ttf') format('truetype'); |
|||
font-weight: normal; |
|||
font-style: normal; |
|||
} |
|||
|
|||
@font-face { |
|||
font-family: 'novecento-bold'; |
|||
src: url('public/fonts/novecento-bold.eot'); |
|||
src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'), |
|||
url('public/fonts/novecento-bold.woff') format('woff'), |
|||
url('public/fonts/novecento-bold.ttf') format('truetype'); |
|||
font-weight: normal; |
|||
font-style: normal; |
|||
} |
|||
|
|||
/*--------------------- Layout ----------------------------*/ |
|||
html { height: 100%; } |
|||
body { |
|||
font-family: "aller-light"; |
|||
font-size: 14px; |
|||
line-height: 18px; |
|||
color: #30404f; |
|||
margin: 0; padding: 0; |
|||
height:100%; |
|||
} |
|||
#container { min-height: 100%; } |
|||
|
|||
a { |
|||
color: #000; |
|||
} |
|||
|
|||
b, strong { |
|||
font-weight: normal; |
|||
font-family: "aller-bold"; |
|||
} |
|||
|
|||
p, ul, ol { |
|||
margin: 15px 0 0px; |
|||
} |
|||
|
|||
h1, h2, h3, h4, h5, h6 { |
|||
color: #112233; |
|||
line-height: 1em; |
|||
font-weight: normal; |
|||
font-family: "novecento-bold"; |
|||
text-transform: uppercase; |
|||
margin: 30px 0 15px 0; |
|||
} |
|||
|
|||
h1 { |
|||
margin-top: 40px; |
|||
} |
|||
|
|||
hr { |
|||
border: 0; |
|||
background: 1px solid #ddd; |
|||
height: 1px; |
|||
margin: 20px 0; |
|||
} |
|||
|
|||
pre, tt, code { |
|||
font-size: 12px; line-height: 16px; |
|||
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace; |
|||
margin: 0; padding: 0; |
|||
} |
|||
.annotation pre { |
|||
display: block; |
|||
margin: 0; |
|||
padding: 7px 10px; |
|||
background: #fcfcfc; |
|||
-moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); |
|||
-webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); |
|||
box-shadow: inset 0 0 10px rgba(0,0,0,0.1); |
|||
overflow-x: auto; |
|||
} |
|||
.annotation pre code { |
|||
border: 0; |
|||
padding: 0; |
|||
background: transparent; |
|||
} |
|||
|
|||
|
|||
blockquote { |
|||
border-left: 5px solid #ccc; |
|||
margin: 0; |
|||
padding: 1px 0 1px 1em; |
|||
} |
|||
.sections blockquote p { |
|||
font-family: Menlo, Consolas, Monaco, monospace; |
|||
font-size: 12px; line-height: 16px; |
|||
color: #999; |
|||
margin: 10px 0 0; |
|||
white-space: pre-wrap; |
|||
} |
|||
|
|||
ul.sections { |
|||
list-style: none; |
|||
padding:0 0 5px 0;; |
|||
margin:0; |
|||
} |
|||
|
|||
/* |
|||
Force border-box so that % widths fit the parent |
|||
container without overlap because of margin/padding. |
|||
|
|||
More Info : http://www.quirksmode.org/css/box.html |
|||
*/ |
|||
ul.sections > li > div { |
|||
-moz-box-sizing: border-box; /* firefox */ |
|||
-ms-box-sizing: border-box; /* ie */ |
|||
-webkit-box-sizing: border-box; /* webkit */ |
|||
-khtml-box-sizing: border-box; /* konqueror */ |
|||
box-sizing: border-box; /* css3 */ |
|||
} |
|||
|
|||
|
|||
/*---------------------- Jump Page -----------------------------*/ |
|||
#jump_to, #jump_page { |
|||
margin: 0; |
|||
background: white; |
|||
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; |
|||
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; |
|||
font: 16px Arial; |
|||
cursor: pointer; |
|||
text-align: right; |
|||
list-style: none; |
|||
} |
|||
|
|||
#jump_to a { |
|||
text-decoration: none; |
|||
} |
|||
|
|||
#jump_to a.large { |
|||
display: none; |
|||
} |
|||
#jump_to a.small { |
|||
font-size: 22px; |
|||
font-weight: bold; |
|||
color: #676767; |
|||
} |
|||
|
|||
#jump_to, #jump_wrapper { |
|||
position: fixed; |
|||
right: 0; top: 0; |
|||
padding: 10px 15px; |
|||
margin:0; |
|||
} |
|||
|
|||
#jump_wrapper { |
|||
display: none; |
|||
padding:0; |
|||
} |
|||
|
|||
#jump_to:hover #jump_wrapper { |
|||
display: block; |
|||
} |
|||
|
|||
#jump_page { |
|||
padding: 5px 0 3px; |
|||
margin: 0 0 25px 25px; |
|||
} |
|||
|
|||
#jump_page .source { |
|||
display: block; |
|||
padding: 15px; |
|||
text-decoration: none; |
|||
border-top: 1px solid #eee; |
|||
} |
|||
|
|||
#jump_page .source:hover { |
|||
background: #f5f5ff; |
|||
} |
|||
|
|||
#jump_page .source:first-child { |
|||
} |
|||
|
|||
/*---------------------- Low resolutions (> 320px) ---------------------*/ |
|||
@media only screen and (min-width: 320px) { |
|||
.pilwrap { display: none; } |
|||
|
|||
ul.sections > li > div { |
|||
display: block; |
|||
padding:5px 10px 0 10px; |
|||
} |
|||
|
|||
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { |
|||
padding-left: 30px; |
|||
} |
|||
|
|||
ul.sections > li > div.content { |
|||
background: #f5f5ff; |
|||
overflow-x:auto; |
|||
-webkit-box-shadow: inset 0 0 5px #e5e5ee; |
|||
box-shadow: inset 0 0 5px #e5e5ee; |
|||
border: 1px solid #dedede; |
|||
margin:5px 10px 5px 10px; |
|||
padding-bottom: 5px; |
|||
} |
|||
|
|||
ul.sections > li > div.annotation pre { |
|||
margin: 7px 0 7px; |
|||
padding-left: 15px; |
|||
} |
|||
|
|||
ul.sections > li > div.annotation p tt, .annotation code { |
|||
background: #f8f8ff; |
|||
border: 1px solid #dedede; |
|||
font-size: 12px; |
|||
padding: 0 0.2em; |
|||
} |
|||
} |
|||
|
|||
/*---------------------- (> 481px) ---------------------*/ |
|||
@media only screen and (min-width: 481px) { |
|||
#container { |
|||
position: relative; |
|||
} |
|||
body { |
|||
background-color: #F5F5FF; |
|||
font-size: 15px; |
|||
line-height: 21px; |
|||
} |
|||
pre, tt, code { |
|||
line-height: 18px; |
|||
} |
|||
p, ul, ol { |
|||
margin: 0 0 15px; |
|||
} |
|||
|
|||
|
|||
#jump_to { |
|||
padding: 5px 10px; |
|||
} |
|||
#jump_wrapper { |
|||
padding: 0; |
|||
} |
|||
#jump_to, #jump_page { |
|||
font: 10px Arial; |
|||
text-transform: uppercase; |
|||
} |
|||
#jump_page .source { |
|||
padding: 5px 10px; |
|||
} |
|||
#jump_to a.large { |
|||
display: inline-block; |
|||
} |
|||
#jump_to a.small { |
|||
display: none; |
|||
} |
|||
|
|||
|
|||
|
|||
#background { |
|||
position: absolute; |
|||
top: 0; bottom: 0; |
|||
width: 350px; |
|||
background: #fff; |
|||
border-right: 1px solid #e5e5ee; |
|||
z-index: -1; |
|||
} |
|||
|
|||
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { |
|||
padding-left: 40px; |
|||
} |
|||
|
|||
ul.sections > li { |
|||
white-space: nowrap; |
|||
} |
|||
|
|||
ul.sections > li > div { |
|||
display: inline-block; |
|||
} |
|||
|
|||
ul.sections > li > div.annotation { |
|||
max-width: 350px; |
|||
min-width: 350px; |
|||
min-height: 5px; |
|||
padding: 13px; |
|||
overflow-x: hidden; |
|||
white-space: normal; |
|||
vertical-align: top; |
|||
text-align: left; |
|||
} |
|||
ul.sections > li > div.annotation pre { |
|||
margin: 15px 0 15px; |
|||
padding-left: 15px; |
|||
} |
|||
|
|||
ul.sections > li > div.content { |
|||
padding: 13px; |
|||
vertical-align: top; |
|||
background: #f5f5ff; |
|||
border: none; |
|||
-webkit-box-shadow: none; |
|||
box-shadow: none; |
|||
} |
|||
|
|||
.pilwrap { |
|||
position: relative; |
|||
display: inline; |
|||
} |
|||
|
|||
.pilcrow { |
|||
font: 12px Arial; |
|||
text-decoration: none; |
|||
color: #454545; |
|||
position: absolute; |
|||
top: 3px; left: -20px; |
|||
padding: 1px 2px; |
|||
opacity: 0; |
|||
-webkit-transition: opacity 0.2s linear; |
|||
} |
|||
.for-h1 .pilcrow { |
|||
top: 47px; |
|||
} |
|||
.for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow { |
|||
top: 35px; |
|||
} |
|||
|
|||
ul.sections > li > div.annotation:hover .pilcrow { |
|||
opacity: 1; |
|||
} |
|||
} |
|||
|
|||
/*---------------------- (> 1025px) ---------------------*/ |
|||
@media only screen and (min-width: 1025px) { |
|||
|
|||
body { |
|||
font-size: 16px; |
|||
line-height: 24px; |
|||
} |
|||
|
|||
#background { |
|||
width: 525px; |
|||
} |
|||
ul.sections > li > div.annotation { |
|||
max-width: 525px; |
|||
min-width: 525px; |
|||
padding: 10px 25px 1px 50px; |
|||
} |
|||
ul.sections > li > div.content { |
|||
padding: 9px 15px 16px 25px; |
|||
} |
|||
} |
|||
|
|||
/*---------------------- Syntax Highlighting -----------------------------*/ |
|||
|
|||
td.linenos { background-color: #f0f0f0; padding-right: 10px; } |
|||
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } |
|||
/* |
|||
|
|||
github.com style (c) Vasily Polovnyov <vast@whiteants.net> |
|||
|
|||
*/ |
|||
|
|||
pre code { |
|||
display: block; padding: 0.5em; |
|||
color: #000; |
|||
background: #f8f8ff |
|||
} |
|||
|
|||
pre .comment, |
|||
pre .template_comment, |
|||
pre .diff .header, |
|||
pre .javadoc { |
|||
color: #408080; |
|||
font-style: italic |
|||
} |
|||
|
|||
pre .keyword, |
|||
pre .assignment, |
|||
pre .literal, |
|||
pre .css .rule .keyword, |
|||
pre .winutils, |
|||
pre .javascript .title, |
|||
pre .lisp .title, |
|||
pre .subst { |
|||
color: #954121; |
|||
/*font-weight: bold*/ |
|||
} |
|||
|
|||
pre .number, |
|||
pre .hexcolor { |
|||
color: #40a070 |
|||
} |
|||
|
|||
pre .string, |
|||
pre .tag .value, |
|||
pre .phpdoc, |
|||
pre .tex .formula { |
|||
color: #219161; |
|||
} |
|||
|
|||
pre .title, |
|||
pre .id { |
|||
color: #19469D; |
|||
} |
|||
pre .params { |
|||
color: #00F; |
|||
} |
|||
|
|||
pre .javascript .title, |
|||
pre .lisp .title, |
|||
pre .subst { |
|||
font-weight: normal |
|||
} |
|||
|
|||
pre .class .title, |
|||
pre .haskell .label, |
|||
pre .tex .command { |
|||
color: #458; |
|||
font-weight: bold |
|||
} |
|||
|
|||
pre .tag, |
|||
pre .tag .title, |
|||
pre .rules .property, |
|||
pre .django .tag .keyword { |
|||
color: #000080; |
|||
font-weight: normal |
|||
} |
|||
|
|||
pre .attribute, |
|||
pre .variable, |
|||
pre .instancevar, |
|||
pre .lisp .body { |
|||
color: #008080 |
|||
} |
|||
|
|||
pre .regexp { |
|||
color: #B68 |
|||
} |
|||
|
|||
pre .class { |
|||
color: #458; |
|||
font-weight: bold |
|||
} |
|||
|
|||
pre .symbol, |
|||
pre .ruby .symbol .string, |
|||
pre .ruby .symbol .keyword, |
|||
pre .ruby .symbol .keymethods, |
|||
pre .lisp .keyword, |
|||
pre .tex .special, |
|||
pre .input_number { |
|||
color: #990073 |
|||
} |
|||
|
|||
pre .builtin, |
|||
pre .constructor, |
|||
pre .built_in, |
|||
pre .lisp .title { |
|||
color: #0086b3 |
|||
} |
|||
|
|||
pre .preprocessor, |
|||
pre .pi, |
|||
pre .doctype, |
|||
pre .shebang, |
|||
pre .cdata { |
|||
color: #999; |
|||
font-weight: bold |
|||
} |
|||
|
|||
pre .deletion { |
|||
background: #fdd |
|||
} |
|||
|
|||
pre .addition { |
|||
background: #dfd |
|||
} |
|||
|
|||
pre .diff .change { |
|||
background: #0086b3 |
|||
} |
|||
|
|||
pre .chunk { |
|||
color: #aaa |
|||
} |
|||
|
|||
pre .tex .formula { |
|||
opacity: 0.5; |
|||
} |
@ -0,0 +1 @@ |
|||
8258c88c2bc39b972ba9ca1e9360383cdf4648ab |
Loading…
Reference in new issue