add API documentation

I converted the documentation in the comments to `gendocs` format,
(basically, just markdown after a `/**`)

I selected `gendocs` because it was the best documented document generator.

Added a link to the documentation from the readme, which works,
but it would be better to just put it in the readme, but that would mean a complicated build step,
or removing it from the code comments and just maintaining the documentation in the readme.

what do you think.

Anyway, this is good for now.