Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Docs!

  • Loading branch information...
commit 159265add47c376f596504847942e42b868e0a43 1 parent c4b7b24
@traviskaufman authored
View
4 Cakefile
@@ -17,6 +17,10 @@ task "lint", "lint all coffeescript in the src/ dir", ->
sh "node_modules/coffeelint/bin/coffeelint -r src/"
notice "Coffeelint Passed!"
+task "doc", "generate documentation for all modules in src/", ->
+ sh "node_modules/coffeedoc/bin/coffeedoc src/"
+ notice "Documentation Generated!"
+
# Taken from coffee-script/Cakefile
notice = (msg) ->
stars = ("*" for _ in [1..msg.length+4]).join("")
View
128 docs/index.html
@@ -0,0 +1,128 @@
+<!doctype html>
+
+<!-- Documentation generated by [CoffeeDoc](http://github.com/omarkhan/coffeedoc) -->
+
+<html>
+<head>
+ <title>CoffeeDoc</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" media="all" href="resources/base.css" />
+</head>
+<body>
+ <header>
+ <h1>CoffeeDoc &mdash; Module Index</h1>
+ </header>
+ <div class="container">
+ <div class="sidebar column">
+ <ul id="modulelist">
+
+ <li><a href="src/cli.coffee.html">src/cli.coffee</a></li>
+
+ <li><a href="src/lipsum.coffee.html">src/lipsum.coffee</a></li>
+
+ <li><a href="src/parser.coffee.html">src/parser.coffee</a></li>
+
+ <li><a href="src/service.coffee.html">src/service.coffee</a></li>
+
+ </ul>
+ </div>
+ <div class="content column">
+
+ <div class="module">
+ <div class="header">
+ <a href="src/cli.coffee.html"><h1>cli.coffee</h1></a>
+ </div>
+ <div class="module-content">
+ <h1>Lipsum Command-line Interface</h1>
+<p>This module provides a CLI wrapper for the main module, allowing it to be
+easily used via anyone&#39;s login shell.
+</p>
+
+
+
+ <h3>Functions</h3>
+ <ul class="functionlist">
+
+ <li><a href="src/cli.coffee.html#exports.run">exports.run(args)</a></li>
+
+ <li><a href="src/cli.coffee.html#exports._run">exports._run(argv)</a></li>
+
+ </ul>
+
+ </div>
+ </div>
+
+ <div class="module">
+ <div class="header">
+ <a href="src/lipsum.coffee.html"><h1>lipsum.coffee</h1></a>
+ </div>
+ <div class="module-content">
+ <h1>Lorem Ipsum Wrapper</h1>
+<p>Main entry point for the node-lipsum module. Provides wrappers for
+the Parser and Service classes as well as an easy method to get text
+from the lipsum.org service.
+</p>
+
+
+ <h3>Classes</h3>
+ <ul class="classlist">
+
+ <li><a href="src/lipsum.coffee.html#Lipsum">Lipsum</a></li>
+
+ </ul>
+
+
+ </div>
+ </div>
+
+ <div class="module">
+ <div class="header">
+ <a href="src/parser.coffee.html"><h1>parser.coffee</h1></a>
+ </div>
+ <div class="module-content">
+ <h1>Lipsum Parser</h1>
+<p>Detects whether input is XML or JSON and parses accordingly.
+Parsing within the file provides the advantage of decoupling server calls with
+calls to the parser, as it is able to be agnostic to the format received. It
+cannot, however, parse HTML (nor should it have to).
+</p>
+
+
+ <h3>Classes</h3>
+ <ul class="classlist">
+
+ <li><a href="src/parser.coffee.html#LipsumParser">LipsumParser</a></li>
+
+ </ul>
+
+
+ </div>
+ </div>
+
+ <div class="module">
+ <div class="header">
+ <a href="src/service.coffee.html"><h1>service.coffee</h1></a>
+ </div>
+ <div class="module-content">
+ <h1>Web Service for lipsum.org</h1>
+<p>Provides the low-level interface to the lipsum.org
+service.
+</p>
+
+
+ <h3>Classes</h3>
+ <ul class="classlist">
+
+ <li><a href="src/service.coffee.html#Service">Service</a></li>
+
+ </ul>
+
+
+ </div>
+ </div>
+
+ </div>
+ </div>
+</body>
+</html>
View
396 docs/resources/base.css
@@ -0,0 +1,396 @@
+/*
+ * Skeleton V1.1
+ * Copyright 2011, Dave Gamache
+ * www.getskeleton.com
+ * Free to use under the MIT license.
+ * http://www.opensource.org/licenses/mit-license.php
+ * 8/17/2011
+ */
+
+
+/* #Reset & Basics (Inspired by E. Meyers)
+================================================== */
+ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ font-size: 100%;
+ font: inherit;
+ vertical-align: baseline; }
+ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
+ display: block; }
+ body {
+ line-height: 1; }
+ ol, ul {
+ list-style: none; }
+ blockquote, q {
+ quotes: none; }
+ blockquote:before, blockquote:after,
+ q:before, q:after {
+ content: '';
+ content: none; }
+ table {
+ border-collapse: collapse;
+ border-spacing: 0; }
+
+
+/* #Basic Styles
+================================================== */
+ body {
+ background: #fff;
+ font: 14px/21px "Helvetica Neue", Helvetica, Arial, sans-serif;
+ color: #444;
+ -webkit-font-smoothing: antialiased; /* Fix for webkit rendering */
+ -webkit-text-size-adjust: 100%;
+ }
+
+
+/* #Typography
+================================================== */
+ h1, h2, h3, h4, h5, h6 {
+ font-family: "Georgia", serif;
+ font-weight: normal; }
+ h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { font-weight: inherit; }
+ h1 { font-size: 34px; line-height: 50px; margin-bottom: 14px;}
+ h2 { font-size: 28px; line-height: 40px; margin-bottom: 10px; }
+ h3 { font-size: 23px; line-height: 34px; margin-bottom: 8px; }
+ h4 { font-size: 19px; line-height: 30px; margin-bottom: 4px; }
+ h5 { font-size: 16px; line-height: 24px; }
+ h6 { font-size: 14px; line-height: 21px; }
+
+ p { margin: 0 0 20px 0; }
+ p img { margin: 0; }
+
+ em { font-style: italic; }
+ strong { font-weight: bold; color: #333; }
+ small { font-size: 80%; }
+
+/* Blockquotes */
+ blockquote, blockquote p { font-size: 17px; line-height: 24px; color: #777; font-style: italic; }
+ blockquote { margin: 0 0 20px; padding: 9px 20px 0 19px; border-left: 1px solid #ddd; }
+ blockquote cite { display: block; font-size: 12px; color: #555; }
+ blockquote cite:before { content: "\2014 \0020"; }
+ blockquote cite a, blockquote cite a:visited, blockquote cite a:visited { color: #555; }
+
+ hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 10px 0 30px; height: 0; }
+
+
+/* #Links
+================================================== */
+ a, a:visited {
+ color: #2d81c5;
+ text-decoration: none; outline: 0;
+ -webkit-transition: color 250ms ease-in-out;
+ -moz-transition: color 250ms ease-in-out;
+ transition: color 250ms ease-in-out;
+ }
+ a:hover, a:focus {
+ color: #2569a0;
+ }
+ p a, p a:visited { line-height: inherit; }
+
+
+/* #Lists
+================================================== */
+ ul, ol { margin-bottom: 20px; }
+ ul { list-style: none outside; }
+ ol { list-style: decimal; }
+ ol, ul.square, ul.circle, ul.disc { margin-left: 30px; }
+ ul.square { list-style: square outside; }
+ ul.circle { list-style: circle outside; }
+ ul.disc { list-style: disc outside; }
+ ul ul, ul ol,
+ ol ol, ol ul { margin: 4px 0 5px 30px; font-size: 90%; }
+ ul ul li, ul ol li,
+ ol ol li, ol ul li { margin-bottom: 6px; }
+ li { line-height: 18px; margin-bottom: 12px; }
+ ul.large li { line-height: 21px; }
+ li p { line-height: 21px; }
+
+
+/* #Images
+================================================== */
+
+ img.scale-with-grid {
+ max-width: 100%;
+ height: auto; }
+
+
+/* #Misc
+================================================== */
+ .remove-bottom { margin-bottom: 0 !important; }
+ .half-bottom { margin-bottom: 10px !important; }
+ .add-bottom { margin-bottom: 20px !important; }
+
+
+/* #Base 960 Grid
+================================================== */
+
+ .container { position: relative; width: 960px; margin: 0 auto; padding: 0; }
+ .container .column { float: left; display: inline; margin-left: 10px; margin-right: 10px; }
+ .row { margin-bottom: 20px; }
+
+ /* Base Grid */
+ .container .sidebar.column { width: 220px; }
+ .container .content.column { width: 700px; }
+
+
+/* #Tablet (Portrait)
+================================================== */
+
+ /* Note: Design for a width of 768px */
+
+ @media only screen and (min-width: 768px) and (max-width: 959px) {
+ .container { width: 768px; }
+ .container .column { margin-left: 10px; margin-right: 10px; }
+
+ .container .sidebar.column { width: 172px; }
+ .container .content.column { width: 556px; }
+ }
+
+
+/* #Mobile (Portrait)
+================================================== */
+
+ /* Note: Design for a width of 320px */
+
+ @media only screen and (max-width: 767px) {
+ .container { width: 300px; }
+ .container .column { margin: 0; }
+
+ .container .sidebar.column,
+ .container .content.column { width: 300px; }
+ }
+
+
+/* #Mobile (Landscape)
+================================================== */
+
+ /* Note: Design for a width of 480px */
+
+ @media only screen and (min-width: 480px) and (max-width: 767px) {
+ .container { width: 420px; }
+ .container .column { margin: 0; }
+
+ .container .sidebar.column,
+ .container .content.column { width: 420px; }
+ }
+
+
+/* #Clearing
+================================================== */
+
+ /* Self Clearing Goodness */
+ .container:after { content: "\0020"; display: block; height: 0; clear: both; visibility: hidden; }
+
+
+/* #CoffeeDoc styles
+================================================== */
+
+code {
+ color: #000;
+ background: #f6f6f6;
+ padding: 2px 4px;
+ border: 1px solid #ccc;
+ font-size: 12px; line-height: 18px;
+ font-family: Monaco, Consolas, "Lucida Console", monospace;
+ border-radius: 2px;
+}
+pre code {
+ display: block;
+ border-radius: 4px;
+ margin-bottom: 20px;
+ padding: 10px;
+}
+header {
+ width: 100%;
+ border-bottom: 1px solid #bbb;
+ margin-bottom: 20px;
+ background-image: -webkit-linear-gradient(top, #fff, #d0d0d0);
+ background-image: -moz-linear-gradient(top, #fff, #d0d0d0);
+ background-image: linear-gradient(top, #fff, #d0d0d0);
+}
+header h1 {
+ margin: 0;
+ line-height: 50px;
+ font-size: 20px;
+ text-align: center;
+}
+h1, h2 {
+ border-bottom: 1px solid #ccc;
+}
+h3 {
+ border-bottom: 1px solid #ddd;
+}
+
+
+/* #Module index
+================================================== */
+
+.module {
+ margin-bottom: 25px;
+}
+.module .header h1 {
+ margin-bottom: 20px;
+ border-bottom: none;
+ box-shadow: 0 5px 5px -6px rgba(45, 129, 197, 0.4);
+ -webkit-transition: box-shadow 250ms ease-in-out;
+ -moz-transition: box-shadow 250ms ease-in-out;
+ transition: box-shadow 250ms ease-in-out;
+}
+.module .header h1:hover {
+ box-shadow: 0 5px 5px -6px rgb(45, 129, 197);
+}
+.module-content h1 {
+ font-size: 30px;
+ line-height: 44px;
+}
+
+
+/* #Module pages
+================================================== */
+
+.function, .class {
+ margin-bottom: 30px;
+}
+.method {
+ margin-bottom: 20px;
+}
+.class .header {
+ border-bottom: 1px solid #ccc;
+ margin-bottom: 10px;
+}
+.class .header h3 {
+ display: inline;
+ border: none;
+}
+.class .header .parent {
+ color: #aaa;
+}
+.class .header .parent:hover {
+ color: #2569a0;
+}
+
+
+/* #Syntax highlighting
+============================================================== */
+
+/* github.com style (c) Vasily Polovnyov <vast@whiteants.net> */
+
+pre .comment,
+pre .template_comment,
+pre .diff .header,
+pre .javadoc {
+ color: #998;
+ font-style: italic
+}
+
+pre .keyword,
+pre .css .rule .keyword,
+pre .winutils,
+pre .javascript .title,
+pre .lisp .title,
+pre .subst {
+ color: #000;
+ font-weight: bold
+}
+
+pre .number,
+pre .hexcolor {
+ color: #40a070
+}
+
+pre .string,
+pre .tag .value,
+pre .phpdoc,
+pre .tex .formula {
+ color: #d14
+}
+
+pre .title,
+pre .id {
+ color: #900;
+ font-weight: bold
+}
+
+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: #009926
+}
+
+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 .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;
+}
View
74 docs/src/cli.coffee.html
@@ -0,0 +1,74 @@
+<!doctype html>
+
+<!-- Documentation generated by [CoffeeDoc](http://github.com/omarkhan/coffeedoc) -->
+
+<html>
+<head>
+ <title>CoffeeDoc | cli.coffee</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" media="all" href="../resources/base.css" />
+</head>
+<body>
+ <header>
+ <h1>cli.coffee</h1>
+ </header>
+ <div class="container">
+ <div class="sidebar column">
+
+
+ <h4>Functions</h4>
+ <ul class="functionlist">
+
+ <li><a href="#exports.run">exports.run</a></li>
+
+ <li><a href="#exports._run">exports._run</a></li>
+
+ </ul>
+
+ </div>
+ <div class="content column">
+
+ <div id="module-docstring">
+ <h1>Lipsum Command-line Interface</h1>
+<p>This module provides a CLI wrapper for the main module, allowing it to be
+easily used via anyone&#39;s login shell.
+</p>
+
+ </div>
+
+
+
+ <div id="functions">
+ <h2>Functions</h2>
+
+ <div class="function">
+ <div class="header">
+ <a id="exports.run"><h3>exports.run(args)</h3></a>
+ </div>
+
+ <div>
+ <p>This will run the CLI
+
+</p>
+<p>args: {Array} The arguments that would be passed to the CLI.
+ This is usually something like <code>process.argv.slice(2)</code>
+</p>
+
+ </div>
+
+ </div>
+
+ <div class="function">
+ <div class="header">
+ <a id="exports._run"><h3>exports._run(argv)</h3></a>
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+ </div>
+</body>
+</html>
View
117 docs/src/lipsum.coffee.html
@@ -0,0 +1,117 @@
+<!doctype html>
+
+<!-- Documentation generated by [CoffeeDoc](http://github.com/omarkhan/coffeedoc) -->
+
+<html>
+<head>
+ <title>CoffeeDoc | lipsum.coffee</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" media="all" href="../resources/base.css" />
+</head>
+<body>
+ <header>
+ <h1>lipsum.coffee</h1>
+ </header>
+ <div class="container">
+ <div class="sidebar column">
+
+ <h4>Classes</h4>
+ <ul class="classlist">
+
+ <li><a href="#Lipsum">Lipsum</a></li>
+
+ </ul>
+
+
+ </div>
+ <div class="content column">
+
+ <div id="module-docstring">
+ <h1>Lorem Ipsum Wrapper</h1>
+<p>Main entry point for the node-lipsum module. Provides wrappers for
+the Parser and Service classes as well as an easy method to get text
+from the lipsum.org service.
+</p>
+
+ </div>
+
+
+ <div id="classes">
+ <h2>Classes</h2>
+
+ <div class="class">
+ <div class="header">
+ <a id="Lipsum"><h3>Lipsum</h3></a>
+
+
+ <a class="parent" href="#events.EventEmitter"><h3>extends events.EventEmitter</h3></a>
+
+
+ </div>
+ <div class="class-content">
+
+ <div class="methods">
+
+
+ <div class="instancemethods">
+ <h3>Instance Methods</h3>
+
+ <div class="method">
+ <h4>constructor()</h4>
+ <p>Class Constructor </p>
+
+ </div>
+
+ <div class="method">
+ <h4>getText(callback, opts)</h4>
+ <p>Retrieves dummy text from lipsum.org
+
+</p>
+<p>callback: {Function} Should take one parameter for the text
+ returned from lipsum.org. Called on successful retrieval
+ of said text.
+
+</p>
+<p>opts: {Object} Options to pass onto the lipsum.org query. These will
+ be transformed into url query params, so if you pass in something
+ like {start: &#39;yes&#39;, what: &#39;bytes&#39;} that will become
+ &quot;?start=yes&amp;what=bytes&quot;
+</p>
+
+ </div>
+
+ <div class="method">
+ <h4>parserSuccessCallBack(result)</h4>
+ <p>Called on successful parsing of returned dummy text. </p>
+
+ </div>
+
+ <div class="method">
+ <h4>parserErrorCallBack(err)</h4>
+ <p>Called on Parser Error. </p>
+
+ </div>
+
+ <div class="method">
+ <h4>serviceCallback(text)</h4>
+ <p>Called when the lipsum.org service succesfully retrieves
+text from the lipsum.org service.
+</p>
+
+ </div>
+
+ </div>
+
+
+ </div>
+ </div>
+ </div>
+
+ </div>
+
+
+ </div>
+ </div>
+</body>
+</html>
View
130 docs/src/parser.coffee.html
@@ -0,0 +1,130 @@
+<!doctype html>
+
+<!-- Documentation generated by [CoffeeDoc](http://github.com/omarkhan/coffeedoc) -->
+
+<html>
+<head>
+ <title>CoffeeDoc | parser.coffee</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" media="all" href="../resources/base.css" />
+</head>
+<body>
+ <header>
+ <h1>parser.coffee</h1>
+ </header>
+ <div class="container">
+ <div class="sidebar column">
+
+ <h4>Classes</h4>
+ <ul class="classlist">
+
+ <li><a href="#LipsumParser">LipsumParser</a></li>
+
+ </ul>
+
+
+ </div>
+ <div class="content column">
+
+ <div id="module-docstring">
+ <h1>Lipsum Parser</h1>
+<p>Detects whether input is XML or JSON and parses accordingly.
+Parsing within the file provides the advantage of decoupling server calls with
+calls to the parser, as it is able to be agnostic to the format received. It
+cannot, however, parse HTML (nor should it have to).
+</p>
+
+ </div>
+
+
+ <div id="classes">
+ <h2>Classes</h2>
+
+ <div class="class">
+ <div class="header">
+ <a id="LipsumParser"><h3>LipsumParser</h3></a>
+
+
+ <a class="parent" href="#events.EventEmitter"><h3>extends events.EventEmitter</h3></a>
+
+
+ </div>
+ <div class="class-content">
+
+ <div class="methods">
+
+
+ <div class="instancemethods">
+ <h3>Instance Methods</h3>
+
+ <div class="method">
+ <h4>constructor(payload)</h4>
+ <p>Instantiates the class with an optional payload </p>
+
+ </div>
+
+ <div class="method">
+ <h4>feed(payload)</h4>
+ <p>Given a payload (which should be XML or JSON), it stores
+this and then returns itself for chainability.
+</p>
+
+ </div>
+
+ <div class="method">
+ <h4>parse(successCallback, errCallback)</h4>
+ <p>Parses the payload it was Given
+
+</p>
+<p>successCallback: {Function} called on successful parse.
+ Takes one parameter that contains the parsed
+ output.
+
+</p>
+<p>errCallback: {Function} called on parsing error from XML parser.
+ Note that this will be called even if the payload is JSON,
+ since JSON is attempted to be parsed first.
+</p>
+
+ </div>
+
+ </div>
+
+
+ <div class="privatemethods">
+ <h3>Private Methods</h3>
+
+ <div class="method">
+ <h4>_attemptParseJSON()</h4>
+
+ </div>
+
+ <div class="method">
+ <h4>_attemptParseXML(onSuccess, onError)</h4>
+
+ </div>
+
+ <div class="method">
+ <h4>_success(succCallback, data)</h4>
+
+ </div>
+
+ <div class="method">
+ <h4>_error(errCallback, data)</h4>
+
+ </div>
+
+ </div>
+
+ </div>
+ </div>
+ </div>
+
+ </div>
+
+
+ </div>
+ </div>
+</body>
+</html>
View
85 docs/src/service.coffee.html
@@ -0,0 +1,85 @@
+<!doctype html>
+
+<!-- Documentation generated by [CoffeeDoc](http://github.com/omarkhan/coffeedoc) -->
+
+<html>
+<head>
+ <title>CoffeeDoc | service.coffee</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" media="all" href="../resources/base.css" />
+</head>
+<body>
+ <header>
+ <h1>service.coffee</h1>
+ </header>
+ <div class="container">
+ <div class="sidebar column">
+
+ <h4>Classes</h4>
+ <ul class="classlist">
+
+ <li><a href="#Service">Service</a></li>
+
+ </ul>
+
+
+ </div>
+ <div class="content column">
+
+ <div id="module-docstring">
+ <h1>Web Service for lipsum.org</h1>
+<p>Provides the low-level interface to the lipsum.org
+service.
+</p>
+
+ </div>
+
+
+ <div id="classes">
+ <h2>Classes</h2>
+
+ <div class="class">
+ <div class="header">
+ <a id="Service"><h3>Service</h3></a>
+
+ </div>
+ <div class="class-content">
+
+ <div class="methods">
+
+
+ <div class="instancemethods">
+ <h3>Instance Methods</h3>
+
+ <div class="method">
+ <h4>get(format, callback, queryOpts)</h4>
+ <p>Retrieves the lipsum text.
+
+</p>
+<p>format: {String} one of &quot;xml&quot; or &quot;json&quot;
+
+</p>
+<p>callback: {Function} called on successful text retrieval.
+ Should have one parameter to hold the response data.
+
+</p>
+<p>queryOpts: {Object} options to attach to the query portion of the url.
+</p>
+
+ </div>
+
+ </div>
+
+
+ </div>
+ </div>
+ </div>
+
+ </div>
+
+
+ </div>
+ </div>
+</body>
+</html>
View
10 lib/cli.js
@@ -1,6 +1,9 @@
// Generated by CoffeeScript 1.3.3
/*
# Lipsum Command-line Interface
+
+This module provides a CLI wrapper for the main module, allowing it to be
+easily used via anyone's login shell.
*/
var ArgumentParser, Lipsum;
@@ -39,6 +42,13 @@ exports.run = function(args) {
if (args == null) {
args = [];
}
+ /*
+ This will run the CLI
+
+ args: {Array} The arguments that would be passed to the CLI.
+ This is usually something like `process.argv.slice(2)`
+ */
+
argv = exports._optparser.parseArgs(args);
return exports._run(argv);
};
View
32 lib/lipsum.js
@@ -1,6 +1,10 @@
// Generated by CoffeeScript 1.3.3
/*
# Lorem Ipsum Wrapper
+
+Main entry point for the node-lipsum module. Provides wrappers for
+the Parser and Service classes as well as an easy method to get text
+from the lipsum.org service.
*/
var Lipsum, Parser, Service, events,
@@ -24,17 +28,37 @@ Lipsum = (function(_super) {
this.parserSuccessCallBack = __bind(this.parserSuccessCallBack, this);
this.getText = __bind(this.getText, this);
+
+ /* Class Constructor
+ */
this.parser = new Parser();
this.service = new Service();
}
Lipsum.prototype.defaults = {
+ /*
+ These parameters will be passed by default to lipsum.org in the query
+ */
+
amount: 5,
what: 'paras',
start: 'no'
};
Lipsum.prototype.getText = function(callback, opts) {
+ /*
+ Retrieves dummy text from lipsum.org
+
+ callback: {Function} Should take one parameter for the text
+ returned from lipsum.org. Called on successful retrieval
+ of said text.
+
+ opts: {Object} Options to pass onto the lipsum.org query. These will
+ be transformed into url query params, so if you pass in something
+ like {start: 'yes', what: 'bytes'} that will become
+ "?start=yes&what=bytes"
+ */
+
var prop, _i, _len, _ref;
if (!opts) {
opts = this.defaults;
@@ -54,14 +78,22 @@ Lipsum = (function(_super) {
};
Lipsum.prototype.parserSuccessCallBack = function(result) {
+ /* Called on successful parsing of returned dummy text.
+ */
return this.emit('lipsum', result.feed.lipsum);
};
Lipsum.prototype.parserErrorCallBack = function(err) {
+ /* Called on Parser Error.
+ */
throw new Error("Parser Error: " + err.message);
};
Lipsum.prototype.serviceCallback = function(text) {
+ /*
+ Called when the lipsum.org service succesfully retrieves
+ text from the lipsum.org service.
+ */
return this.parser.feed(text).parse(this.parserSuccessCallBack, this.parserErrorCallBack);
};
View
26 lib/parser.js
@@ -1,6 +1,8 @@
// Generated by CoffeeScript 1.3.3
/*
- Parser that detects whether input is XML or JSON and parses accordingly.
+ # Lipsum Parser
+
+ Detects whether input is XML or JSON and parses accordingly.
Parsing within the file provides the advantage of decoupling server calls with
calls to the parser, as it is able to be agnostic to the format received. It
cannot, however, parse HTML (nor should it have to).
@@ -31,18 +33,37 @@ LipsumParser = (function(_super) {
this.parse = __bind(this.parse, this);
this.feed = __bind(this.feed, this);
+
+ /* Instantiates the class with an optional payload
+ */
this._xmlParser = new XMLParser();
this._payload = payload != null ? payload : null;
this.parsedOutput = null;
}
LipsumParser.prototype.feed = function(payload) {
+ /*
+ Given a payload (which should be XML or JSON), it stores
+ this and then returns itself for chainability.
+ */
this.parsedOutput = null;
this._payload = payload;
return this;
};
LipsumParser.prototype.parse = function(successCallback, errCallback) {
+ /*
+ Parses the payload it was Given
+
+ successCallback: {Function} called on successful parse.
+ Takes one parameter that contains the parsed
+ output.
+
+ errCallback: {Function} called on parsing error from XML parser.
+ Note that this will be called even if the payload is JSON,
+ since JSON is attempted to be parsed first.
+ */
+
var errMsg, xmlErrCallback, xmlParseErrors, xmlSuccCallback,
_this = this;
successCallback = successCallback || function() {
@@ -55,7 +76,8 @@ LipsumParser = (function(_super) {
throw new ReferenceError("Nothing to parse.");
}
if (this.parsedOutput != null) {
- return this.parsedOutput;
+ this._success(successCallback, this.parsedOutput);
+ return;
}
this.parsedOutput = this._attemptParseJSON();
xmlParseErrors = null;
View
16 lib/service.js
@@ -1,8 +1,9 @@
// Generated by CoffeeScript 1.3.3
/*
- Web Service for lipsum.org
+ # Web Service for lipsum.org
- author: Travis Kaufman
+ Provides the low-level interface to the lipsum.org
+ service.
*/
var Service, http, url;
@@ -16,6 +17,17 @@ Service = (function() {
function Service() {}
Service.prototype.get = function(format, callback, queryOpts) {
+ /*
+ Retrieves the lipsum text.
+
+ format: {String} one of "xml" or "json"
+
+ callback: {Function} called on successful text retrieval.
+ Should have one parameter to hold the response data.
+
+ queryOpts: {Object} options to attach to the query portion of the url.
+ */
+
var endpoint, req, urlopts;
urlopts = {
protocol: 'http:',
View
3  package.json
@@ -22,7 +22,8 @@
"devDependencies": {
"jasmine-node": "1.0.x",
"shelljs": "0.0.x",
- "coffeelint": "0.4.x"
+ "coffeelint": "0.4.x",
+ "coffeedoc": "0.2.x"
},
"scripts": {
"test": "cake test"
View
9 src/cli.coffee
@@ -1,5 +1,8 @@
###
# Lipsum Command-line Interface
+
+This module provides a CLI wrapper for the main module, allowing it to be
+easily used via anyone's login shell.
###
Lipsum = require('./lipsum')
@@ -37,6 +40,12 @@ exports._optparser.addArgument(
)
exports.run = (args = []) ->
+ ###
+ This will run the CLI
+
+ args: {Array} The arguments that would be passed to the CLI.
+ This is usually something like `process.argv.slice(2)`
+ ###
argv = exports._optparser.parseArgs(args)
exports._run(argv)
View
26 src/lipsum.coffee
@@ -1,5 +1,9 @@
###
# Lorem Ipsum Wrapper
+
+Main entry point for the node-lipsum module. Provides wrappers for
+the Parser and Service classes as well as an easy method to get text
+from the lipsum.org service.
###
Service = require('./service')
@@ -8,15 +12,31 @@ events = require('events')
class Lipsum extends events.EventEmitter
constructor: ->
+ ### Class Constructor ###
@parser = new Parser()
@service = new Service()
defaults:
+ ###
+ These parameters will be passed by default to lipsum.org in the query
+ ###
amount: 5
what: 'paras'
start: 'no'
getText: (callback, opts) =>
+ ###
+ Retrieves dummy text from lipsum.org
+
+ callback: {Function} Should take one parameter for the text
+ returned from lipsum.org. Called on successful retrieval
+ of said text.
+
+ opts: {Object} Options to pass onto the lipsum.org query. These will
+ be transformed into url query params, so if you pass in something
+ like {start: 'yes', what: 'bytes'} that will become
+ "?start=yes&what=bytes"
+ ###
if not opts then opts = @defaults else
for prop in @defaults
opts[prop] = @defaults[prop] unless opts[prop]?
@@ -25,12 +45,18 @@ class Lipsum extends events.EventEmitter
@once('lipsum', (txt) -> callback(txt))
parserSuccessCallBack: (result) =>
+ ### Called on successful parsing of returned dummy text. ###
@emit('lipsum', result.feed.lipsum)
parserErrorCallBack: (err) ->
+ ### Called on Parser Error. ###
throw new Error("Parser Error: #{err.message}")
serviceCallback: (text) =>
+ ###
+ Called when the lipsum.org service succesfully retrieves
+ text from the lipsum.org service.
+ ###
@parser.feed(text).parse(@parserSuccessCallBack,
@parserErrorCallBack)
View
26 src/parser.coffee
@@ -1,5 +1,7 @@
###
- Parser that detects whether input is XML or JSON and parses accordingly.
+ # Lipsum Parser
+
+ Detects whether input is XML or JSON and parses accordingly.
Parsing within the file provides the advantage of decoupling server calls with
calls to the parser, as it is able to be agnostic to the format received. It
cannot, however, parse HTML (nor should it have to).
@@ -9,17 +11,32 @@ events = require('events')
class LipsumParser extends events.EventEmitter
constructor: (payload) ->
+ ### Instantiates the class with an optional payload ###
@_xmlParser = new XMLParser()
@_payload = if payload? then payload else null
@parsedOutput = null
feed: (payload) =>
+ ###
+ Given a payload (which should be XML or JSON), it stores
+ this and then returns itself for chainability.
+ ###
@parsedOutput = null
@_payload = payload
- # make chainable
- return this
+ this
parse: (successCallback, errCallback) =>
+ ###
+ Parses the payload it was Given
+
+ successCallback: {Function} called on successful parse.
+ Takes one parameter that contains the parsed
+ output.
+
+ errCallback: {Function} called on parsing error from XML parser.
+ Note that this will be called even if the payload is JSON,
+ since JSON is attempted to be parsed first.
+ ###
successCallback = successCallback or -> {}
errCallback = errCallback or -> {}
@@ -27,7 +44,8 @@ class LipsumParser extends events.EventEmitter
throw new ReferenceError("Nothing to parse.")
if @parsedOutput?
- return @parsedOutput
+ @_success(successCallback, @parsedOutput)
+ return
# First attempt to parse the JSON string
@parsedOutput = @_attemptParseJSON()
View
15 src/service.coffee
@@ -1,7 +1,8 @@
###
- Web Service for lipsum.org
+ # Web Service for lipsum.org
- author: Travis Kaufman
+ Provides the low-level interface to the lipsum.org
+ service.
###
http = require 'http'
@@ -10,6 +11,16 @@ url = require 'url'
class Service
get: (format, callback, queryOpts) ->
+ ###
+ Retrieves the lipsum text.
+
+ format: {String} one of "xml" or "json"
+
+ callback: {Function} called on successful text retrieval.
+ Should have one parameter to hold the response data.
+
+ queryOpts: {Object} options to attach to the query portion of the url.
+ ###
urlopts =
protocol: 'http:'
hostname: 'lipsum.lipsum.com'
Please sign in to comment.
Something went wrong with that request. Please try again.