YARD friendly code generation

@jarib Specs now pass. I had to remove some attributes from generated interfaces because they overwrite some element methods. Please, review code.
This could probably be made more efficient by using `Enumerable#group_by` (thus avoiding the `find` inside the loop), but I guess it doesn't really matter. It's not a hot code path.