Extend the API documentation

Document all new definition functions and macros, and also add more
structure to the API docs.