Literate documentation

This PR is composed of two parts.

The first 10 commits improve the existing documentation: more functions are documented, some functions have been moved around and the formatting has improved in general.

The last 3 commits implement a simple documentation generator. The generator extracts the comments, parses them as Markdown (using the external `stmd` command) and generates a `tutorial.html` file in which the comments are the main text of the tutorial, and the code illustrate what is being discussed.