ENH: better macro which considers libraries link and .m doc file