Clean up edoc generation

Run `make docs` on the previous commit to see all of the individual
error messages. There are several basic types of changes:

* Fix `foo` syntax to `foo'
* Put specs on top of their functions. Otherwise edoc complains that
* there are multiple spec definitions for a function
* Properly escape code that edoc was interpreting  as XML
* Make sure module documentation comes before `-module(..).`

`rm -rf doc && make docs; echo $?` should now exit with 0, and have no
warnings or errors printed.