template-haskell: Add putDoc, getDoc and friends
This MR is an implementation of @mpickering's comment in #5467 (closed)
It adds two new functions, addDoc
and getDoc
that can attach documentation to module headers, declarations, function arguments and class/family instances, as well as retrieve it, provided that Opt_Haddock
is enabled.
This part extends template-haskell
and GHC's opt-haddock support, since Haddock doesn't seem to use the .hi files just yet there is a separate patch that integrates this into Haddock at this branch
Things to do:
-
Tests -
Is String
the right type for docs? -
Add combinators -
Take a closer look at getDoc
(should probably allow it to lookup docs that were added viaaddDoc
-
Does that IORef in TcGblEnv need to be released? -
What happens when Opt_Haddock isn't on? -
How does this work with things defined outside of the module? -
Rename addDoc
tosetDoc
Edited by Ryan Scott