Skip to content

Commit

Permalink
update backbone/underscore docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nsfmc committed Feb 3, 2012
1 parent cefc6dc commit d16a272
Show file tree
Hide file tree
Showing 9 changed files with 1,981 additions and 1,222 deletions.
66 changes: 35 additions & 31 deletions docs/backbone-min.js

Large diffs are not rendered by default.

889 changes: 666 additions & 223 deletions docs/backbone.html

Large diffs are not rendered by default.

914 changes: 522 additions & 392 deletions docs/backbone.js

Large diffs are not rendered by default.

883 changes: 493 additions & 390 deletions docs/docs/backbone.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/todos.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<span class="p">},</span></pre></div> </td> </tr> <tr id="section-37"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-37">&#182;</a> </div> <p>Add a single todo item to the list by creating a view for it, and
appending its element to the <code>&lt;ul&gt;</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">addOne</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">todo</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">view</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">TodoView</span><span class="p">({</span><span class="nx">model</span><span class="o">:</span> <span class="nx">todo</span><span class="p">});</span>
<span class="k">this</span><span class="p">.</span><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#todo-list&quot;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">view</span><span class="p">.</span><span class="nx">render</span><span class="p">().</span><span class="nx">el</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#todo-list&quot;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">view</span><span class="p">.</span><span class="nx">render</span><span class="p">().</span><span class="nx">el</span><span class="p">);</span>
<span class="p">},</span></pre></div> </td> </tr> <tr id="section-38"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-38">&#182;</a> </div> <p>Add all items in the <strong>Todos</strong> collection at once.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">addAll</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">Todos</span><span class="p">.</span><span class="nx">each</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">addOne</span><span class="p">);</span>
<span class="p">},</span></pre></div> </td> </tr> <tr id="section-39"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-39">&#182;</a> </div> <p>If you hit return in the main input field, and there is text to save,
Expand Down
232 changes: 117 additions & 115 deletions docs/docs/underscore.html

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions docs/underscore-min.js

Large diffs are not rendered by default.

98 changes: 84 additions & 14 deletions docs/underscore.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
width: 550px;
margin: 40px 0 50px 260px;
}
div.warning {
margin-top: 15px;
font: bold 11px Arial;
color: #770000;
}
p {
margin: 20px 0;
width: 550px;
Expand Down Expand Up @@ -129,7 +134,7 @@
<div id="sidebar" class="interface">

<a class="toc_title" href="#">
Underscore.js <span class="version">(1.2.4)</span>
Underscore.js <span class="version">(1.3.1)</span>
</a>

<a class="toc_title" href="#">
Expand Down Expand Up @@ -206,15 +211,17 @@
<ul class="toc_section">
<li>- <a href="#keys">keys</a></li>
<li>- <a href="#values">values</a></li>
<li>- <a href="#functions">functions</a></li>
<li>- <a href="#object-functions">functions</a></li>
<li>- <a href="#extend">extend</a></li>
<li>- <a href="#defaults">defaults</a></li>
<li>- <a href="#clone">clone</a></li>
<li>- <a href="#tap">tap</a></li>
<li>- <a href="#has">has</a></li>
<li>- <a href="#isEqual">isEqual</a></li>
<li>- <a href="#isEmpty">isEmpty</a></li>
<li>- <a href="#isElement">isElement</a></li>
<li>- <a href="#isArray">isArray</a></li>
<li>- <a href="#isObject">isObject</a></li>
<li>- <a href="#isArguments">isArguments</a></li>
<li>- <a href="#isFunction">isFunction</a></li>
<li>- <a href="#isString">isString</a></li>
Expand Down Expand Up @@ -311,14 +318,16 @@ <h2>Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and u

<table>
<tr>
<td><a href="underscore.js">Development Version (1.2.4)</a></td>
<td><a href="underscore.js">Development Version (1.3.1)</a></td>
<td><i>34kb, Uncompressed with Comments</i></td>
</tr>
<tr>
<td><a href="underscore-min.js">Production Version (1.2.4)</a></td>
<td><a href="underscore-min.js">Production Version (1.3.1)</a></td>
<td><i>&lt; 4kb, Minified and Gzipped</i></td>
</tr>
</table>

<div class="warning">Upgrade warning: version 1.3.0 removes AMD (RequireJS) support.</div>

<div id="documentation">

Expand All @@ -343,6 +352,7 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>

<p id="map">
<b class="header">map</b><code>_.map(list, iterator, [context])</code>
<span class="alias">Alias: <b>collect</b></span>
<br />
Produces a new array of values by mapping each value in <b>list</b>
through a transformation function (<b>iterator</b>). If the native <b>map</b> method
Expand Down Expand Up @@ -514,8 +524,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<p id="sortBy">
<b class="header">sortBy</b><code>_.sortBy(list, iterator, [context])</code>
<br />
Returns a sorted copy of <b>list</b>, ranked by the results of running
each value through <b>iterator</b>.
Returns a sorted copy of <b>list</b>, ranked in ascending order by the
results of running each value through <b>iterator</b>.
</p>
<pre>
_.sortBy([1, 2, 3, 4, 5, 6], function(num){ return Math.sin(num); });
Expand Down Expand Up @@ -569,8 +579,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
real Array. Useful for transmuting the <b>arguments</b> object.
</p>
<pre>
(function(){ return _.toArray(arguments).slice(0); })(1, 2, 3);
=&gt; [1, 2, 3]
(function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
=&gt; [2, 3, 4]
</pre>

<p id="size">
Expand Down Expand Up @@ -649,13 +659,17 @@ <h2 id="arrays">Array Functions</h2>
</pre>

<p id="flatten">
<b class="header">flatten</b><code>_.flatten(array)</code>
<b class="header">flatten</b><code>_.flatten(array, [shallow])</code>
<br />
Flattens a nested <b>array</b> (the nesting can be to any depth).
Flattens a nested <b>array</b> (the nesting can be to any depth). If you
pass <b>shallow</b>, the array will only be flattened a single level.
</p>
<pre>
_.flatten([1, [2], [3, [[[4]]]]]);
_.flatten([1, [2], [3, [[4]]]]);
=&gt; [1, 2, 3, 4];

_.flatten([1, [2], [3, [[4]]]], true);
=&gt; [1, 2, 3, [[4]]];
</pre>

<p id="without">
Expand Down Expand Up @@ -975,7 +989,7 @@ <h2 id="objects">Object Functions</h2>
=&gt; [1, 2, 3]
</pre>

<p id="functions">
<p id="object-functions">
<b class="header">functions</b><code>_.functions(object)</code>
<span class="alias">Alias: <b>methods</b></span>
<br />
Expand Down Expand Up @@ -1037,6 +1051,19 @@ <h2 id="objects">Object Functions</h2>
.value();
=&gt; [2, 200]
=&gt; [4, 40000]
</pre>

<p id="has">
<b class="header">has</b><code>_.has(object, key)</code>
<br />
Does the object contain the given key? Identical to
<tt>object.hasOwnProperty(key)</tt>, but uses a safe reference to the
<tt>hasOwnProperty</tt> function, in case it's been
<a href="http://www.devthought.com/2012/01/18/an-object-is-not-a-hash/">overridden accidentally</a>.
</p>
<pre>
_.has({a: 1, b: 2, c: 3}, "b");
=&gt; true
</pre>

<p id="isEqual">
Expand Down Expand Up @@ -1086,6 +1113,18 @@ <h2 id="objects">Object Functions</h2>
=&gt; false
_.isArray([1,2,3]);
=&gt; true
</pre>

<p id="isObject">
<b class="header">isObject</b><code>_.isObject(value)</code>
<br />
Returns <i>true</i> if <b>value</b> is an Object.
</p>
<pre>
_.isObject({});
=&gt; true
_.isObject(1);
=&gt; false
</pre>

<p id="isArguments">
Expand Down Expand Up @@ -1197,7 +1236,7 @@ <h2 id="objects">Object Functions</h2>
_.isUndefined(window.missingVariable);
=&gt; true
</pre>

<h2 id="utility">Utility Functions</h2>

<p id="noConflict">
Expand Down Expand Up @@ -1252,6 +1291,7 @@ <h2 id="utility">Utility Functions</h2>
<br />
Generate a globally-unique id for client-side models or DOM elements
that need one. If <b>prefix</b> is passed, the id will be appended to it.
Without <b>prefix</b>, returns an integer.
</p>
<pre>
_.uniqueId('contact_');
Expand Down Expand Up @@ -1458,6 +1498,36 @@ <h2 id="links">Links &amp; Suggested Reading</h2>

<h2 id="changelog">Change Log</h2>

<p>
<b class="header">1.3.1</b> &mdash; <small><i>Jan. 23, 2012</i></small><br />
<ul>
<li>
Added an <tt>_.has</tt> function, as a safer way to use <tt>hasOwnProperty</tt>.
</li>
<li>
Added <tt>_.collect</tt> as an alias for <tt>_.map</tt>. Smalltalkers, rejoice.
</li>
<li>
Reverted an old change so that <tt>_.extend</tt> will correctly copy
over keys with undefined values again.
</li>
<li>
Bugfix to stop escaping slashes within interpolations in <tt>_.template</tt>.
</li>
</ul>
</p>

<p>
<b class="header">1.3.0</b> &mdash; <small><i>Jan. 11, 2012</i></small><br />
<ul>
<li>
Removed AMD (RequireJS) support from Underscore. If you'd like to use
Underscore with RequireJS, you can load it as a normal script, wrap
or patch your copy, or download a forked version.
</li>
</ul>
</p>

<p>
<b class="header">1.2.4</b> &mdash; <small><i>Jan. 4, 2012</i></small><br />
<ul>
Expand Down Expand Up @@ -1850,7 +1920,7 @@ <h2 id="changelog">Change Log</h2>
like so: <tt>_([1, 2, 3]).map(...);</tt>. Original patch provided by
<a href="http://macournoyer.com/">Marc-André Cournoyer</a>.
Wrapped objects can be chained through multiple
method invocations. A <a href="#functions"><tt>functions</tt></a> method
method invocations. A <a href="#object-functions"><tt>functions</tt></a> method
was added, providing a sorted list of all the functions in Underscore.
</p>

Expand Down
Loading

0 comments on commit d16a272

Please sign in to comment.