Pretty print return types of events

Close #676 (now supported from upstream).
Handle a part of #683.
Pretty print attributes correctly based on current context

Fix #699.