Moved text-api and doc to javascript. Edited the doc API a bit