Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Merge branch 'json-api-docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 27, 2012
2 parents 90fd70d + 7af2d6b commit 0e7dad3
Show file tree
Hide file tree
Showing 58 changed files with 3,131 additions and 2,230 deletions.
12 changes: 8 additions & 4 deletions Makefile
Expand Up @@ -92,7 +92,8 @@ test-npm-publish: node
npm_package_config_publishtest=true ./node deps/npm/test/run.js

apidoc_sources = $(wildcard doc/api/*.markdown)
apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html))
apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
$(addprefix out/,$(apidoc_sources:.markdown=.json))

apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets out/doc/about out/doc/community out/doc/logos out/doc/images

Expand All @@ -115,7 +116,7 @@ website_files = \
out/doc/logos/index.html \
$(doc_images)

doc: node $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs)
doc: node $(apidoc_dirs) $(website_files) $(apiassets) $(apidocs) tools/doc/

$(apidoc_dirs):
mkdir -p $@
Expand All @@ -126,8 +127,11 @@ out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
out/doc/%: doc/%
cp -r $< $@

out/doc/api/%.html: doc/api/%.markdown node $(apidoc_dirs) $(apiassets) tools/doctool/doctool.js
out/Release/node tools/doctool/doctool.js doc/template.html $< > $@
out/doc/api/%.json: doc/api/%.markdown
out/Release/node tools/doc/generate.js --format=json $< > $@

out/doc/api/%.html: doc/api/%.markdown
out/Release/node tools/doc/generate.js --format=html --template=doc/template.html $< > $@

website-upload: doc
rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
Expand Down
2 changes: 1 addition & 1 deletion doc/about/index.html
Expand Up @@ -102,7 +102,7 @@ <h1>Node's goal is to provide an easy way to build scalable
<p>But what about multiple-processor concurrency? Aren't
threads necessary to scale programs to multi-core computers?
You can start new processes via <code><a
href="http://nodejs.org/docs/latest/api/child_processes.html#child_process.fork">child_process.fork()</a></code>
href="http://nodejs.org/docs/latest/api/child_process.html#child_process.fork">child_process.fork()</a></code>
these other processes will be scheduled in parallel. For load
balancing incoming connections across multiple processes use
<a href="http://nodejs.org/docs/latest/api/cluster.html">the
Expand Down
10 changes: 4 additions & 6 deletions doc/api/_toc.markdown
@@ -1,5 +1,4 @@
## Table of Contents

* [About these Docs](documentation.html)
* [Synopsis](synopsis.html)
* [Globals](globals.html)
* [STDIO](stdio.html)
Expand All @@ -9,8 +8,8 @@
* [Process](process.html)
* [Utilities](util.html)
* [Events](events.html)
* [Buffers](buffers.html)
* [Streams](streams.html)
* [Buffer](buffer.html)
* [Stream](stream.html)
* [Crypto](crypto.html)
* [TLS/SSL](tls.html)
* [String Decoder](string_decoder.html)
Expand All @@ -26,7 +25,7 @@
* [Readline](readline.html)
* [REPL](repl.html)
* [VM](vm.html)
* [Child Processes](child_processes.html)
* [Child Processes](child_process.html)
* [Assertion Testing](assert.html)
* [TTY](tty.html)
* [ZLIB](zlib.html)
Expand All @@ -35,4 +34,3 @@
* [Cluster](cluster.html)
* Appendixes
* [Appendix 1: Recommended Third-party Modules](appendix_1.html)
* [Appendix 2: Deprecated API's](appendix_2.html)
18 changes: 9 additions & 9 deletions doc/api/addons.markdown
@@ -1,4 +1,4 @@
## Addons
# Addons

Addons are dynamically linked shared objects. They can provide glue to C and
C++ libraries. The API (at the moment) is rather complex, involving
Expand All @@ -24,7 +24,7 @@ compiling your module, you don't need to worry about linking to any of these
libraries.


### Hello world
## Hello world

To get started let's make a small Addon which is the C++ equivalent of
the following Javascript code:
Expand Down Expand Up @@ -129,7 +129,7 @@ In cases where there is more than one `.cc` file, simply add the file name to th
obj.source = ['addon.cc', 'myexample.cc']


#### Function arguments
### Function arguments

The following pattern illustrates how to read arguments from JavaScript
function calls and return a result. This is the main and only needed source
Expand Down Expand Up @@ -172,7 +172,7 @@ You can test it with the following JavaScript snippet:
console.log( 'This should be eight:', addon.add(3,5) );


#### Callbacks
### Callbacks

You can pass JavaScript functions to a C++ function and execute them from
there. Here's `addon.cc`:
Expand Down Expand Up @@ -209,7 +209,7 @@ To test it run the following JavaScript snippet:
});


#### Object factory
### Object factory

You can create and return new objects from within a C++ function with this
`addon.cc` pattern, which returns an object with property `msg` that echoes
Expand Down Expand Up @@ -245,7 +245,7 @@ To test it in JavaScript:
console.log(obj1.msg+' '+obj2.msg); // 'hello world'


#### Function factory
### Function factory

This pattern illustrates how to create and return a JavaScript function that
wraps a C++ function:
Expand Down Expand Up @@ -286,7 +286,7 @@ To test:
console.log(fn()); // 'hello world'


#### Wrapping C++ objects
### Wrapping C++ objects

Here we will create a wrapper for a C++ object/class `MyObject` that can be
instantiated in JavaScript through the `new` operator. First prepare the main
Expand Down Expand Up @@ -381,7 +381,7 @@ Test it with:
console.log( obj.plusOne() ); // 13


#### Factory of wrapped objects
### Factory of wrapped objects

This is useful when you want to be able to create native objects without
explicitly instantiating them with the `new` operator in JavaScript, e.g.
Expand Down Expand Up @@ -507,7 +507,7 @@ Test it with:
console.log( obj2.plusOne() ); // 23


#### Passing wrapped objects around
### Passing wrapped objects around

In addition to wrapping and returning C++ objects, you can pass them around
by unwrapping them with Node's `node::ObjectWrap::Unwrap` helper function.
Expand Down
12 changes: 4 additions & 8 deletions doc/api/all.markdown
@@ -1,16 +1,15 @@
@include documentation
@include synopsis
@include globals
@include stdio
@include timers
@include modules
@include addons
@include process
@include constants
@include util
@include freelist
@include events
@include buffers
@include streams
@include buffer
@include stream
@include crypto
@include tls
@include string_decoder
Expand All @@ -26,14 +25,11 @@
@include readline
@include repl
@include vm
@include child_processes
@include child_process
@include assert
@include tty
@include zlib
@include os
@include debugger
@include cluster

# Appendixes
@include appendix_1
@include appendix_2
2 changes: 1 addition & 1 deletion doc/api/appendix_1.markdown
@@ -1,4 +1,4 @@
## Appendix 1 - Third Party Modules
# Appendix 1 - Third Party Modules

There are many third party modules for Node. At the time of writing, August
2010, the master repository of modules is
Expand Down
Empty file removed doc/api/appendix_2.markdown
Empty file.
24 changes: 12 additions & 12 deletions doc/api/assert.markdown
@@ -1,41 +1,41 @@
## Assert
# 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)
## assert.fail(actual, expected, message, operator)

Throws an exception that displays the values for `actual` and `expected` separated by the provided operator.

### assert(value, message), assert.ok(value, [message])
## assert(value, message), assert.ok(value, [message])

Tests if value is a `true` value, it is equivalent to `assert.equal(true, value, message);`

### assert.equal(actual, expected, [message])
## assert.equal(actual, expected, [message])

Tests shallow, coercive equality with the equal comparison operator ( `==` ).

### assert.notEqual(actual, expected, [message])
## assert.notEqual(actual, expected, [message])

Tests shallow, coercive non-equality with the not equal comparison operator ( `!=` ).

### assert.deepEqual(actual, expected, [message])
## assert.deepEqual(actual, expected, [message])

Tests for deep equality.

### assert.notDeepEqual(actual, expected, [message])
## assert.notDeepEqual(actual, expected, [message])

Tests for any deep inequality.

### assert.strictEqual(actual, expected, [message])
## assert.strictEqual(actual, expected, [message])

Tests strict equality, as determined by the strict equality operator ( `===` )

### assert.notStrictEqual(actual, expected, [message])
## assert.notStrictEqual(actual, expected, [message])

Tests strict non-equality, as determined by the strict not equal operator ( `!==` )

### assert.throws(block, [error], [message])
## assert.throws(block, [error], [message])

Expects `block` to throw an error. `error` can be constructor, regexp or
validation function.
Expand Down Expand Up @@ -72,11 +72,11 @@ Custom error validation:
"unexpected error"
);

### assert.doesNotThrow(block, [error], [message])
## assert.doesNotThrow(block, [error], [message])

Expects `block` not to throw an error, see assert.throws for details.

### assert.ifError(value)
## assert.ifError(value)

Tests if value is not a false value, throws if it is a true value. Useful when
testing the first argument, `error` in callbacks.

0 comments on commit 0e7dad3

Please sign in to comment.