apidoc: make decorators use a function attribute rather than a nested stack
This simplifies the handling of the api documentation greatly, as we do not need
to handle a huge tower of nested decorated functions, but just collect data in a
function attribute as we go.