Documented most API functions.

Everything but the field API functions are now documented, so it's a good time to get this merged back in, I think.

The field API functions haven't yet been documented, because I don't yet understand the inputs. Also, the FieldIDs for each record type need documenting, but given the number of record types that's a major bit of work in itself, and will come as a separate pull request.