Reorganize site to make room for documenting the other built-in modules.

This commit is contained in:
Bob Nystrom
2015-11-08 13:31:22 -08:00
parent 8c0dae1320
commit 82706b74fc
52 changed files with 771 additions and 178 deletions

View File

@ -1,9 +1,10 @@
^title Classes
^category guide
Every value in Wren is an object, and every object is an instance of a class.
Even `true` and `false` are full-featured objects—instances of the
[`Bool`](core/bool.html) class.
[Bool][] class.
[bool]: modules/core/bool.html
Classes define an objects *behavior* and *state*. Behavior is defined by
[*methods*][method calls] which live in the class. Every object of the same

View File

@ -1,5 +1,4 @@
^title Concurrency
^category guide
Lightweight concurrency is a key feature of Wren and it is expressed using
*fibers*. They control how all code is executed, and take the place of

View File

@ -1,5 +1,4 @@
^title Control Flow
^category guide
Control flow is used to determine which chunks of code are executed and how many
times. *Branching* statements and expressions decide whether or not to execute

View File

@ -1,5 +1,4 @@
^title Embedding API
^category reference
Wren is designed to be a scripting language, so the embedding API is as
important as any of its language features. There are two (well, three) ways to

View File

@ -1,5 +1,4 @@
^title Error Handling
^category guide
Errors come in a few fun flavors.
@ -165,5 +164,5 @@ For example, a method for parsing a number could return a number on success and
`null` to indicate parsing failed. Since Wren is dynamically typed, it's easy
and natural for a method to return different types of values.
<a class="right" href="modules.html">Modules &rarr;</a>
<a class="right" href="modularity.html">Modularity &rarr;</a>
<a href="concurrency.html">&larr; Concurrency</a>

View File

@ -1,5 +1,4 @@
^title Functions
^category guide
No self-respecting language today can get by without functions&mdash;first
class little bundles of code. Since Wren is object-oriented, most of your code

View File

@ -1,5 +1,4 @@
^title Lists
^category guide
A list is a compound object that holds a collection of elements identified by
integer index. You can create a list by placing a sequence of comma-separated

View File

@ -1,5 +1,4 @@
^title Maps
^category guide
A map is an *associative* collection. It holds a set of entries, each of which
maps a *key* to a *value*. The same data structure has a variety of names in
@ -117,7 +116,7 @@ For that, map exposes two methods: `keys` and `values`.
The first returns a [Sequence][] that [iterates][] over all of the keys in the
map, and the second returns one that iterates over the values.
[sequence]: core/sequence.html
[sequence]: modules/core/sequence.html
[iterates]: control-flow.html#the-iterator-protocol
If you want to see all of the key-value pairs in a map, the easiest way is to

View File

@ -1,5 +1,4 @@
^title Method Calls
^category guide
Wren is deeply object oriented, so most code consists of invoking methods on
objects, usually something like this:
@ -34,11 +33,11 @@ methods with the same *name*, as long as they have different *signatures*. The
signature includes the method's name along with the number of arguments it
takes. In technical terms, this means you can *overload by arity*.
<!-- TODO: Link to Random. -->
For example, the [Random][] class has two methods for getting a random integer.
One takes a minimum and maximum value and returns a value in that range. The
other only takes a maximum value and uses 0 as the minimum:
For example, the Random class has two methods for getting a random integer. One
takes a minimum and maximum value and returns a value in that range. The other
only takes a maximum value and uses 0 as the minimum:
[random]: modules/random/random.html
:::wren
var random = Random.new()
@ -143,7 +142,7 @@ it to tell if an object is an instance of a given class. You'll rarely need to,
but you can override `is` in your own classes. That can be useful for things
like mocks or proxies where you want an object to masquerade as a certain class.
[object]: core/object.html
[object]: modules/core/object.html
## Subscripts

View File

@ -1,5 +1,4 @@
^title Modules
^category guide
^title Modularity
Once you start writing programs that are more than little toys, you quickly run
into two problems:
@ -52,7 +51,8 @@ performs:
1. Locate the source code for the module.
2. Execute the imported module's code.
3. Bind new variables in the importing module to values defined in the imported module.
3. Bind new variables in the importing module to values defined in the imported
module.
We'll go through each step:
@ -110,9 +110,11 @@ valid separator on Windows, but backslashes are not valid on other OSes.)
## Executing the module
Once we have the source code for a module, we need to run it. First, the VM
takes the fiber that is executing the `import` statement in the importing
takes the [fiber][] that is executing the `import` statement in the importing
module and pauses it.
[fiber]: concurrency.html
Then it creates a new module object&mdash;a new fresh top-level scope,
basically&mdash;and a new fiber. It executes the new module's code in that
fiber and scope. The module can run whatever imperative code it wants and
@ -157,7 +159,7 @@ rarely makes a difference.
## Shared imports
Earlier, I described a programs set of modules as a tree. Of course, it's only
Earlier, I described a program's set of modules as a tree. Of course, it's only
a *tree* of modules if there are no *shared imports*. But consider a program
like:

View File

@ -1,7 +1,8 @@
^title Bool Class
^category core
Boolean values. There are two instances, `true` and `false`.
Boolean [values][]. There are two instances, `true` and `false`.
[values]: ../../values.html
## Methods

View File

@ -1,5 +1,6 @@
^title Class Class
^category core
**TODO**
## Methods

View File

@ -1,9 +1,8 @@
^title Fiber Class
^category core
A lightweight coroutine. [Here][fibers] is a gentle introduction.
[fibers]: ../concurrency.html
[fibers]: ../../concurrency.html
### Fiber.**new**(function)

View File

@ -1,8 +1,9 @@
^title Fn Class
^category core
A first class function&mdash;an object that wraps an executable chunk of code.
[Here](../functions.html) is a friendly introduction.
[Here][functions] is a friendly introduction.
[functions]: ../../functions.html
### Fn.**new**(function)

View File

@ -1,8 +1,7 @@
^title Core Library
^category core
^title Core Module
Because Wren is designed for [embedding in applications][embedding], its core
library is minimal and is focused on working with objects within Wren. For
module is minimal and is focused on working with objects within Wren. For
stuff like file IO, graphics, etc., it is up to the host application to provide
interfaces for this.
@ -22,4 +21,4 @@ All Wren source files automatically have access to the following classes:
* [String](string.html)
* [System](system.html)
[embedding]: ../embedding-api.html
[embedding]: ../../embedding-api.html

View File

@ -1,9 +1,10 @@
^title List Class
^category core
Extends [Sequence](sequence.html).
An indexable contiguous collection of elements. More details [here](../lists.html).
An indexable contiguous collection of elements. More details [here][lists].
[lists]: ../../lists.html
## Methods
@ -52,8 +53,10 @@ It is a runtime error if the index is not an integer or is out of bounds.
### **iterate**(iterator), **iteratorValue**(iterator)
Implements the [iterator protocol](../control-flow.html#the-iterator-protocol)
for iterating over the elements in the list.
Implements the [iterator protocol][] for iterating over the elements in the
list.
[iterator protocol]: ../../control-flow.html#the-iterator-protocol
### **removeAt**(index)

View File

@ -1,5 +1,4 @@
^title Map Class
^category core
An associative collection that maps keys to values. More details [here](../maps.html).

View File

@ -1,5 +1,4 @@
^title Null Class
^category core
## Methods

View File

@ -1,5 +1,4 @@
^title Num Class
^category core
## Static Methods

View File

@ -1,5 +1,4 @@
^title Object Class
^category core
## Static Methods

View File

@ -1,5 +1,4 @@
^title Range Class
^category core
A range defines a bounded range of values from a starting point to a possibly
exclusive endpoint. [Here](../range.html) is a friendly introduction.

View File

@ -1,10 +1,9 @@
^title Sequence Class
^category core
An abstract base class for any iterable object. Any class that implements the
core [iterator protocol][] can extend this to get a number of helpful methods.
[iterator protocol]: ../control-flow.html#the-iterator-protocol
[iterator protocol]: ../../control-flow.html#the-iterator-protocol
## Methods
@ -25,9 +24,11 @@ and returns the value. Otherwise, returns `true`.
Tests whether any element in the sequence passes the `predicate`.
Iterates over the sequence, passing each element to the function `predicate`.
If it returns something [true](../control-flow.html#truth), stops iterating and
If it returns something [true][], stops iterating and
returns that value. Otherwise, returns `false`.
[true]: ../../control-flow.html#truth
:::wren
System.print([1, 2, 3].any {|n| n < 1}) //> false
System.print([1, 2, 3].any {|n| n > 2}) //> true
@ -126,7 +127,9 @@ the sequence is empty, returns `seed`.
### **toList**
Creates a [list](list.html) containing all the elements in the sequence.
Creates a [list][] containing all the elements in the sequence.
[list]: list.html
:::wren
System.print((1..3).toList) //> [1, 2, 3]

View File

@ -1,5 +1,4 @@
^title String Class
^category core
A string is an immutable array of bytes. Strings usually store text, in which
case the bytes are the UTF-8 encoding of the text's code points. But you can put

View File

@ -1,5 +1,4 @@
^title System Class
^category core
The System class is a grab-bag of functionality exposed by the VM, mostly for
use during development or debugging.

View File

@ -0,0 +1,98 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>{title} &ndash; Wren</title>
<link rel="stylesheet" type="text/css" href="../../style.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
</head>
<body id="top" class="module">
<header>
<div class="page">
<div class="main-column">
<h1><a href="../../">wren</a></h1>
<h2>a classy little scripting language</h2>
</div>
</div>
</header>
<div class="page">
<nav class="big">
<ul>
<li><a href="../">Modules</a></li>
<li><a href="./">Core</a></li>
</ul>
<section>
<h2>core classes</h2>
<ul>
<li><a href="bool.html">Bool</a></li>
<li><a href="class.html">Class</a></li>
<li><a href="fiber.html">Fiber</a></li>
<li><a href="fn.html">Fn</a></li>
<li><a href="list.html">List</a></li>
<li><a href="map.html">Map</a></li>
<li><a href="null.html">Null</a></li>
<li><a href="num.html">Num</a></li>
<li><a href="object.html">Object</a></li>
<li><a href="range.html">Range</a></li>
<li><a href="sequence.html">Sequence</a></li>
<li><a href="string.html">String</a></li>
<li><a href="system.html">System</a></li>
</ul>
</section>
</nav>
<nav class="small">
<table>
<tr>
<td><a href="../">Modules</a></td>
<td><a href="./">Core</a></td>
</tr>
<tr>
<td colspan="2"><h2>core classes</h2></td>
</tr>
<tr>
<td>
<ul>
<li><a href="bool.html">Bool</a></li>
<li><a href="class.html">Class</a></li>
<li><a href="fiber.html">Fiber</a></li>
<li><a href="fn.html">Fn</a></li>
<li><a href="list.html">List</a></li>
<li><a href="map.html">Map</a></li>
<li><a href="null.html">Null</a></li>
</ul>
</td>
<td>
<ul>
<li><a href="num.html">Num</a></li>
<li><a href="object.html">Object</a></li>
<li><a href="range.html">Range</a></li>
<li><a href="sequence.html">Sequence</a></li>
<li><a href="string.html">String</a></li>
<li><a href="system.html">System</a></li>
</ul>
</td>
</tr>
</table>
</nav>
<main>
<h1>{title}</h1>
{html}
</main>
</div>
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives
<a href="https://github.com/munificent/wren">on GitHub</a>
&mdash; Made with &#x2764; by
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
</p>
<div class="main-column">
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,48 @@
^title Modules
Because Wren can be used both as an embedded scripting language, and as a
full-featured general purpose programming language run from the command line,
the definition of a "built-in" module is a little more complicated than other
languages. They are organized into three categories:
## Core
There is one core module. It is built directly into the VM and is implicitly
imported by every other module. It contains the classes for the kinds of objects
built directly into the language itself: [numbers][], [strings][], etc.
[numbers]: core/num.html
[strings]: core/string.html
The core module is always available and can't be removed.
* [Core](core)
## Optional
Optional modules are available in the command line Wren interpreter. When you
embed Wren in your own host application, you can also include them too. They are
written in Wren and C, but have no external dependencies, so including them in
your application doesn't force you to bring in any other third-party code.
At the same time, they aren't needed by the VM to function, so you can disable
some or all of them if you want to keep your app as small and constrained as
possible.
There are a couple of optional modules:
* [Meta](meta)
* [Random](random)
## CLI
The CLI modules are only available in the standalone command-line Wren
interpreter. They are deeply tied to [libuv][], each other, and other internals
of the command-line app, so can't be easily separated out and pulled into host
applications that want to embed Wren.
[libuv]: http://libuv.org
* [IO](io)
* [Scheduler](scheduler)
* [Timer](timer)

View File

@ -0,0 +1,7 @@
^title File Class
**TODO**
## Methods
**TODO**

View File

@ -0,0 +1,6 @@
^title IO Module
**TODO**
* [File](file.html)
* [Stdin](stdin.html)

View File

@ -0,0 +1,7 @@
^title Stdin Class
**TODO**
## Methods
**TODO**

View File

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>{title} &ndash; Wren</title>
<link rel="stylesheet" type="text/css" href="../../style.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
</head>
<body id="top" class="module">
<header>
<div class="page">
<div class="main-column">
<h1><a href="../../">wren</a></h1>
<h2>a classy little scripting language</h2>
</div>
</div>
</header>
<div class="page">
<nav class="big">
<ul>
<li><a href="../">Modules</a></li>
<li><a href="./">IO</a></li>
</ul>
<section>
<h2>io classes</h2>
<ul>
<li><a href="file.html">File</a></li>
<li><a href="stdin.html">Stdin</a></li>
</ul>
</section>
</nav>
<nav class="small">
<table>
<tr>
<td><a href="../">Modules</a></td>
<td><a href="./">IO</a></td>
</tr>
<tr>
<td colspan="2"><h2>io classes</h2></td>
</tr>
<tr>
<td>
<ul>
<li><a href="file.html">File</a></li>
</ul>
</td>
<td>
<ul>
<li><a href="stdin.html">Stdin</a></li>
</ul>
</td>
</tr>
</table>
</nav>
<main>
<h1>{title}</h1>
{html}
</main>
</div>
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives
<a href="https://github.com/munificent/wren">on GitHub</a>
&mdash; Made with &#x2764; by
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
</p>
<div class="main-column">
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,5 @@
^title Meta Module
**TODO**
* [Meta](meta.html)

View File

@ -0,0 +1,7 @@
^title Meta Class
**TODO**
## Methods
**TODO**

View File

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>{title} &ndash; Wren</title>
<link rel="stylesheet" type="text/css" href="../../style.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
</head>
<body id="top" class="module">
<header>
<div class="page">
<div class="main-column">
<h1><a href="../../">wren</a></h1>
<h2>a classy little scripting language</h2>
</div>
</div>
</header>
<div class="page">
<nav class="big">
<ul>
<li><a href="../">Modules</a></li>
<li><a href="./">Meta</a></li>
</ul>
<section>
<h2>meta classes</h2>
<ul>
<li><a href="meta.html">Meta</a></li>
</ul>
</section>
</nav>
<nav class="small">
<table>
<tr>
<td><a href="../">Modules</a></td>
<td><a href="./">Meta</a></td>
</tr>
<tr>
<td colspan="2"><h2>meta classes</h2></td>
</tr>
<tr>
<td>
<ul>
<li><a href="meta.html">Meta</a></li>
</ul>
</td>
<td>
<ul>
</ul>
</td>
</tr>
</table>
</nav>
<main>
<h1>{title}</h1>
{html}
</main>
</div>
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives
<a href="https://github.com/munificent/wren">on GitHub</a>
&mdash; Made with &#x2764; by
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
</p>
<div class="main-column">
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,5 @@
^title Random Module
**TODO**
* [Random](random.html)

View File

@ -0,0 +1,7 @@
^title Random Class
**TODO**
## Methods
**TODO**

View File

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>{title} &ndash; Wren</title>
<link rel="stylesheet" type="text/css" href="../../style.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
</head>
<body id="top" class="module">
<header>
<div class="page">
<div class="main-column">
<h1><a href="../../">wren</a></h1>
<h2>a classy little scripting language</h2>
</div>
</div>
</header>
<div class="page">
<nav class="big">
<ul>
<li><a href="../">Modules</a></li>
<li><a href="./">Random</a></li>
</ul>
<section>
<h2>random classes</h2>
<ul>
<li><a href="random.html">Random</a></li>
</ul>
</section>
</nav>
<nav class="small">
<table>
<tr>
<td><a href="../">Modules</a></td>
<td><a href="./">Random</a></td>
</tr>
<tr>
<td colspan="2"><h2>random classes</h2></td>
</tr>
<tr>
<td>
<ul>
<li><a href="random.html">Random</a></li>
</ul>
</td>
<td>
<ul>
</ul>
</td>
</tr>
</table>
</nav>
<main>
<h1>{title}</h1>
{html}
</main>
</div>
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives
<a href="https://github.com/munificent/wren">on GitHub</a>
&mdash; Made with &#x2764; by
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
</p>
<div class="main-column">
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,5 @@
^title Scheduler Module
**TODO**
* [Scheduler](scheduler.html)

View File

@ -0,0 +1,7 @@
^title Scheduler Class
**TODO**
## Methods
**TODO**

View File

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>{title} &ndash; Wren</title>
<link rel="stylesheet" type="text/css" href="../../style.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
</head>
<body id="top" class="module">
<header>
<div class="page">
<div class="main-column">
<h1><a href="../../">wren</a></h1>
<h2>a classy little scripting language</h2>
</div>
</div>
</header>
<div class="page">
<nav class="big">
<ul>
<li><a href="../">Modules</a></li>
<li><a href="./">Scheduler</a></li>
</ul>
<section>
<h2>scheduler classes</h2>
<ul>
<li><a href="scheduler.html">Scheduler</a></li>
</ul>
</section>
</nav>
<nav class="small">
<table>
<tr>
<td><a href="../">Modules</a></td>
<td><a href="./">Scheduler</a></td>
</tr>
<tr>
<td colspan="2"><h2>scheduler classes</h2></td>
</tr>
<tr>
<td>
<ul>
<li><a href="scheduler.html">Scheduler</a></li>
</ul>
</td>
<td>
<ul>
</ul>
</td>
</tr>
</table>
</nav>
<main>
<h1>{title}</h1>
{html}
</main>
</div>
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives
<a href="https://github.com/munificent/wren">on GitHub</a>
&mdash; Made with &#x2764; by
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
</p>
<div class="main-column">
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,92 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>{title} &ndash; Wren</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
</head>
<body id="top" class="module">
<header>
<div class="page">
<div class="main-column">
<h1><a href="../">wren</a></h1>
<h2>a classy little scripting language</h2>
</div>
</div>
</header>
<div class="page">
<nav class="big">
<section>
<h2>core</h2>
<ul>
<li><a href="core">Core</a></li>
</ul>
</section>
<section>
<h2>optional</h2>
<ul>
<li><a href="meta">Meta</a></li>
<li><a href="random">Random</a></li>
</ul>
</section>
<section>
<h2>cli</h2>
<ul>
<li><a href="io">IO</a></li>
<li><a href="scheduler">Scheduler</a></li>
<li><a href="timer">Timer</a></li>
</ul>
</section>
</nav>
<nav class="small">
<table>
<tr>
<td><h2>core</h2></td>
<td><h2>optional</h2></td>
<td><h2>cli</h2></td>
</tr>
<tr>
<td>
<ul>
<li><a href="core">Core</a></li>
</ul>
</td>
<td>
<ul>
<li><a href="meta">Meta</a></li>
<li><a href="random">Random</a></li>
</ul>
</td>
<td>
<ul>
<li><a href="io">IO</a></li>
<li><a href="scheduler">Scheduler</a></li>
<li><a href="timer">Timer</a></li>
</ul>
</td>
</tr>
</table>
</nav>
<main>
<h1>{title}</h1>
{html}
</main>
</div>
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives
<a href="https://github.com/munificent/wren">on GitHub</a>
&mdash; Made with &#x2764; by
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
</p>
<div class="main-column">
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,5 @@
^title Timer Module
**TODO**
* [Timer](timer.html)

View File

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>{title} &ndash; Wren</title>
<link rel="stylesheet" type="text/css" href="../../style.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
</head>
<body id="top" class="module">
<header>
<div class="page">
<div class="main-column">
<h1><a href="../../">wren</a></h1>
<h2>a classy little scripting language</h2>
</div>
</div>
</header>
<div class="page">
<nav class="big">
<ul>
<li><a href="../">Modules</a></li>
<li><a href="./">Timer</a></li>
</ul>
<section>
<h2>timer classes</h2>
<ul>
<li><a href="timer.html">Timer</a></li>
</ul>
</section>
</nav>
<nav class="small">
<table>
<tr>
<td><a href="../">Modules</a></td>
<td><a href="./">Timer</a></td>
</tr>
<tr>
<td colspan="2"><h2>timer classes</h2></td>
</tr>
<tr>
<td>
<ul>
<li><a href="timer.html">Timer</a></li>
</ul>
</td>
<td>
<ul>
</ul>
</td>
</tr>
</table>
</nav>
<main>
<h1>{title}</h1>
{html}
</main>
</div>
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives
<a href="https://github.com/munificent/wren">on GitHub</a>
&mdash; Made with &#x2764; by
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
</p>
<div class="main-column">
</div>
</footer>
</body>
</html>

View File

@ -0,0 +1,7 @@
^title Timer Class
**TODO**
## Methods
**TODO**

View File

@ -1,5 +1,4 @@
^title Performance
^category reference
Even though most benchmarks aren't worth the pixels they're printed on, people
seem to like them, so here's a few:

View File

@ -1,5 +1,4 @@
^title Q & A
^category reference
## Why did you create Wren?

View File

@ -24,10 +24,10 @@ $link-hover: hsl(210, 100%, 80%);
$link-dark: hsl(210, 60%, 20%);
$link-glow: hsla(210, 100%, 50%, 0.4);
$core-link: hsl(150, 70%, 40%);
$core-link-hover: hsl(130, 70%, 70%);
$core-link-dark: hsl(160, 60%, 25%);
$core-link-glow: hsla(130, 90%, 50%, 0.4);
$module-link: hsl(150, 70%, 40%);
$module-link-hover: hsl(130, 70%, 70%);
$module-link-dark: hsl(160, 60%, 25%);
$module-link-glow: hsla(130, 90%, 50%, 0.4);
* {
-moz-box-sizing: border-box;
@ -188,7 +188,7 @@ a {
main {
@extend .main-column;
padding-top: 12px;
float:left;
float: left;
}
a:hover {
@ -315,25 +315,25 @@ footer {
}
}
// Have a different primary color for the core library docs.
body.core {
// Have a different primary color for the module docs.
body.module {
header {
a {
color: $gray-20;
}
a:hover {
color: $core-link-hover;
text-shadow: 0 0 6px $core-link-glow;
color: $module-link-hover;
text-shadow: 0 0 6px $module-link-glow;
}
}
a {
color: $core-link;
color: $module-link;
}
a:hover {
color: $core-link-dark;
color: $module-link-dark;
}
.header-anchor {
@ -342,22 +342,22 @@ body.core {
main {
h1, h2, h3 {
color: $core-link;
color: $module-link;
}
h2:hover > .header-anchor:hover,
h3:hover > .header-anchor:hover {
color: $core-link-dark;
color: $module-link-dark;
}
}
footer {
a {
color: $core-link-hover;
color: $module-link-hover;
}
a:hover {
color: $core-link;
color: $module-link;
}
}
}

View File

@ -1,5 +1,4 @@
^title Syntax
^category guide
Wren's syntax is designed to be familiar to people coming from C-like languages
while being a bit simpler and more streamlined.

View File

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>{title} Wren</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
</head>
<body id="top" class="core">
<header>
<div class="page">
<div class="main-column">
<h1><a href="../">wren</a></h1>
<h2>a classy little scripting language</h2>
</div>
</div>
</header>
<div class="page">
<nav>
<ul>
<li><a href="./">Core Library</a></li>
</ul>
<section>
<h2>core classes</h2>
<ul>
<li><a href="bool.html">Bool</a></li>
<li><a href="class.html">Class</a></li>
<li><a href="fiber.html">Fiber</a></li>
<li><a href="fn.html">Fn</a></li>
<li><a href="list.html">List</a></li>
<li><a href="map.html">Map</a></li>
<li><a href="null.html">Null</a></li>
<li><a href="num.html">Num</a></li>
<li><a href="object.html">Object</a></li>
<li><a href="range.html">Range</a></li>
<li><a href="sequence.html">Sequence</a></li>
<li><a href="string.html">String</a></li>
<li><a href="system.html">System</a></li>
</ul>
</section>
</nav>
<main>
<h1>{title}</h1>
{html}
</main>
</div>
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives <a href="https://github.com/munificent/wren">on GitHub</a> &mdash; Made with &#x2764; by <a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and <a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.</p>
<div class="main-column">
</div>
</footer>
</body>
</html>

View File

@ -39,13 +39,13 @@
<li><a href="classes.html">Classes</a></li>
<li><a href="concurrency.html">Concurrency</a></li>
<li><a href="error-handling.html">Error Handling</a></li>
<li><a href="modules.html">Modules</a></li>
<li><a href="modularity.html">Modularity</a></li>
</ul>
</section>
<section>
<h2>reference</h2>
<ul>
<li><a href="core">Core Library</a></li>
<li><a href="modules">Modules</a></li>
<li><a href="embedding-api.html">Embedding API</a></li>
<li><a href="performance.html">Performance</a></li>
<li><a href="qa.html">Q &amp; A</a></li>
@ -81,12 +81,12 @@
<li><a href="classes.html">Classes</a></li>
<li><a href="concurrency.html">Concurrency</a></li>
<li><a href="error-handling.html">Error Handling</a></li>
<li><a href="modules.html">Modules</a></li>
<li><a href="modularity.html">Modularity</a></li>
</ul>
</td>
<td>
<ul>
<li><a href="core">Core Library</a></li>
<li><a href="modules">Modules</a></li>
<li><a href="embedding-api.html">Embedding API</a></li>
<li><a href="performance.html">Performance</a></li>
<li><a href="qa.html">Q &amp; A</a></li>
@ -103,7 +103,12 @@
<footer>
<div class="page">
<div class="main-column">
<p>Wren lives <a href="https://github.com/munificent/wren">on GitHub</a> &mdash; Made with &#x2764; by <a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and <a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.</p>
<p>Wren lives
<a href="https://github.com/munificent/wren">on GitHub</a>
&mdash; Made with &#x2764; by
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
</p>
<div class="main-column">
</div>
</footer>

View File

@ -1,5 +1,4 @@
^title Values
^category guide
Values are the built-in atomic object types that all other objects are composed
of. They can be created through *literals*, expressions that evaluate to a
@ -10,7 +9,9 @@ character array modified in place.
## Booleans
A boolean value represents truth or falsehood. There are two boolean literals,
`true` and `false`. Their class is [Bool](core/bool.html).
`true` and `false`. Their class is [Bool][].
[bool]: modules/core/bool.html
## Numbers
@ -26,7 +27,9 @@ from other languages:
1.0
-12.34
Numbers are instances of the [Num](core/num.html) class.
Numbers are instances of the [Num][] class.
[num]: modules/core/num.html
## Strings
@ -70,7 +73,9 @@ A `\x` followed by two hex digits specifies a single unencoded byte:
:::wren
System.print("\x48\x69\x2e") //> Hi.
Strings are instances of class [String](core/string.html).
Strings are instances of class [String][].
[string]: modules/core/string.html
## Ranges
@ -100,15 +105,18 @@ example:
var slice = list[1..3]
System.print(slice) //> [b, c, d]
Their class is [Range](core/range.html).
Their class is [Range][].
[range]: modules/core/range.html
## Null
Wren has a special value `null`, which is the only instance of the class
[Null](core/null.html). (Note the difference in case.) It functions a bit like
`void` in some languages: it indicates the absence of a value. If you call a
method that doesn't return anything and get its returned value, you get `null`
back.
[Null][]. (Note the difference in case.) It functions a bit like `void` in some
languages: it indicates the absence of a value. If you call a method that
doesn't return anything and get its returned value, you get `null` back.
[null]: modules/core/null.html
<a class="right" href="lists.html">Lists &rarr;</a>
<a href="syntax.html">&larr; Syntax</a>

View File

@ -1,5 +1,4 @@
^title Variables
^category guide
Variables are named slots for storing values. You define a new variable in Wren
using a `var` statement, like so:

View File

@ -21,18 +21,6 @@ MARKDOWN_HEADER = re.compile(r'#+ ')
# Clean up a header to be a valid URL.
FORMAT_ANCHOR = re.compile(r'\?|!|:|/|\*|`')
def load_template():
global template
with codecs.open("doc/site/template.html", encoding="utf-8") as f:
template = f.read()
def load_core_template():
global template_core
with codecs.open("doc/site/template-core.html", encoding="utf-8") as f:
template_core = f.read()
def ensure_dir(path):
if not os.path.exists(path):
os.mkdir(path)
@ -43,36 +31,24 @@ def is_up_to_date(path, out_path):
if os.path.exists(out_path):
dest_mod = os.path.getmtime(out_path)
# See if the templates have changed.
source_mod = os.path.getmtime('doc/site/template.html')
if source_mod > dest_mod:
load_template()
return False
# See if the templates have changed.
source_mod = os.path.getmtime('doc/site/template-core.html')
if source_mod > dest_mod:
load_core_template()
return False
# See if it's up to date.
source_mod = os.path.getmtime(path)
return source_mod < dest_mod
def format_file(path, skip_up_to_date):
basename = os.path.basename(path)
basename = basename.split('.')[0]
in_path = os.path.join('doc/site', path)
out_path = "build/docs/" + os.path.splitext(path)[0] + ".html"
template_path = os.path.join("doc/site", os.path.dirname(path),
"template.html")
if skip_up_to_date and is_up_to_date(in_path, out_path):
if (skip_up_to_date and
is_up_to_date(in_path, out_path) and
is_up_to_date(template_path, out_path)):
# It's up to date.
return
title = ""
category = ""
# Read the markdown file and preprocess it.
contents = ""
@ -88,8 +64,6 @@ def format_file(path, skip_up_to_date):
if command == "title":
title = args
elif command == "category":
category = args
else:
print(' '.join(["UNKNOWN COMMAND:", command, args]))
@ -125,15 +99,13 @@ def format_file(path, skip_up_to_date):
modified = datetime.fromtimestamp(os.path.getmtime(in_path))
mod_str = modified.strftime('%B %d, %Y')
page_template = template
if category == 'core':
page_template = template_core
with codecs.open(template_path, encoding="utf-8") as f:
page_template = f.read()
fields = {
'title': title,
'html': html,
'mod': mod_str,
'category': category
'mod': mod_str
}
# Write the html output.
@ -173,9 +145,6 @@ if os.path.exists("build/docs"):
shutil.rmtree("build/docs")
ensure_dir("build/docs")
load_template()
load_core_template()
# Process each markdown file.
format_files(False)