diff --git a/node_modules/.bin/docco b/node_modules/.bin/docco deleted file mode 120000 index e146526..0000000 --- a/node_modules/.bin/docco +++ /dev/null @@ -1 +0,0 @@ -../docco/bin/docco \ No newline at end of file diff --git a/node_modules/.bin/vows b/node_modules/.bin/vows deleted file mode 120000 index 0386e59..0000000 --- a/node_modules/.bin/vows +++ /dev/null @@ -1 +0,0 @@ -../vows/bin/vows \ No newline at end of file diff --git a/node_modules/docco/.gitignore b/node_modules/docco/.gitignore deleted file mode 100644 index 80df34f..0000000 --- a/node_modules/docco/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -output -docs \ No newline at end of file diff --git a/node_modules/docco/Cakefile b/node_modules/docco/Cakefile deleted file mode 100644 index 55b4904..0000000 --- a/node_modules/docco/Cakefile +++ /dev/null @@ -1,27 +0,0 @@ -{spawn, exec} = require 'child_process' - -option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`' - -task 'build', 'continually build the docco library with --watch', -> - coffee = spawn 'coffee', ['-cw', '-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 - ) diff --git a/node_modules/docco/README b/node_modules/docco/README deleted file mode 100644 index 777bb9d..0000000 --- a/node_modules/docco/README +++ /dev/null @@ -1,13 +0,0 @@ - ____ -/\ _`\ -\ \ \/\ \ ___ ___ ___ ___ - \ \ \ \ \ / __`\ /'___\ /'___\ / __`\ - \ \ \_\ \ /\ \ \ \ /\ \__/ /\ \__/ /\ \ \ \ - \ \____/ \ \____/ \ \____\ \ \____\ \ \____/ - \/___/ \/___/ \/____/ \/____/ \/___/ - - -Docco is a quick-and-dirty, hundred-line-long, literate-programming-style -documentation generator. For more information, see: - -http://jashkenas.github.com/docco/ \ No newline at end of file diff --git a/node_modules/docco/bin/docco b/node_modules/docco/bin/docco deleted file mode 100755 index d9f78a1..0000000 --- a/node_modules/docco/bin/docco +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env node - -var path = require('path'); -var fs = require('fs'); -var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib'); - -process.ARGV = process.argv = process.argv.slice(2, process.argv.length); -require(lib + '/docco.js'); diff --git a/node_modules/docco/index.html b/node_modules/docco/index.html deleted file mode 100644 index 73ce3c7..0000000 --- a/node_modules/docco/index.html +++ /dev/null @@ -1,143 +0,0 @@ -
docco.coffee | |
---|---|
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, and code is -passed through Pygments 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: - -
-
-...will generate linked HTML documentation for the named source files, saving
-it into a The source for Docco is available on GitHub, -and released under the MIT license. - -To install Docco, first make sure you have Node.js, -Pygments (install the latest dev version of Pygments -from its Mercurial repo), and -CoffeeScript. Then, with NPM: - -
-
-If Node.js doesn't run on your platform, or you'd prefer a more convenient -package, get Rocco, the Ruby port that's -available as a gem. If you're writing shell scripts, try -Shocco, a port for the POSIX shell. -Both are by Ryan Tomayko. If Python's more -your speed, take a look at Nick Fitzgerald's -Pycco. | |
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. | generate_documentation = (source, callback) ->
- fs.readFile source, "utf-8", (error, code) ->
- throw error if error
- sections = parse source, code
- highlight source, sections, ->
- generate_html source, sections
- 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: - - | parse = (source, code) ->
- lines = code.split '\n'
- sections = []
- language = get_language source
- has_code = docs_text = code_text = ''
-
- save = (docs, code) ->
- sections.push docs_text: docs, code_text: code
-
- for line in lines
- if line.match language.comment_matcher
- if not (line.match language.comment_filter)
- if has_code
- save docs_text, code_text
- has_code = docs_text = code_text = ''
- docs_text += line.replace(language.comment_matcher, '') + '\n'
- else
- has_code = yes
- code_text += line + '\n'
- save docs_text, code_text
- sections |
Highlights a single chunk of CoffeeScript code, using Pygments over stdio, -and runs the text of its corresponding comment through Markdown, using the -Github-flavored-Markdown modification of Showdown.js. - -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 = get_language source
- pygments = spawn 'pygmentize', ['-l', language.name, '-f', 'html', '-O', 'encoding=utf-8']
- output = ''
- pygments.stderr.addListener 'data', (error) ->
- console.error error if error
- pygments.stdout.addListener 'data', (result) ->
- output += result if result
- pygments.addListener 'exit', ->
- output = output.replace(highlight_start, '').replace(highlight_end, '')
- fragments = output.split language.divider_html
- for section, i in sections
- section.code_html = highlight_start + fragments[i] + highlight_end
- section.docs_html = showdown.makeHtml section.docs_text
- callback()
- pygments.stdin.write((section.code_text for section in sections).join(language.divider_text))
- pygments.stdin.end() |
Once all of the code is finished highlighting, we can generate the HTML file
-and write out the documentation. Pass the completed sections into the template
-found in | generate_html = (source, sections) ->
- title = path.basename source
- dest = destination source
- html = docco_template {
- title: title, sections: sections, sources: sources, path: path, destination: destination
- }
- console.log "docco: #{source} -> #{dest}"
- fs.writeFile 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' |
A list of the languages that Docco supports, mapping the file extension to -the name of the Pygments lexer and the symbol that indicates a comment. To -add another language to Docco's repertoire, add it here. | languages =
- '.coffee':
- name: 'coffee-script', symbol: '#'
- '.js':
- name: 'javascript', symbol: '//'
- '.rb':
- name: 'ruby', symbol: '#'
- '.py':
- name: 'python', symbol: '#' |
Build out the appropriate matchers and delimiters for each language. | for ext, l of languages |
Does the line begin with a comment? | l.comment_matcher = new RegExp('^\\s*' + l.symbol + '\\s?') |
Ignore hashbangs) | l.comment_filter = new RegExp('^#![/]') |
The dividing token we feed into Pygments, to delimit the boundaries between -sections. | l.divider_text = '\n' + l.symbol + 'DIVIDER\n' |
The mirror of | l.divider_html = new RegExp('\\n*<span class="c1?">' + l.symbol + 'DIVIDER<\\/span>\\n*') |
Get the current language we're documenting, based on the extension. | get_language = (source) -> languages[path.extname(source)] |
Compute the destination HTML path for an input source file path. If the source
-is | destination = (filepath) ->
- 'docs/' + path.basename(filepath, path.extname(filepath)) + '.html' |
Ensure that the destination directory exists. | ensure_directory = (callback) ->
- exec 'mkdir -p docs', -> callback() |
Micro-templating, originally by John Resig, borrowed by way of -Underscore.js. | 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('');" |
Create the template that we will use to generate the Docco HTML page. | docco_template = template fs.readFileSync(__dirname + '/../resources/docco.jst').toString() |
The CSS styles we'd like to apply to the documentation. | docco_styles = fs.readFileSync(__dirname + '/../resources/resources/docco.css').toString() |
The start of each Pygments highlight block. | highlight_start = '<div class="highlight"><pre>' |
The end of each Pygments highlight block. | highlight_end = '</pre></div>' |
Run the script. -For each source file passed in as an argument, generate the documentation. | sources = process.ARGV.sort()
-if sources.length
- ensure_directory ->
- fs.writeFile 'docs/resources/docco.css', docco_styles
- files = sources.slice(0)
- next_file = -> generate_documentation files.shift(), next_file if files.length
- next_file()
-
- |
';
- highlight_end = '
- - <%= title %> -- |
- - | -
---|---|
-
- ¶
-
- <%= section.docs_html %>
- |
- - <%= section.code_html %> - | -
'
-
-# The end of each Pygments highlight block.
-highlight_end = '
s around - // "paragraphs" that are wrapped in non-block-level tags, such as anchors, - // phrase emphasis, and spans. The list of tags we're looking for is - // hard-coded: - var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" - var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" - - // First, look for nested blocks, e.g.: - //
tags around block-level tags.
- text = _HashHTMLBlocks(text);
- text = _FormParagraphs(text);
-
- return text;
-}
-
-
-var _RunSpanGamut = function(text) {
-//
-// These are all the transformations that occur *within* block-level
-// tags like paragraphs, headers, and list items.
-//
-
- text = _DoCodeSpans(text);
- text = _EscapeSpecialCharsWithinTagAttributes(text);
- text = _EncodeBackslashEscapes(text);
-
- // Process anchor and image tags. Images must come first,
- // because ![foo][f] looks like an anchor.
- text = _DoImages(text);
- text = _DoAnchors(text);
-
- // Make links out of things like ` Just type tags
-//
-
- // Strip leading and trailing lines:
- text = text.replace(/^\n+/g,"");
- text = text.replace(/\n+$/g,"");
-
- var grafs = text.split(/\n{2,}/g);
- var grafsOut = new Array();
-
- //
- // Wrap tags.
- //
- var end = grafs.length;
- for (var i=0; i ");
- str += " Steal vows console object Construct a report object store contexts When vows fires report we add various data to our internal structure
-For a context, just inject a context object into our internal list
-For vow we add a vows object to that context
-For subject set the subject
-For finish, print the structure, then print the report Code horrors :( Find the parent context based on the name Create the real contexts object from this.contexts print a context recursively For each context print it delegate printing of the report to vows console Might be needed. Who knows o/ When vows reports ask our report to add the object Remove should from the prototype. Redefine should in a friendly manner. defaults objects overwritten through config. test whether an url is an url or has a method in it. utility create function factory to get a server instance. Cached internally Is object used in topic().is dummy getter dummy getter invocation. This will invoke the previous topic with values
-and return it request. This sets the value of the topic to be a request function.
-It goes off and asks for a server from the server factory,
-Then generates the url to request. It makes a request to your
-server then uses Set the topic to be a property of the current topic end the is abstraction returning the context owning the topic. Property descriptor for property is.
-Creates a Is, sets the parent and returns it.
-Typeof function check supports Add is as a getter to the topic to support replace topic method with a getter that returns the function
-make sure to bind this and add the It object used in Creates a should wrapper and returns it.
-Also sets the vow value to unwrap the should wrapper. Property descriptor for property it.
-Creates a It, sets the parent and returns it.
-Typeof function check supports Add is as a getter on Vow to support Replace vow method with a getter that returns the function
-make sure to bind the scope and add Extension of the should.js Assertion object header. Assert it has property headers and that the
-header error getter. Set's the object to the error and calls ok. a Should object which is a wrapper around should.js transforms the stack into a nice assertion string end the abstraction. This creates a should.js assertion
-and unravels the stack running every assertion.
-it then returns context that the vow belongs to. A stack of prettyPrint methods to make the assertions look pretty For each of the methods that can be called on a context add them to should.
-This tells the Should wrappers to end itself and return back to the context. Replace the vow method of Should with a getter so chaining doesn't break For each of the methods of Config method sets defaults partial method that runs a predefined partial function on the context Store hashes of partials Store a partial by name Expose methods of vows-fluent on exports. Expose the custom vows-is reporter Expose vows console End function will various clean up functions
-default.server.kill is your clean up function to kill the server expose should object from should.js Punch vows in the face
\n");
-
- return text;
-}
-
-var _EscapeSpecialCharsWithinTagAttributes = function(text) {
-//
-// Within tags -- meaning between < and > -- encode [\ ` * _] so they
-// don't conflict with their use in Markdown for code, italics and strong.
-//
-
- // Build a regex to find HTML tags and comments. See Friedl's
- // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
- var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;
-
- text = text.replace(regex, function(wholeMatch) {
- var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
- tag = escapeCharacters(tag,"\\`*_");
- return tag;
- });
-
- return text;
-}
-
-var _DoAnchors = function(text) {
-//
-// Turn Markdown link shortcuts into XHTML tags.
-//
- //
- // First, handle reference-style links: [link text] [id]
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- (
- (?:
- \[[^\]]*\] // allow brackets nested one level
- |
- [^\[] // or anything else
- )*
- )
- \]
-
- [ ]? // one optional space
- (?:\n[ ]*)? // one optional newline followed by spaces
-
- \[
- (.*?) // id = $3
- \]
- )()()()() // pad remaining backreferences
- /g,_DoAnchors_callback);
- */
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
-
- //
- // Next, inline-style links: [link text](url "optional title")
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- (
- (?:
- \[[^\]]*\] // allow brackets nested one level
- |
- [^\[\]] // or anything else
- )
- )
- \]
- \( // literal paren
- [ \t]*
- () // no id, so leave $3 empty
- (.*?)>? // href = $4
- [ \t]*
- ( // $5
- (['"]) // quote char = $6
- (.*?) // Title = $7
- \6 // matching quote
- [ \t]* // ignore any spaces/tabs between closing quote and )
- )? // title is optional
- \)
- )
- /g,writeAnchorTag);
- */
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
-
- //
- // Last, handle reference-style shortcuts: [link text]
- // These must come last in case you've also got [link test][1]
- // or [link test](/foo)
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- \[
- ([^\[\]]+) // link text = $2; can't contain '[' or ']'
- \]
- )()()()()() // pad rest of backreferences
- /g, writeAnchorTag);
- */
- text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
-
- return text;
-}
-
-var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
- if (m7 == undefined) m7 = "";
- var whole_match = m1;
- var link_text = m2;
- var link_id = m3.toLowerCase();
- var url = m4;
- var title = m7;
-
- if (url == "") {
- if (link_id == "") {
- // lower-case and turn embedded newlines into spaces
- link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
- }
- url = "#"+link_id;
-
- if (g_urls[link_id] != undefined) {
- url = g_urls[link_id];
- if (g_titles[link_id] != undefined) {
- title = g_titles[link_id];
- }
- }
- else {
- if (whole_match.search(/\(\s*\)$/m)>-1) {
- // Special case for explicit empty url
- url = "";
- } else {
- return whole_match;
- }
- }
- }
-
- url = escapeCharacters(url,"*_");
- var result = "" + link_text + "";
-
- return result;
-}
-
-
-var _DoImages = function(text) {
-//
-// Turn Markdown image shortcuts into tags.
-//
-
- //
- // First, handle reference-style labeled images: ![alt text][id]
- //
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- !\[
- (.*?) // alt text = $2
- \]
-
- [ ]? // one optional space
- (?:\n[ ]*)? // one optional newline followed by spaces
-
- \[
- (.*?) // id = $3
- \]
- )()()()() // pad rest of backreferences
- /g,writeImageTag);
- */
- text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
-
- //
- // Next, handle inline images: ![alt text](url "optional title")
- // Don't forget: encode * and _
-
- /*
- text = text.replace(/
- ( // wrap whole match in $1
- !\[
- (.*?) // alt text = $2
- \]
- \s? // One optional whitespace character
- \( // literal paren
- [ \t]*
- () // no id, so leave $3 empty
- (\S+?)>? // src url = $4
- [ \t]*
- ( // $5
- (['"]) // quote char = $6
- (.*?) // title = $7
- \6 // matching quote
- [ \t]*
- )? // title is optional
- \)
- )
- /g,writeImageTag);
- */
- text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
-
- return text;
-}
-
-var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
- var whole_match = m1;
- var alt_text = m2;
- var link_id = m3.toLowerCase();
- var url = m4;
- var title = m7;
-
- if (!title) title = "";
-
- if (url == "") {
- if (link_id == "") {
- // lower-case and turn embedded newlines into spaces
- link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
- }
- url = "#"+link_id;
-
- if (g_urls[link_id] != undefined) {
- url = g_urls[link_id];
- if (g_titles[link_id] != undefined) {
- title = g_titles[link_id];
- }
- }
- else {
- return whole_match;
- }
- }
-
- alt_text = alt_text.replace(/"/g,""");
- url = escapeCharacters(url,"*_");
- var result = "";
-
- return result;
-}
-
-
-var _DoHeaders = function(text) {
-
- // Setext-style headers:
- // Header 1
- // ========
- //
- // Header 2
- // --------
- //
- text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
- function(wholeMatch,m1){return hashBlock("" + _RunSpanGamut(m1) + "
");});
-
- text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
- function(matchFound,m1){return hashBlock("" + _RunSpanGamut(m1) + "
");});
-
- // atx-style headers:
- // # Header 1
- // ## Header 2
- // ## Header 2 with closing hashes ##
- // ...
- // ###### Header 6
- //
-
- /*
- text = text.replace(/
- ^(\#{1,6}) // $1 = string of #'s
- [ \t]*
- (.+?) // $2 = Header text
- [ \t]*
- \#* // optional closing #'s (not counted)
- \n+
- /gm, function() {...});
- */
-
- text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
- function(wholeMatch,m1,m2) {
- var h_level = m1.length;
- return hashBlock("` blocks.
-//
-
- /*
- text = text.replace(text,
- /(?:\n\n|^)
- ( // $1 = the code block -- one or more lines, starting with a space/tab
- (?:
- (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
- .*\n+
- )+
- )
- (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
- /g,function(){...});
- */
-
- // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
- text += "~0";
-
- text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
- function(wholeMatch,m1,m2) {
- var codeblock = m1;
- var nextChar = m2;
-
- codeblock = _EncodeCode( _Outdent(codeblock));
- codeblock = _Detab(codeblock);
- codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
- codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
-
- codeblock = "
";
-
- return hashBlock(codeblock) + nextChar;
- }
- );
-
- // attacklab: strip sentinel
- text = text.replace(/~0/,"");
-
- return text;
-}
-
-var hashBlock = function(text) {
- text = text.replace(/(^\n+|\n+$)/g,"");
- return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
-}
-
-
-var _DoCodeSpans = function(text) {
-//
-// * Backtick quotes are used for " + codeblock + "\n
spans.
-//
-// * You can use multiple backticks as the delimiters if you want to
-// include literal backticks in the code span. So, this input:
-//
-// Just type ``foo `bar` baz`` at the prompt.
-//
-// Will translate to:
-//
-//
foo `bar` baz
at the prompt.`bar`
...
-//
-
- /*
- text = text.replace(/
- (^|[^\\]) // Character before opening ` can't be a backslash
- (`+) // $2 = Opening run of `
- ( // $3 = The code block
- [^\r]*?
- [^`] // attacklab: work around lack of lookbehind
- )
- \2 // Matching closer
- (?!`)
- /gm, function(){...});
- */
-
- text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
- function(wholeMatch,m1,m2,m3,m4) {
- var c = m3;
- c = c.replace(/^([ \t]*)/g,""); // leading whitespace
- c = c.replace(/[ \t]*$/g,""); // trailing whitespace
- c = _EncodeCode(c);
- return m1+""+c+"
";
- });
-
- return text;
-}
-
-
-var _EncodeCode = function(text) {
-//
-// Encode/escape certain characters inside Markdown code runs.
-// The point is that in code, these characters are literals,
-// and lose their special Markdown meanings.
-//
- // Encode all ampersands; HTML entities are not
- // entities within a Markdown code span.
- text = text.replace(/&/g,"&");
-
- // Do the angle bracket song and dance:
- text = text.replace(//g,">");
-
- // Now, escape characters that are magic in Markdown:
- text = escapeCharacters(text,"\*_{}[]\\",false);
-
-// jj the line above breaks this:
-//---
-
-//* Item
-
-// 1. Subitem
-
-// special char: *
-//---
-
- return text;
-}
-
-
-var _DoItalicsAndBold = function(text) {
-
- // must go first:
- text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
- "$2");
-
- text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
- "$2");
-
- return text;
-}
-
-
-var _DoBlockQuotes = function(text) {
-
- /*
- text = text.replace(/
- ( // Wrap whole match in $1
- (
- ^[ \t]*>[ \t]? // '>' at the start of a line
- .+\n // rest of the first line
- (.+\n)* // subsequent consecutive lines
- \n* // blanks
- )+
- )
- /gm, function(){...});
- */
-
- text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
- function(wholeMatch,m1) {
- var bq = m1;
-
- // attacklab: hack around Konqueror 3.5.4 bug:
- // "----------bug".replace(/^-/g,"") == "bug"
-
- bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
-
- // attacklab: clean up hack
- bq = bq.replace(/~0/g,"");
-
- bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
- bq = _RunBlockGamut(bq); // recurse
-
- bq = bq.replace(/(^|\n)/g,"$1 ");
- // These leading spaces screw with content, so we need to fix that:
- bq = bq.replace(
- /(\s*
[^\r]+?<\/pre>)/gm,
- function(wholeMatch,m1) {
- var pre = m1;
- // attacklab: hack around Konqueror 3.5.4 bug:
- pre = pre.replace(/^ /mg,"~0");
- pre = pre.replace(/~0/g,"");
- return pre;
- });
-
- return hashBlock("
\n" + bq + "\n
");
- });
- return text;
-}
-
-
-var _FormParagraphs = function(text) {
-//
-// Params:
-// $text - string to process with html
reporter.js
var consoleObj = require("../lib/console.js");
-
-var options = { tail: '\n' };
-var stylize = consoleObj.stylize,
- puts = consoleObj.puts(options);
var report = {
"contexts": {},
"add": function _add(obj) {
- if (obj[0] === "context") {
- this.contexts[obj[1]] = { vows: {} };
- } else if (obj[0] === "vow") {
- var vow = obj[1];
- this.contexts[vow.context].vows[vow.title] = vow;
- } else if (obj[0] === "subject") {
- this.subject = obj[1];
- } else if (obj[0] === "finish") {
- this.print();
- this.printReport(obj[1]);
- }
- },
"print": function _print() {
- var self = this;
- puts('\n♢ ' + stylize(this.subject, 'bold') + '\n');
-
- var contexts = {};
function findParent(contexts, text) {
- var obj = false;
- var newKey = text;
- for (var key in contexts) {
- var context = contexts[key];
- if (context.oldKey) {
- key = context.oldKey;
- }
- if (context.contexts) {
- var arr = findParent(context.contexts, text);
- if (arr) {
- return arr;
- }
- }
- if (text.indexOf(key) !== -1) {
- newKey = text.replace(key, "");
- obj = context;
- break;
- }
- }
- if (obj) {
- return [obj, newKey];
- } else {
- return false;
- }
- };
Object.keys(this.contexts).sort().forEach(function(key) {
- var arr = findParent(contexts, key);
- if (arr) {
- var context = arr[0];
- var newKey = arr[1];
- }
-
- if (!arr) {
- contexts[key] = self.contexts[key];
- if (!contexts[key].contexts) {
- contexts[key].contexts = {};
- }
- } else {
- context.contexts[newKey] = self.contexts[key];
- context.contexts[newKey].oldKey = key;
- if (!context.contexts[newKey].contexts) {
- context.contexts[newKey].contexts = {};
- }
- }
- });
function print(context, key, depth) {
- var whitespace = (new Array(depth + 1)).join(" ");
- puts(whitespace + consoleObj.contextText(key));
-
- Object.keys(context.vows).forEach(function(key2) {
- puts(whitespace + " " + consoleObj.vowText(context.vows[key2]));
- });
- if (context.contexts) {
- Object.keys(context.contexts).forEach(function(key) {
- print(context.contexts[key], key, depth + 1);
- });
- }
- }
Object.keys(contexts).forEach(function(key) {
- print(contexts[key], key, 0);
- });
- },
"printReport": function _printReport(report) {
- puts(consoleObj.result(report).join('\n'));
- }
-}
-
-exports.name = 'prettyprint';
exports.setStream = function _setStream(s) {
- options.stream = s;
-};
exports.report = function _report(obj) {
- report.add(obj);
-};
-
-
vows-is.js
var fluent = require("vows-fluent"),
- request = require("request"),
- should = require("should"),
- EventEmitter = require("events").EventEmitter.Prototype,
- AssertionConstructor = should.Assertion,
- Assertion = AssertionConstructor.prototype,
- Trait = require("traits").Trait,
- Topic = fluent.Topic,
- Vow = fluent.Vow,
- Context = fluent.Context;
delete Object.prototype.should;
Object.defineProperty(Object.prototype, "should", {
- get: function() {
- return this._should || new AssertionConstructor(this);
- },
- set: function(val) {
- this._should = val;
- },
- configurable: true
-});
var defaults = {},
test_uri = /^(GET|POST|PUT|HEAD|DELETE)(.*)/;
var create = function _create(trait) {
- return Object.create(Object.prototype, trait)
-};
var getServer = function _getServer(cb) {
- if (getServer.app) {
- cb(getServer.app);
- } else {
- defaults.server.factory(function(app) {
- getServer.app = app;
- cb(app);
- });
- }
-}
exports.Is = {
get a() {
- return this;
- },
get an() {
- return this;
- },
"invocation": function _invocation() {
- var args = arguments;
- this._parent.set(wrapTopicInError(function _topic(topic) {
- return topic.apply(null, args);
- }));
- return this.end();
- },
this.callback
to set the response as the topic "request": function _request(url) {
- this._parent.set(function _topic() {
- var cb = this.callback;
- getServer(function _getServer(server) {
- var options;
- if (typeof url === "string") {
- options = {};
- var match = url && url.match(test_uri);
- if (match) {
- options.method = match[1];
- options.uri = defaults.server.uri + match[2].substr(1);
- } else {
- options.uri = defaults.server.uri + uri
- }
- } else {
- options = url;
- }
- request(options, function _handleRequest(err, res, body) {
- cb(err, res);
- });
- });
- });
- return this.end()
- },
"property": function _property(name) {
- this._parent.set(function _topic(topic) {
- return topic[name];
- });
- return this.end()
- },
"end": function _end() {
- return this._parent.parent()
- }
-};
-
-var wrapTopicInError = function _wrap(val) {
- return function() {
- try {
- return val.apply(this, arguments);
- } catch (e) {
- var ev = Object.create(EventEmitter);
- process.nextTick(function() {
- ev.emit('error', e)
- });
- return ev;
- }
- };
-}
topic.is
and topic().is
-The function is used to allow topic.is(value)
var propertyDescriptorIs = {
- "set": function _set() {},
- "get": function _get() {
- var i = create(Trait(exports.Is));
- if (typeof this === "function") {
- i._parent = this();
- } else {
- i._parent = this;
- }
- var f = (function _is(val) {
- if (typeof val === "function") {
- var val = wrapTopicInError(val);
- }
- this._parent.set(val);
- return this.end();
- }).bind(i);
- var keys = Object.getOwnPropertyNames(i);
- keys.forEach(function(key) {
- var pd = Object.getOwnPropertyDescriptor(i, key);
- Object.defineProperty(f, key, pd);
- });
- return f;
- }
-};
topic().is
Object.defineProperty(Topic, "is", propertyDescriptorIs);
is
property to the function var old_topic = Context.topic;
-Object.defineProperty(Context, "topic", {
- "set": function _set() {},
- "get": function _get() {
- var f = old_topic.bind(this);
- Object.defineProperty(f, "is", propertyDescriptorIs);
- return f;
- }
-});
vow().it
exports.It = {
get should() {
- var s = create(Trait(exports.Should));
- s._stack = [];
- s._parent = this._parent;
- return s;
- }
-}
vow.it
and vow().it
var propertyDescriptorIt = {
- "set": function _set() {},
- "get": function _get() {
- var i = create(Trait(exports.It));
- if (typeof this === "function") {
- i._parent = this();
- } else {
- i._parent = this;
- }
- return i;
- }
-};
vow().it
Object.defineProperty(Vow, "it", propertyDescriptorIt);
it
to the vow
value var old_vow = Context.vow
-Object.defineProperty(Context, "vow", {
- "set": function _set() {},
- "get": function _get() {
- var f = old_vow.bind(this);
- Object.defineProperty(f, "it", propertyDescriptorIt);
- return f;
- }
-});
exports.Assertion = create(Trait.override(Trait({
name
has value val
"header": function _header(name, val) {
- return this.property("headers").with.property(name, val);
- },
get error() {
- this.obj = this._error
- return this.ok;
- },
-}), Trait(Assertion)));
exports.Should = {
"prettyPrint": function _prettyPrint() {
- var arr = this._stack.map(function _map(val) {
- var str = val.key;
- if (exports.prettyPrint[val.key]) {
- str += " " + exports.prettyPrint[val.key](val.args);
- } else if (val.args.length) {
- str += " " + val.args.join(" ");
- }
- return str;
- });
- arr.unshift("should");
- return arr.join(" ");
- },
"end": function _end() {
- var s = create(Trait(exports.Assertion));
- s.obj = this._obj;
- s._error = this._error;
- this._stack.forEach(function _each(val) {
- if (val.type === 'get') {
- s = s[val.key];
- } else {
- s = s[val.key].apply(s, val.args);
- }
- });
- return this._parent.parent();
- }
-};
exports.prettyPrint = {
- "header": function _property(args) {
- return args[0] + " with value " + args[1];
- }
-};
["vow", "context", "parent", "batch", "suite", "partial"].forEach(function _each(key) {
- exports.Should[key] = function _parent() {
- var parent = this._parent.parent();
- if (!this._parent._name) {
- this._parent.name(this.prettyPrint());
- }
- var that = this;
- this._parent.set(function _set(err, value) {
- that._obj = value;
- that._error = err;
- that.end();
- });
- return parent[key].apply(parent, arguments);
- };
-});
var should_vow = exports.Should.vow
-Object.defineProperty(exports.Should, "vow", {
- "set": function _set() {},
- "get": function _get() {
- var f = should_vow.bind(this);
- Object.defineProperty(f, "it", propertyDescriptorIt);
- return f;
- }
-});
exports.Assersion
add a wrapper
-to Should. The wrapper simply saves the command on a stack.
-The stack is unravelled when the should wrapper ends. Object.keys(exports.Assertion).forEach(function _each(key) {
- if (!exports.Should.hasOwnProperty(key)) {
- var descriptor = Object.getOwnPropertyDescriptor(exports.Assertion, key);
- var name = descriptor.get ? "get" : "value";
- descriptor[name] = function _descriptor() {
- this._stack.push({
- "type": name,
- "key": key,
- "args": Array.prototype.slice.call(arguments)
- });
- return this;
- }
- Object.defineProperty(exports.Should, key, descriptor);
- }
-});
exports.config = function _init(obj) {
- Object.keys(obj).forEach(function _each(key) {
- defaults[key] = obj[key];
- });
- if (defaults.server.defaults) {
- request = request.defaults(defaults.server.defaults);
- }
- return this;
-};
Context.partial = function _partial(name, data) {
- var p = exports._partial[name];
- return p(this, data);
-};
exports._partial = {};
exports.partial = function _partial(name, f) {
- this._partial[name] = f;
- return this;
-};
Object.keys(fluent).forEach(function _each(key) {
- exports[key] = fluent[key];
-});
exports.reporter = require("./reporter.js");
exports.console = require("../lib/console.js");
exports.end = function _end() {
- if (defaults.server &&
- defaults.server.kill &&
- typeof defaults.server.kill === "function"
- ) {
- getServer(function(server) {
- defaults.server.kill(server);
- });
- }
-};
exports.should = should;
var stylize = exports.console.stylize;
-var inspect = exports.console.inspect;
-
-require('assert').AssertionError.prototype.toString = function () {
- var that = this,
- source = this.stack && this.stack.match(/([a-zA-Z0-9._-]+\.js)(:\d+):\d+/);
-
- function parse(str) {
- return str.replace(/{actual}/g, inspect(that.actual)).
- replace(/{operator}/g, stylize(that.operator, 'bold')).
- replace(/{expected}/g, (that.expected instanceof Function)
- ? that.expected.name
- : inspect(that.expected));
- }
-
- if (this.message) {
- var msg = stylize(parse(this.message), 'yellow');
- if (source) {
- msg += stylize(' // ' + source[1] + source[2], 'grey');
- }
- return msg;
- } else {
- return stylize([
- this.expected,
- this.operator,
- this.actual
- ].join(' '), 'yellow');
- }
-};
-
-