aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md94
-rw-r--r--docs/_config.yml1
-rw-r--r--docs/_includes/toc.html3
-rw-r--r--docs/_layouts/blog.html3
-rw-r--r--docs/_layouts/default.html26
-rw-r--r--docs/_layouts/search.html17
-rw-r--r--docs/blog/index.html2
-rw-r--r--docs/css/main.scss63
-rw-r--r--docs/docs/contributing/eclipse.md5
-rw-r--r--docs/docs/contributing/getting-started.md3
-rw-r--r--docs/docs/contributing/intellij-idea.md3
-rw-r--r--docs/docs/contributing/workflow.md2
-rw-r--r--docs/docs/index.md4
-rw-r--r--docs/docs/internals/backend.md2
-rw-r--r--docs/docs/internals/contexts.md4
-rw-r--r--docs/docs/internals/dotc-scalac.md4
-rw-r--r--docs/docs/internals/overall-structure.md4
-rw-r--r--docs/docs/internals/periods.md5
-rw-r--r--docs/docs/internals/type-system.md3
-rw-r--r--docs/docs/usage/cbt-projects.md4
-rw-r--r--docs/docs/usage/migrating.md3
-rw-r--r--docs/docs/usage/sbt-projects.md4
-rw-r--r--docs/js/elasticlunr.min.js10
-rw-r--r--docs/js/search.js89
-rw-r--r--docs/search.html35
25 files changed, 263 insertions, 130 deletions
diff --git a/README.md b/README.md
index 6d7f97c52..39ec2834e 100644
--- a/README.md
+++ b/README.md
@@ -1,86 +1,18 @@
-dotty
+Dotty
=====
-
[![Join the chat at https://gitter.im/lampepfl/dotty](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lampepfl/dotty?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-Dotty is a platform to try out new language concepts and compiler
-technologies for Scala. The focus is mainly on simplification. We
-remove extraneous syntax (e.g. no XML literals), and try to boil down
-Scala's types into a smaller set of more fundamental constructors. The
-theory behind these constructors is researched in
-[DOT](http://www.cs.uwm.edu/~boyland/fool2012/papers/fool2012_submission_3.pdf),
-a calculus for dependent object types.
-
-####Current status:
- _Technology preview_: currently unsupported, may be functionally incomplete or unsuitable for production use.
-
-####Is it going to be the future Scala?
-Yes, eventually.
-
-####Who's working on it?
-See [github contributors page](https://github.com/lampepfl/dotty/graphs/contributors).
-
-####What are the features that could make me consider trying it?
-| Feature | Status |
-|---------------------------------------------------------------------------------------------------------|---------------------|
-| Union, Intersection and [Literal singleton types](http://docs.scala-lang.org/sips/pending/42.type.html) | Implemented |
-| Fast compilation(phase fusion) | Implemented |
-| [Trait parameters](http://docs.scala-lang.org/sips/pending/trait-parameters.html) | Implemented |
-| [@Static methods and fields](https://github.com/scala/scala.github.com/pull/491) | Implemented |
-| Colored Repl | Implemented |
-| Sbt incremental build | Implemented |
-| Non-blocking lazy vals | Implemented |
-| Multiverse equality | Implemented |
-| Option-less pattern matching(based on [name-based patmat](https://github.com/scala/scala/pull/2848)) | Implemented |
-| Function arity adaptation | Implemented |
-| Exhaustivity checks in pattern matching | Implemented |
-| | |
-| Non-boxed arrays of value classes | In progress |
-| Working contravariant implicits | In progress |
-| [Auto-Specialization](https://github.com/dotty-linker/dotty) | In progress |
-| [Whole program optimizer](https://github.com/dotty-linker/dotty) | In progress |
-| [Library defined optimizations](https://github.com/dotty-linker/dotty) | In progress |
-| | |
-| HList & HMaps\Record types | Under consideration |
-| Implicit functions | Under consideration |
-| Effects | Under consideration |
-| Auto-completion in repl | Under consideration |
-| Spec Option-less pattern matching | Under consideration |
-
-There are also plethora of small details such as [per-callsite @tailrec annotations](https://github.com/lampepfl/dotty/issues/1221)
-
-####What are the complications that I can have If I start using Dotty?
-Dotty can use libraries compiled by scalac 2.11, but Scala scalac can't use libraries compiled by Dotty.<br>
-No existential types.<br>
-No macro support yet. We have big plans here.<br>
-No early initializers. No scala.DelayedInit. Use trait parameters instead.<br>
-Whole program optimizer will only work if all dependencies are compiled by Dotty.<br>
-
-
-####Can I write my code in a way that is going to be compatible with Scalac & Dotty?
-Yes, Dotty itself is a project that can be compiled by both Dotty and Scalac.<br>
-It's not very hard, and the biggest thing that you will likely miss is using macros.
-
-####How can I try it out?
-http://lampepfl.github.io/dotty/docs/contributing/getting-started.html.
-Here’s an example sbt project and instructions on how to set it up: https://github.com/smarter/dotty-example-project/ <br>
-We have colored REPL :-). You can invoke it by running `dotc -repl`.
-
-####We also have:
-Basic support for Scala.js,<br>
-[Prototype](https://github.com/scala-native/scala-native/tree/topic/dotty-support) of compilation to x86 native code(Shabalin)<br>
-
-####What about scalac:
-Scalac is the basis for stability in scala. We expect scalac & dotty to coexist for long time.
-
-####Contributions are welcome!
-We invite you to help us build the future of Scala.<br>
-This is the best moment to participate, as everyone can make an impact.<br>
-
-####SI-2712?
-Since scalac merged a fix into 2.12, we’ll mimic their behaviour. But we have bigger plans for
-HK-types.
-
+* [Homepage](http://dotty.epfl.ch)
+* [Documentation](http://dotty.epfl.ch/docs)
+* [FAQ](http://dotty.epfl.ch/#why-dotty)
+* [Mailing list](https://groups.google.com/forum/#!forum/dotty-internals)
+How to Contribute
+=================
+* [Getting Started](http://dotty.epfl.ch/docs/contributing/getting-started.html)
+* [Awesome Error Messages](http://scala-lang.org/blog/2016/10/14/dotty-errors.html)
+* [Issues](https://github.com/lampepfl/dotty/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
-Developers mailing list is https://groups.google.com/forum/#!forum/dotty-internals.
+License
+=======
+Dotty is licensed under the [3-Clause BSD License](https://github.com/lampepfl/dotty/blob/master/LICENSE.md)
diff --git a/docs/_config.yml b/docs/_config.yml
index 51578256b..1bdfb808a 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -1,4 +1,5 @@
title: Dotty Documentation
+repository_url: "http://github.com/lampepfl/dotty"
baseurl: ""
theme: minima
gems:
diff --git a/docs/_includes/toc.html b/docs/_includes/toc.html
index cac31d2bf..45cbb5940 100644
--- a/docs/_includes/toc.html
+++ b/docs/_includes/toc.html
@@ -4,6 +4,9 @@
{% include scala-logo.html %}
</div>
</a>
+ <form id="search-form" action="/search.html" method="get">
+ <input placeholder="Search" type="text" id="search-box" name="query">
+ </form>
<ul id="categories">
<li><ul><li><a href="{{ site.baseurl }}/blog">Blog</a></li></ul></li>
<li><ul><li><a href="{{ site.baseurl }}/docs">Dotty Docs</a></li></ul></li>
diff --git a/docs/_layouts/blog.html b/docs/_layouts/blog.html
index 560b8a64c..f476bf5fa 100644
--- a/docs/_layouts/blog.html
+++ b/docs/_layouts/blog.html
@@ -2,12 +2,11 @@
layout: default
---
-<h1 class="title">{{ page.title }}</h1>
<h2 class="subtitle">{{ page.subTitle }}</h2>
<div class="author-container {% if page.authorImg != null %} spaced {% endif %}">
{% if page.authorImg != null %}
- <img src="{{ site.baseurl }}/{{ page.authorImg }}"/>
+ <img src="{{ site.baseurl }}{{ page.authorImg }}"/>
{% endif %}
<div class="author-info">
<div>{{ page.author }}</div>
diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html
index ce1345145..6fa1a1d78 100644
--- a/docs/_layouts/default.html
+++ b/docs/_layouts/default.html
@@ -15,6 +15,10 @@
</div>
</a>
<div id="content">
+ <h1>{{ page.title }}</h1>
+ <div class="edit-docs">
+ <a href="{{site.repository_url}}/edit/master/docs/{{page.path}}">[edit on github]</a>
+ </div>
{{ content }}
</div>
<div id="toc">
@@ -22,6 +26,7 @@
</div>
</div>
</body>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.4.0/mark.min.js"></script>
<script src="{{ site.baseurl }}/js/highlight.pack.js"></script>
<script language="javascript">
hljs.initHighlightingOnLoad();
@@ -31,5 +36,26 @@
if (thisHREF.indexOf(window.location.hostname) > -1) thisHREF = thisHREF.replace(".md",".html")
document.links[i].setAttribute('href', thisHREF);
}
+
+ function getQueryVariable(variable) {
+ var query = window.location.search.substring(1);
+ var vars = query.split('&');
+
+ for (var i = 0; i < vars.length; i++) {
+ var pair = vars[i].split('=');
+
+ if (pair[0] === variable) {
+ return decodeURIComponent(pair[1].replace(/\+/g, '%20'));
+ }
+ }
+ }
+
+
+ var highlight = getQueryVariable("highlight");
+ if (highlight) {
+ var context = document.querySelector("#content");
+ var instance = new Mark(context);
+ instance.mark(highlight);
+ }
</script>
</html>
diff --git a/docs/_layouts/search.html b/docs/_layouts/search.html
new file mode 100644
index 000000000..14994ab62
--- /dev/null
+++ b/docs/_layouts/search.html
@@ -0,0 +1,17 @@
+<html>
+ <head>
+ <meta charset="utf-8">
+
+ <title>Dotty - {{ page.title }}</title>
+ <link rel="shortcut icon" type="image/png" href="{{ site.baseurl}}/images/favicon.png"/>
+ <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/github.min.css">
+ <link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">
+ </head>
+ <body>
+ <div id="container">
+ <div class="search">
+ {{ content }}
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/docs/blog/index.html b/docs/blog/index.html
index e58018857..ac4b33c8a 100644
--- a/docs/blog/index.html
+++ b/docs/blog/index.html
@@ -3,8 +3,6 @@ layout: default
title: "Blog"
---
-<h1>Blog</h1>
-
<ul class="post-list">
{% for post in site.posts %}
<li>
diff --git a/docs/css/main.scss b/docs/css/main.scss
index c6b41594f..dbc5153e2 100644
--- a/docs/css/main.scss
+++ b/docs/css/main.scss
@@ -15,8 +15,8 @@ $base-line-height: 1.5;
$spacing-unit: 30px;
-$text-color: #111;
-$background-color: #fdfdfd;
+$text-color: #efefef;
+$background-color: #002B36;
$brand-color: #2a7ae2;
@@ -25,6 +25,8 @@ $blue-light: rgba(52, 152, 219, 0.12);
$grey: #f8f8f8;
$red: #de332e;
+$link-color: $blue;
+
// content area
$distance-top: 80px;
$content-width: 1150px;
@@ -49,6 +51,14 @@ html {
box-sizing: inherit;
}
+*:focus {
+ outline: none;
+}
+
+a, a:focus, a:hover, a:visited {
+ color: $link-color;
+}
+
div#container {
position: relative;
max-width: $content-width;
@@ -60,6 +70,7 @@ div#container {
}
div#content {
+ position: relative;
margin-top: $distance-top;
width: $content-width - $toc-width;
float: right;
@@ -80,10 +91,25 @@ div#container {
padding-right: 20px;
width: $toc-width;
+ form#search-form {
+ input#search-box {
+ width: 100%;
+ border: 0;
+ height: 24px;
+ font-size: 14px;
+ padding-left: 4px;
+ }
+
+ input#search-button {
+ margin-top: 3px;
+ }
+ }
+
> div {
position: fixed;
top: $distance-top;
bottom: auto;
+ max-width: $toc-width;
a > div#scala-logo {
width: 64px;
@@ -125,6 +151,27 @@ div#container {
}
}
+div.edit-docs {
+ position: absolute;
+ top: 8px;
+ right: 0;
+}
+
+h1#search {
+ margin-top: 50px;
+}
+
+form#search-bar {
+ width: 100%;
+ > input {
+ width: 100%;
+ border: 0;
+ height: 24px;
+ font-size: 14px;
+ padding-left: 4px;
+ }
+}
+
div.author-container {
height: 50px;
margin-bottom: 15px;
@@ -135,7 +182,7 @@ div.author-container {
}
> div.author-info {
- color: rgba(0,0,0,0.45);
+ color: rgba(255,255,255,0.45);
float: left;
}
}
@@ -155,7 +202,7 @@ ul.post-list {
> li {
div.date {
- color: rgba(0,0,0,0.45);
+ color: rgba(255,255,255,0.55);
}
}
}
@@ -165,12 +212,18 @@ pre, code {
border: 0;
border-radius: 3px;
background-color: $grey;
+ color: $background-color;
font-family: $code-font-family;
}
+code {
+ padding-left: 0.1em;
+ padding-right: 0.1em;
+}
+
body {
font: 400 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
- color: #111;
+ color: $text-color;
}
@include media-query(1166px) {
diff --git a/docs/docs/contributing/eclipse.md b/docs/docs/contributing/eclipse.md
index 46301dc42..9afe28355 100644
--- a/docs/docs/contributing/eclipse.md
+++ b/docs/docs/contributing/eclipse.md
@@ -1,11 +1,8 @@
---
layout: default
-title: Eclipse
+title: "Building Dotty with Eclipse"
---
-Building Dotty with Eclipse
-===========================
-
Build setup
-----------
You may need to redo these steps when the build changes.
diff --git a/docs/docs/contributing/getting-started.md b/docs/docs/contributing/getting-started.md
index 92afd02f3..bea5b6962 100644
--- a/docs/docs/contributing/getting-started.md
+++ b/docs/docs/contributing/getting-started.md
@@ -3,9 +3,6 @@ layout: default
title: "Getting Started"
---
-Getting Started
-===============
-
Talks on Dotty
--------------
- [Scala's Road Ahead](https://www.youtube.com/watch?v=GHzWqJKFCk4) by Martin Odersky [\[slides\]](http://www.slideshare.net/Odersky/scala-days-nyc-2016)
diff --git a/docs/docs/contributing/intellij-idea.md b/docs/docs/contributing/intellij-idea.md
index dda04f515..9231f209a 100644
--- a/docs/docs/contributing/intellij-idea.md
+++ b/docs/docs/contributing/intellij-idea.md
@@ -1,9 +1,8 @@
---
layout: default
+title: "Building Dotty with Intellij IDEA"
---
-Building Dotty with Intellij IDEA
-=================================
Dotty compiler support is available in the [Scala plugin nightly] starting
from 2.2.39. You need to install [IDEA 2016.1] to try it.
diff --git a/docs/docs/contributing/workflow.md b/docs/docs/contributing/workflow.md
index e160999d9..a0b9fd528 100644
--- a/docs/docs/contributing/workflow.md
+++ b/docs/docs/contributing/workflow.md
@@ -3,8 +3,6 @@ layout: default
title: "Workflow"
---
-Workflow
-========
This document details common workflow patterns when working with Dotty.
## Compiling files with dotc ##
diff --git a/docs/docs/index.md b/docs/docs/index.md
index 6fc2b2739..699fcecb1 100644
--- a/docs/docs/index.md
+++ b/docs/docs/index.md
@@ -1,10 +1,8 @@
---
layout: default
-title: "Docs"
+title: "Dotty Documentation"
---
-Dotty Documentation
-===================
The Dotty compiler is currently somewhat lacking in documentation - PRs
welcome! But, we've attempted to gather the most essential knowledge in these
pages.
diff --git a/docs/docs/internals/backend.md b/docs/docs/internals/backend.md
index 1fb9bba26..f10cf1e82 100644
--- a/docs/docs/internals/backend.md
+++ b/docs/docs/internals/backend.md
@@ -3,8 +3,6 @@ layout: default
title: "Backend Internals"
---
-Backend Internals
-=================
The code for the backend is split up by functionality and assembled in the
objet `GenBCode`.
diff --git a/docs/docs/internals/contexts.md b/docs/docs/internals/contexts.md
index e2111029c..09cbb40c5 100644
--- a/docs/docs/internals/contexts.md
+++ b/docs/docs/internals/contexts.md
@@ -1,10 +1,8 @@
---
-title: Contexts
layout: default
+title: "Contexts"
---
-Contexts
-========
The `Context` contains the state of the compiler, for example
* `settings`
* `freshNames` (`FreshNameCreator`)
diff --git a/docs/docs/internals/dotc-scalac.md b/docs/docs/internals/dotc-scalac.md
index cf668cbb8..f41f21370 100644
--- a/docs/docs/internals/dotc-scalac.md
+++ b/docs/docs/internals/dotc-scalac.md
@@ -1,10 +1,8 @@
---
layout: default
-title: "Scalac vs Dotty"
+title: "Differences between Scalac and Dotty"
---
-Differences between Scalac and Dotty
-====================================
Overview explanation how symbols, named types and denotations hang together:
[Denotations.scala:22]
diff --git a/docs/docs/internals/overall-structure.md b/docs/docs/internals/overall-structure.md
index 214e47aa5..08d9ebe97 100644
--- a/docs/docs/internals/overall-structure.md
+++ b/docs/docs/internals/overall-structure.md
@@ -1,10 +1,8 @@
---
layout: default
-title: "Project Structure"
+title: "Dotty Overall Structure"
---
-Dotc Overall Structure
-======================
The compiler code is found in package [dotty.tools]. It spans the
following three sub-packages:
diff --git a/docs/docs/internals/periods.md b/docs/docs/internals/periods.md
index fe788915d..bb161b7b8 100644
--- a/docs/docs/internals/periods.md
+++ b/docs/docs/internals/periods.md
@@ -1,11 +1,8 @@
---
layout: default
-title: "Periods"
-toc: true
+title: "Dotc's concept of time"
---
-Dotc's concept of time
-======================
Conceptually, the `dotc` compiler's job is to maintain views of various
artifacts associated with source code at all points in time. But what is
*time* for `dotc`? In fact, it is a combination of compiler runs and compiler
diff --git a/docs/docs/internals/type-system.md b/docs/docs/internals/type-system.md
index 191c107cf..e86e07fd1 100644
--- a/docs/docs/internals/type-system.md
+++ b/docs/docs/internals/type-system.md
@@ -1,9 +1,8 @@
---
layout: default
+title: "Type System"
---
-Type System
-===========
The types are defined in [dotty/tools/dotc/core/Types.scala][1]
## Class diagram ##
diff --git a/docs/docs/usage/cbt-projects.md b/docs/docs/usage/cbt-projects.md
index 1ae25efd5..291813b91 100644
--- a/docs/docs/usage/cbt-projects.md
+++ b/docs/docs/usage/cbt-projects.md
@@ -1,10 +1,8 @@
---
layout: default
-title: "cbt"
+title: "Using Dotty with cbt"
---
-Using Dotty with cbt
-====================
cbt comes with built-in dotty support. Follow the
[cbt tutorial](https://github.com/cvogt/cbt/), then simply extend `Dotty` in the Build class.
diff --git a/docs/docs/usage/migrating.md b/docs/docs/usage/migrating.md
index d835aeea6..eb76571e5 100644
--- a/docs/docs/usage/migrating.md
+++ b/docs/docs/usage/migrating.md
@@ -3,9 +3,6 @@ layout: default
title: "Migrating to Dotty"
---
-Migrating to Dotty
-==================
-
### Minor tweaks ###
* `sym.linkedClassOfClass` => `sym.linkedClass`
* `definitions` => `ctx.definitions`
diff --git a/docs/docs/usage/sbt-projects.md b/docs/docs/usage/sbt-projects.md
index 79418850d..b4eb5136d 100644
--- a/docs/docs/usage/sbt-projects.md
+++ b/docs/docs/usage/sbt-projects.md
@@ -1,10 +1,8 @@
---
layout: default
-title: "sbt"
+title: "Using Dotty with sbt"
---
-Using Dotty with sbt
-====================
It is now possible to use Dotty with sbt thanks to the dotty-bridge project.
There are two alternatives in how to create an sbt project that uses dotty:
diff --git a/docs/js/elasticlunr.min.js b/docs/js/elasticlunr.min.js
new file mode 100644
index 000000000..32cb1bce1
--- /dev/null
+++ b/docs/js/elasticlunr.min.js
@@ -0,0 +1,10 @@
+/**
+ * elasticlunr - http://weixsong.github.io
+ * Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.5
+ *
+ * Copyright (C) 2016 Oliver Nightingale
+ * Copyright (C) 2016 Wei Song
+ * MIT Licensed
+ * @license
+ */
+!function(){function e(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.9.5",lunr=t,t.utils={},t.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),t.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},t.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!==n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},t.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},t.EventEmitter.prototype.hasHandler=function(e){return e in this.events},t.tokenizer=function(e){if(!arguments.length||null===e||void 0===e)return[];if(Array.isArray(e)){var n=e.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(e){return t.utils.toString(e).toLowerCase()});var i=[];return n.forEach(function(e){var n=e.split(t.tokenizer.seperator);i=i.concat(n)},this),i}return e.toString().trim().toLowerCase().split(t.tokenizer.seperator)},t.tokenizer.defaultSeperator=/[\s\-]+/,t.tokenizer.seperator=t.tokenizer.defaultSeperator,t.tokenizer.setSeperator=function(e){null!==e&&void 0!==e&&"object"==typeof e&&(t.tokenizer.seperator=e)},t.tokenizer.resetSeperator=function(){t.tokenizer.seperator=t.tokenizer.defaultSeperator},t.tokenizer.getSeperator=function(){return t.tokenizer.seperator},t.Pipeline=function(){this._queue=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in t.Pipeline.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[n]=e},t.Pipeline.getRegisteredFunction=function(e){return e in t.Pipeline.registeredFunctions!=!0?null:t.Pipeline.registeredFunctions[e]},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.getRegisteredFunction(e);if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},t.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},t.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];var i=null;null!=n&&(i=JSON.stringify(n));var o=new t.Configuration(i,this.getFields()).get(),r=this.pipeline.run(t.tokenizer(e)),s={};for(var u in o){var a=this.fieldSearch(r,u,o),l=o[u].boost;for(var d in a)a[d]=a[d]*l;for(var d in a)d in s?s[d]+=a[d]:s[d]=a[d]}var c=[];for(var d in s)c.push({ref:d,score:s[d]});return c.sort(function(e,t){return t.score-e.score}),c},t.Index.prototype.fieldSearch=function(e,t,n){var i=n[t].bool,o=n[t].expand,r=n[t].boost,s=null,u={};return 0!==r?(e.forEach(function(e){var n=[e];1==o&&(n=this.index[t].expandToken(e));var r={};n.forEach(function(n){var o=this.index[t].getDocs(n),a=this.idf(n,t);if(s&&"AND"==i){var l={};for(var d in s)d in o&&(l[d]=o[d]);o=l}n==e&&this.fieldSearchStats(u,n,o);for(var d in o){var c=this.index[t].getTermFrequency(n,d),f=this.documentStore.getFieldLength(d,t),h=1;0!=f&&(h=1/Math.sqrt(f));var p=1;n!=e&&(p=.15*(1-(n.length-e.length)/n.length));var v=c*a*h*p;d in r?r[d]+=v:r[d]=v}},this),s=this.mergeScores(s,r,i)},this),s=this.coordNorm(s,u,e.length)):void 0},t.Index.prototype.mergeScores=function(e,t,n){if(!e)return t;if("AND"==n){var i={};for(var o in t)o in e&&(i[o]=e[o]+t[o]);return i}for(var o in t)o in e?e[o]+=t[o]:e[o]=t[o];return e},t.Index.prototype.fieldSearchStats=function(e,t,n){for(var i in n)i in e?e[i].push(t):e[i]=[t]},t.Index.prototype.coordNorm=function(e,t,n){for(var i in e)if(i in t){var o=t[i].length;e[i]=e[i]*o/n}return e},t.Index.prototype.toJSON=function(){var e={};return this._fields.forEach(function(t){e[t]=this.index[t].toJSON()},this),{version:t.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:e,pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},t.DocumentStore=function(e){this._save=null===e||void 0===e?!0:e,this.docs={},this.docInfo={},this.length=0},t.DocumentStore.load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},t.DocumentStore.prototype.isDocStored=function(){return this._save},t.DocumentStore.prototype.addDoc=function(t,n){this.hasDoc(t)||this.length++,this.docs[t]=this._save===!0?e(n):null},t.DocumentStore.prototype.getDoc=function(e){return this.hasDoc(e)===!1?null:this.docs[e]},t.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},t.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},t.DocumentStore.prototype.addFieldLength=function(e,t,n){null!==e&&void 0!==e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},t.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!==e&&void 0!==e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},t.DocumentStore.prototype.getFieldLength=function(e,t){return null===e||void 0===e?0:e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},t.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},t.stemmer=function(){var e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},t={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",o=n+"[^aeiouy]*",r=i+"[aeiou]*",s="^("+o+")?"+r+o,u="^("+o+")?"+r+o+"("+r+")?$",a="^("+o+")?"+r+o+r+o,l="^("+o+")?"+i,d=new RegExp(s),c=new RegExp(a),f=new RegExp(u),h=new RegExp(l),p=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,m=/^(.+?)(ed|ing)$/,y=/.$/,S=/(at|bl|iz)$/,x=new RegExp("([^aeiouylsz])\\1$"),w=new RegExp("^"+o+i+"[^aeiouwxy]$"),I=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,D=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,F=/^(.+?)(s|t)(ion)$/,_=/^(.+?)e$/,P=/ll$/,k=new RegExp("^"+o+i+"[^aeiouwxy]$"),z=function(n){var i,o,r,s,u,a,l;if(n.length<3)return n;if(r=n.substr(0,1),"y"==r&&(n=r.toUpperCase()+n.substr(1)),s=p,u=v,s.test(n)?n=n.replace(s,"$1$2"):u.test(n)&&(n=n.replace(u,"$1$2")),s=g,u=m,s.test(n)){var z=s.exec(n);s=d,s.test(z[1])&&(s=y,n=n.replace(s,""))}else if(u.test(n)){var z=u.exec(n);i=z[1],u=h,u.test(i)&&(n=i,u=S,a=x,l=w,u.test(n)?n+="e":a.test(n)?(s=y,n=n.replace(s,"")):l.test(n)&&(n+="e"))}if(s=I,s.test(n)){var z=s.exec(n);i=z[1],n=i+"i"}if(s=b,s.test(n)){var z=s.exec(n);i=z[1],o=z[2],s=d,s.test(i)&&(n=i+e[o])}if(s=E,s.test(n)){var z=s.exec(n);i=z[1],o=z[2],s=d,s.test(i)&&(n=i+t[o])}if(s=D,u=F,s.test(n)){var z=s.exec(n);i=z[1],s=c,s.test(i)&&(n=i)}else if(u.test(n)){var z=u.exec(n);i=z[1]+z[2],u=c,u.test(i)&&(n=i)}if(s=_,s.test(n)){var z=s.exec(n);i=z[1],s=c,u=f,a=k,(s.test(i)||u.test(i)&&!a.test(i))&&(n=i)}return s=P,u=c,s.test(n)&&u.test(n)&&(s=y,n=n.replace(s,"")),"y"==r&&(n=r.toLowerCase()+n.substr(1)),n};return z}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),t.stopWordFilter=function(e){return e&&t.stopWordFilter.stopWords[e]!==!0?e:void 0},t.clearStopWords=function(){t.stopWordFilter.stopWords={}},t.addStopWords=function(e){null!=e&&Array.isArray(e)!==!1&&e.forEach(function(e){t.stopWordFilter.stopWords[e]=!0},this)},t.resetStopWords=function(){t.stopWordFilter.stopWords=t.defaultStopWords},t.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,"do":!0,does:!0,either:!0,"else":!0,ever:!0,every:!0,"for":!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,"if":!0,"in":!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,"this":!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,"while":!0,who:!0,whom:!0,why:!0,will:!0,"with":!0,would:!0,yet:!0,you:!0,your:!0},t.stopWordFilter.stopWords=t.defaultStopWords,t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),t.trimmer=function(e){if(null===e||void 0===e)throw new Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),t.InvertedIndex=function(){this.root={docs:{},df:0}},t.InvertedIndex.load=function(e){var t=new this;return t.root=e.root,t},t.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,i=0;i<=e.length-1;){var o=e[i];o in n||(n[o]={docs:{},df:0}),i+=1,n=n[o]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},t.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},t.InvertedIndex.prototype.getNode=function(e){if(!e)return null;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return null;t=t[e[n]]}return t},t.InvertedIndex.prototype.getDocs=function(e){var t=this.getNode(e);return null==t?{}:t.docs},t.InvertedIndex.prototype.getTermFrequency=function(e,t){var n=this.getNode(e);return null==n?0:t in n.docs?n.docs[t].tf:0},t.InvertedIndex.prototype.getDocFreq=function(e){var t=this.getNode(e);return null==t?0:t.df},t.InvertedIndex.prototype.removeToken=function(e,t){if(e){var n=this.getNode(e);null!=n&&t in n.docs&&(delete n.docs[t],n.df-=1)}},t.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];var t=t||[];if(void 0==n&&(n=this.getNode(e),null==n))return t;n.df>0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e<arguments.length;e++)t=arguments[e],~this.indexOf(t)||this.elements.splice(this.locationFor(t),0,t);this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]<u[i]?n++:s[n]>u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();o<r.length;o++)i.add(r[o]);return i},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.elasticlunr=t()}(this,function(){return t})}(); \ No newline at end of file
diff --git a/docs/js/search.js b/docs/js/search.js
new file mode 100644
index 000000000..63544d52f
--- /dev/null
+++ b/docs/js/search.js
@@ -0,0 +1,89 @@
+(function() {
+ var searchTerm = getQueryVariable('query');
+ function showMark(first, last) {
+ var res = "";
+ if ((first.length + last.length) <= 150) {
+ res = '<p class="result-text">' + first + "<mark>" + searchTerm + "</mark>" + last + '...</p></li>';
+ } else if (first.length > 150 && last.length > 150) {
+ res = '<p class="result-text">' + first.substring(first.length - 76, first.length - 1) + "<mark>" + searchTerm + "</mark>" + last.substring(0, 75) + '...</p></li>';
+ } else if (first.length > last.length) {
+ var lastLen = Math.min(last.length, 75);
+ var frstLen = Math.min(first.length, 150 - lastLen);
+ res = '<p class="result-text">' + first.substring(first.length - frstLen - 1, first.length - 1) + "<mark>" + searchTerm + "</mark>" + last.substring(0, 75) + '...</p></li>';
+ }
+ return res;
+ }
+
+ function displaySearchResults(results, store) {
+ var searchResults = document.getElementById('search-results');
+
+ if (results.length) { // Are there any results?
+ var appendString = '';
+
+ for (var i = 0; i < results.length; i++) { // Iterate over the results
+ var item = store[results[i].ref];
+ appendString += '<li><a href="' + item.url + "?highlight=" + searchTerm + '"><h3>' + item.title + '</h3></a>';
+
+ var text = item.content.split(searchTerm)
+
+ if (text.length == 1) {
+ appendString += '<p class="result-text">' + item.content.substring(0, 150) + '...</p></li>';
+ }
+ else if (text.length == 2) {
+ appendString += showMark(text[0], text[1]);
+ }
+ else {
+ for (var j = 0; j < text.length - 1; j++) {
+ appendString += showMark(text[j], text[j+1]);
+ }
+ }
+ }
+
+ searchResults.innerHTML = appendString;
+ } else {
+ searchResults.innerHTML = '<li>No results found</li>';
+ }
+ }
+
+ function getQueryVariable(variable) {
+ var query = window.location.search.substring(1);
+ var vars = query.split('&');
+
+ for (var i = 0; i < vars.length; i++) {
+ var pair = vars[i].split('=');
+
+ if (pair[0] === variable) {
+ return decodeURIComponent(pair[1].replace(/\+/g, '%20'));
+ }
+ }
+ }
+
+ if (searchTerm) {
+ document.getElementById('search-box').setAttribute("value", searchTerm);
+ var idx = elasticlunr(function () {
+ this.addField('title'); // hits in title get a boost
+ this.addField('author');
+ this.addField('content');
+ this.setRef('id');
+ });
+
+ for (var key in window.store) { // Add the data to lunr
+ var author = (typeof window.store[key].author === 'undefined') ? "" : window.store[key].author;
+ idx.addDoc({
+ 'id': key,
+ 'title': window.store[key].title,
+ 'author': author,
+ 'content': window.store[key].content
+ });
+
+ var results = idx.search(searchTerm, {
+ fields: {
+ title: { boost: 3 },
+ author: { boost: 2 },
+ content: { boost: 1 }
+ }
+ }); // Get lunr to perform a search
+ displaySearchResults(results, window.store); // We'll write this in the next section
+ }
+ }
+})();
diff --git a/docs/search.html b/docs/search.html
new file mode 100644
index 000000000..20cccc11f
--- /dev/null
+++ b/docs/search.html
@@ -0,0 +1,35 @@
+---
+layout: search
+title: "Search"
+---
+<h1 id="search">Search Results</h1>
+
+<form id="search-bar" action="/search.html" method="get">
+ <input placeholder="Search" type="text" id="search-box" name="query">
+</form>
+
+<ul id="search-results"></ul>
+
+<script>
+ window.store = {
+ {% for post in site.posts %}
+ "{{ post.url | slugify }}": {
+ "title": "{{ post.title | xml_escape }}",
+ "author": "{{ post.author | xml_escape }}",
+ "content": {{ post.content | markdownify | strip_html | lstrip | jsonify }},
+ "url": "{{ post.url | xml_escape }}"
+ },
+ {% endfor %}
+ {% for page in site.html_pages %}
+ "{{ page.url | slugify }}": {
+ "title": "{{ page.title | xml_escape }}",
+ "name": "{{ page.name | xml_escape }}",
+ "content": {{ page.content | markdownify | strip_html | lstrip | jsonify }},
+ "url": "{{ page.url | xml_escape }}"
+ }
+ {% unless forloop.last %},{% endunless %}
+ {% endfor %}
+ };
+</script>
+<script src="/js/elasticlunr.min.js"></script>
+<script src="/js/search.js"></script>