From ee3026797c00e84ae13ab216da7f54835404e6a3 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 9 Apr 2010 15:34:08 -0700 Subject: [PATCH] More documentation work. Remove long lines --- Makefile | 1 + doc/api.markdown | 103 ++++++++++++-------------------------------- doc/api_header.html | 20 +++------ 3 files changed, 34 insertions(+), 90 deletions(-) diff --git a/Makefile b/Makefile index 36a518d082..b2c0cfc623 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ benchmark: all # gem install ronn doc: doc/node.1 doc/api.html doc/index.html doc/changelog.html +## HACK to give the ronn-generated page a TOC doc/api.html: doc/api.markdown ronn -f --html doc/api.markdown \ | sed "s/

\(.*\)<\/h2>/

\1<\/h2>/g" \ diff --git a/doc/api.markdown b/doc/api.markdown index 3038d16c2a..c59ac55a09 100644 --- a/doc/api.markdown +++ b/doc/api.markdown @@ -251,20 +251,20 @@ Closes the underlying file descriptor. Stream will not emit any more events. A **writable stream** has the following methods, members, and events. -### Event 'drain' +### Event: 'drain' `function () { }` Emitted after a `write()` method was called that returned `false` to indicate that it is safe to write again. -### Event 'error' +### Event: 'error' `function (exception) { }` Emitted on error with the exception `e`. -### Event 'close' +### Event: 'close' `function () { }` @@ -400,6 +400,7 @@ Example of listening for `SIGINT`: An easy way to send the `SIGINT` signal is with `Control-C` in most terminal programs. + ### process.stdout A writable stream to `stdout`. @@ -508,13 +509,6 @@ Returns the current working directory of the process. An object containing the user environment. See environ(7). - // print process.env - var sys = require('sys'); - - Object.getOwnPropertyNames(process.env).forEach(function (val, index, array) { - sys.puts(index + ': ' + val + '=' + process.env[val]); - }); - ### process.evalcx(code, sandbox, filename) @@ -741,45 +735,14 @@ Example of inspecting all properties of the `sys` object: To schedule execution of `callback` after `delay` milliseconds. Returns a `timeoutId` for possible use with `clearTimeout()`. - var sys = require('sys'), - start = new Date(), - timer = setTimeout(function () { - sys.puts('Timer fired after ' + (Date.now() - start) + 'ms'); - }, 1000); - - sys.puts('Started timer.'); - -Optionally, you can pass arguments to the callback. - - var sys = require('sys'), - start = new Date(), - timer = setTimeout(function (start_time, message) { - sys.puts(message + (Date.now() - start_time) + 'ms'); - }, 1000, start, 'Timer fired after '); - - sys.puts('Started timer.'); - -These two examples generate the same output. - ### clearTimeout(timeoutId) Prevents a timeout from triggering. - var sys = require('sys'), - start = new Date(), - timer1 = setTimeout(function () { - sys.puts('Timer fired after ' + (Date.now() - start) + 'ms'); - }, 5000), - timer2 = setTimeout(function () { - sys.puts('This is taking too long. Stopping timer1.'); - clearTimeout(timer1); - }, 1000); - - sys.puts('Started timers.'); - ### setInterval(callback, delay, [arg, ...]) -To schedule the repeated execution of `callback` every `delay` milliseconds. Returns a `intervalId` for possible use with `clearInterval()`. +To schedule the repeated execution of `callback` every `delay` milliseconds. +Returns a `intervalId` for possible use with `clearInterval()`. Optionally, you can also pass arguments to the callback. @@ -787,19 +750,6 @@ Optionally, you can also pass arguments to the callback. Stops a interval from triggering. - var sys = require('sys'), - start = new Date(), - count = 10, - timer = setInterval(function () { - count -= 1; - sys.puts('Timer fired after ' + (Date.now() - start) + 'ms ' + count + ' remaining.'); - if (count === 0) { - clearInterval(timer); - } - }, 100); - - sys.puts('Started timer.'); - ## Child Processes @@ -816,7 +766,7 @@ Child processes always have three streams associated with them. `child.stdin`, `ChildProcess` is an EventEmitter. -### Event 'exit' +### Event: 'exit' `function (code) {} ` @@ -1694,9 +1644,9 @@ chunked, this will send the terminating `'0\r\n\r\n'`. This object is created when making a request with `http.Client`. It is passed to the `'response'` event of the request object. -The response implements the stream interface. +The response implements the **readable stream** interface. -### Event 'data' +### Event: 'data' `function (chunk) {}` @@ -1829,24 +1779,25 @@ and passed to the user through the `'connection'` event of a server. `function () { }` -Call once the stream is established after a call to `createConnection()` or -`connect()`. +Emitted when a stream connection successfully is established. +See `connect()`. + ### Event: 'data' `function (data) { }` -Called when data is received on the stream. `data` -will be a string. Encoding of data is set by `stream.setEncoding()`. +Emitted when data is received. The argument `data` will be a `Buffer` or +`String`. Encoding of data is set by `stream.setEncoding()`. +(See the section on Readable Streams for more infromation.) ### Event: 'end' `function () { }` -Called when the other end of the stream sends a FIN -packet. After this is emitted the `readyState` will be -`'writeOnly'`. One should probably just call -`stream.end()` when this event is emitted. +Emitted when the other end of the stream sends a FIN packet. After this is +emitted the `readyState` will be `'writeOnly'`. One should probably just +call `stream.end()` when this event is emitted. ### Event: 'timeout' @@ -1874,7 +1825,7 @@ following this event. Emitted once the stream is fully closed. The argument `had_error` is a boolean which says if the stream was closed due to a transmission -error. +error. ### net.createConnection(port, host='127.0.0.1') @@ -1958,7 +1909,7 @@ algorithm, they buffer data before sending it off. Setting `noDelay` will immediately fire off data each time `stream.write()` is called. -## DNS module +## DNS Use `require('dns')` to access this module. @@ -2049,9 +2000,10 @@ Each DNS query can return an error code. - `dns.BADQUERY`: the query is malformed. -## Assert Module +## Assert -This module is used for writing unit tests for your applications, you can access it with `require('assert')`. +This module is used for writing unit tests for your applications, you can +access it with `require('assert')`. ### assert.fail(actual, expected, message, operator) @@ -2094,7 +2046,7 @@ Expects `block` to throw an error. Expects `block` not to throw an error. -## Path Module +## Path This module contains utilities for dealing with file paths. Use `require('path')` to use it. It provides the following methods: @@ -2165,9 +2117,10 @@ Test whether or not the given path exists. Then, call the `callback` argument w }); -## URL Module +## URL This module has utilities for URL resolution and parsing. +Call `require('url')` to use it. Parsed URL objects have some or all of the following fields, depending on whether or not they exist in the URL string. Any parts that are not in the URL @@ -2177,7 +2130,7 @@ string will not be in the parsed object. Examples are shown for the URL - `href` - The full URL that was originally parsed. Example: + The full URL that was originally parsed. Example: `'http://user:pass@host.com:8080/p/a/t/h?query=string#hash'` - `protocol` @@ -2235,7 +2188,7 @@ Take a parsed URL object, and return a formatted URL string. Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. -## Query String Module +## Query String This module provides utilities for dealing with query strings. It provides the following methods: diff --git a/doc/api_header.html b/doc/api_header.html index b25a908d2a..e3338bc95e 100644 --- a/doc/api_header.html +++ b/doc/api_header.html @@ -11,7 +11,7 @@ line-height:1.3; color:#343331; background:#fff; } - #man { max-width:89ex; text-align:justify; margin:0 25px 25px 25px } + #man { max-width:89ex; text-align:justify; margin:0 25px 25px 10px } #man h1, #man h2, #man h3 { color:#232221;clear:left } #man h1 { font-size:28px; margin:15px 0 30px 0; text-align:center } #man h2 { font-size:18px; margin-bottom:0; margin-top:10px; line-height:1.3; } @@ -50,26 +50,18 @@ #man ol.man a:hover { color:#333231 } -body { - background:#fff; - color:#333; - font-family:helvetica; - font-size:14px; - line-height:1.3em; - padding:25px; -} - + #man { width: 50%; margin: 0 0 0 22em; } - + #toc { position: fixed; left: 0; top: 0; bottom: 0; - width: 20em; + width: 15em; border-right: 1px solid #ccc; overflow: auto; } @@ -84,8 +76,6 @@ body { } #toc ul li { margin: 0; - border: 1px solid #ccc; - border-width: 1px 0 0; } #toc ul li a { padding: 0.2em 0.4em; @@ -133,7 +123,7 @@ body {
-
Node.js v0.1.90
+
Node v0.1.90