doc refactor: vm
authorisaacs <i@izs.me>
Mon, 27 Feb 2012 19:09:35 +0000 (11:09 -0800)
committerisaacs <i@izs.me>
Thu, 1 Mar 2012 00:04:55 +0000 (16:04 -0800)
doc/api/vm.markdown

index 3d3c168..dfcf350 100644 (file)
@@ -1,4 +1,6 @@
-## Executing JavaScript
+# Executing JavaScript
+
+<!--name=vm-->
 
 You can access this module with:
 
@@ -7,7 +9,7 @@ You can access this module with:
 JavaScript code can be compiled and run immediately or compiled, saved, and run later.
 
 
-### vm.runInThisContext(code, [filename])
+## vm.runInThisContext(code, [filename])
 
 `vm.runInThisContext()` compiles `code`, runs it and returns the result. Running
 code does not have access to local scope. `filename` is optional, it's used only
@@ -37,7 +39,7 @@ In case of syntax error in `code`, `vm.runInThisContext` emits the syntax error
 and throws an exception.
 
 
-### vm.runInNewContext(code, [sandbox], [filename])
+## vm.runInNewContext(code, [sandbox], [filename])
 
 `vm.runInNewContext` compiles `code`, then runs it in `sandbox` and returns the
 result. Running code does not have access to local scope. The object `sandbox`
@@ -66,7 +68,7 @@ requires a separate process.
 In case of syntax error in `code`, `vm.runInNewContext` emits the syntax error to stderr
 and throws an exception.
 
-### vm.runInContext(code, context, [filename])
+## vm.runInContext(code, context, [filename])
 
 `vm.runInContext` compiles `code`, then runs it in `context` and returns the
 result. A (V8) context comprises a global object, together with a set of
@@ -100,14 +102,14 @@ requires a separate process.
 In case of syntax error in `code`, `vm.runInContext` emits the syntax error to stderr
 and throws an exception.
 
-### vm.createContext([initSandbox])
+## vm.createContext([initSandbox])
 
 `vm.createContext` creates a new context which is suitable for use as the 2nd argument of a subsequent
 call to `vm.runInContext`. A (V8) context comprises a global object together with a set of
 build-in objects and functions. The optional argument `initSandbox` will be shallow-copied
 to seed the initial contents of the global object used by the context.
 
-### vm.createScript(code, [filename])
+## vm.createScript(code, [filename])
 
 `createScript` compiles `code` but does not run it. Instead, it returns a
 `vm.Script` object representing this compiled code. This script can be run
@@ -119,6 +121,10 @@ In case of syntax error in `code`, `createScript` prints the syntax error to std
 and throws an exception.
 
 
+## Class: Script
+
+A class for running scripts.  Returned by vm.createScript.
+
 ### script.runInThisContext()
 
 Similar to `vm.runInThisContext` but a method of a precompiled `Script` object.