diff options
author | David Waern <david.waern@gmail.com> | 2009-11-24 20:55:49 +0000 |
---|---|---|
committer | David Waern <david.waern@gmail.com> | 2009-11-24 20:55:49 +0000 |
commit | dc3a42156eeb0fd1457a395e69f5778c0446caa5 (patch) | |
tree | 480019738b5aa5060ac43e133949f7fb1e09eab9 /src/Haddock/Types.hs | |
parent | 53f11cbd4af38e88ef547fec54cc42f976b1d048 (diff) |
Comments on instances
Implementing this was a little trickier than I thought, since we need to match
up instances from the renamed syntax with instances represented by
InstEnv.Instance. This is due to the current design of Haddock, which matches
comments with declarations from the renamed syntax, while getting the list of
instances of a class/family directly using the GHC API.
- Works for class instances only (Haddock has no support for type family
instances yet)
- The comments are rendered to the right of the instance head in the HTML output
- No change to the .haddock file format
- Works for normal user-written instances only. No comments are added on
derived or TH-generated instances
Diffstat (limited to 'src/Haddock/Types.hs')
-rw-r--r-- | src/Haddock/Types.hs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Haddock/Types.hs b/src/Haddock/Types.hs index 4c8c3656..d7d5e7bd 100644 --- a/src/Haddock/Types.hs +++ b/src/Haddock/Types.hs @@ -40,6 +40,8 @@ import Name type Decl = LHsDecl Name type Doc = HsDoc Name +type DocInstance name = (name, InstHead name, Maybe (HsDoc name)) + #if __GLASGOW_HASKELL__ <= 610 type HsDocString = HsDoc Name type LHsDocString = Located HsDocString @@ -98,8 +100,8 @@ data ExportItem name -- | Subordinate names, possibly with documentation expItemSubDocs :: [(name, DocForDecl name)], - -- | Instances relevant to this declaration - expItemInstances :: [InstHead name] + -- | Instances relevant to this declaration, possibly with documentation + expItemInstances :: [DocInstance name] } -- ^ An exported declaration @@ -131,7 +133,11 @@ data ExportItem name | ExportModule Module -- ^ A cross-reference to another module +-- | The head of an instance. Consists of a context, a class name and a list of +-- instance types. type InstHead name = ([HsPred name], name, [HsType name]) + + type ModuleMap = Map Module Interface type InstIfaceMap = Map Module InstalledInterface type DocMap = Map Name (HsDoc DocName) @@ -215,7 +221,10 @@ data Interface = Interface { ifaceVisibleExports :: ![Name], -- | The instances exported by this module - ifaceInstances :: ![Instance] + ifaceInstances :: ![Instance], + + -- | Docs for instances defined in this module + ifaceInstanceDocMap :: Map Name (HsDoc Name) } |