[seed] Add documentation for sandbox module



commit 7355d21231b6944369ecb28e45927a93c31774b4
Author: Robert Carr <racarr svn gnome org>
Date:   Mon May 11 17:19:22 2009 -0400

    Add documentation for sandbox module
---
 configure.ac                |    1 +
 doc/modules/Makefile.am     |    4 +-
 doc/modules/sandbox.html.in |   66 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index a4de09f..39275d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -284,6 +284,7 @@ doc/modules/canvas.html
 doc/modules/multiprocessing.html
 doc/modules/readline.html
 doc/modules/sqlite.html
+doc/modules/sandbox.html
 
 doc/mapping/mapping.html
 
diff --git a/doc/modules/Makefile.am b/doc/modules/Makefile.am
index 979bfaa..66b94c8 100644
--- a/doc/modules/Makefile.am
+++ b/doc/modules/Makefile.am
@@ -1,7 +1,7 @@
 modulesdir=$(datadir)/doc/seed/modules
 modules_DATA = \
-	readline.html canvas.html multiprocessing.html sqlite.html
+	readline.html canvas.html multiprocessing.html sqlite.html sandbox.html
 EXTRA_DIST = \
-	readline.html.in canvas.html.in multiprocessing.html.in sqlite.html.in
+	readline.html.in canvas.html.in multiprocessing.html.in sqlite.html.in sandbox.html
 
 
diff --git a/doc/modules/sandbox.html.in b/doc/modules/sandbox.html.in
new file mode 100644
index 0000000..bd143e5
--- /dev/null
+++ b/doc/modules/sandbox.html.in
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml"; lang="en" xml:lang="en">
+<head>
+	<title>Seed sandbox Module Documentation</title>
+	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+	<link rel="stylesheet" href="../style.css" type="text/css" charset="utf-8" />
+	<script type="text/javascript" src="../sh.js"></script>
+    <script type="text/javascript" src="../sh_js.js"></script>
+    <link type="text/css" rel="stylesheet" href="../sh.css" />
+</head>
+<body onload="sh_highlightDocument();">
+<div id="header">Seed <i>sqlite</i> Module</div>
+<div id="subheader">v  VERSION@</div>
+<div class="section"><b>Usage</b></div>
+<p>
+In order to use functions from the sandbox module, you must first import it.
+</p>
+<pre class="sh_javascript">
+sandbox = imports.sandbox;
+</pre>
+<div class="section"><b>new sandbox.Context</b>()</div>
+<p>
+Creates a new sandbox context object, which wraps a Seed JavaScript context with it's own global object. By default this global object contains only default JSCore globals (Array, Object, etc..) and has no ability to interact with the outside system. Note the context must be manually destroyed with the <b>destroy</b> method (due to the finer points of garbage collection).
+</p>
+<pre class="sh_javascript">
+var context = new sandbox.Context();
+// Do things.
+context.destroy();
+</pre>
+<div class="section">context.<b>eval</b>(source)</div>
+Evaluates a string <i>source</i> with <i>context</i>, returns the result.
+<pre class="sh_javascript">
+context = new sandbox.Context();
+result = context.eval("2+2");
+</pre>
+<div class="section">context.<b>add_globals</b>()</div>
+<p>
+Adds the default Seed globals to the context, including the "Seed" global object, and the imports object.
+</p>
+<pre class="sh_javascript">
+context.add_globals();
+</pre>
+
+<div class="section">context.<b>destroy</b>()</div>
+<p>
+Destroys the internal context object, and any further usage of the wrapper is an exception.
+</p>
+<pre class="sh_javascript">
+context.destroy();
+</pre>
+<div class="section">context.<b>global</b></div>
+<p>
+A property representing the literal global object of the context. May be freely read from and assigned to.
+</p>
+<pre class="sh_javascript">
+context = new sandbox.Context();
+context.global.WindowType = Gtk.WindowType;
+
+context.eval("b = WindowType.NORMAL;");
+if (context.global.b == Gtk.WindowType.NORMAL){
+   Seed.print("Everything works!");
+}
+</pre>
+</body>
+</html>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]