aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2009-01-22 18:53:49 +0000
committerDavid Waern <david.waern@gmail.com>2009-01-22 18:53:49 +0000
commit2ca9f33e5147bf1499e578dd559b927752fce0cc (patch)
treeaab10b84ed002e56be5681605bce7ac1f810788e /src/Haddock
parentfdceb0b527144c33bce39a1165c97cfa073a0c74 (diff)
Fix Trac #50: do not attach docs to pragmas or other kinds of non-declarations
We now filter out everything that is not a proper Haskell declaration before collecting the docs and attaching them to declarations.
Diffstat (limited to 'src/Haddock')
-rw-r--r--src/Haddock/Interface/Create.hs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs
index e2180f6d..8216b9e8 100644
--- a/src/Haddock/Interface/Create.hs
+++ b/src/Haddock/Interface/Create.hs
@@ -198,18 +198,19 @@ topDecls = filterClasses . filterDecls . collectDocs . sortByLoc . declsFromGrou
filterOutInstances = filter (\(L _ d, _, _) -> not (isInstD d))
--- | Take all declarations in an 'HsGroup' and convert them into a list of
--- 'Decl's
+-- | Take all declarations except pragmas, infix decls, rules and value
+-- bindings from an 'HsGroup'.
declsFromGroup :: HsGroup Name -> [Decl]
--- TODO: actually take all declarations
declsFromGroup group =
- decls hs_tyclds TyClD group ++
- decls hs_fords ForD group ++
- decls hs_docs DocD group ++
- decls hs_instds InstD group ++
- decls (sigs . hs_valds) SigD group
+ decls hs_tyclds TyClD group ++
+ decls hs_derivds DerivD group ++
+ decls hs_defds DefD group ++
+ decls hs_fords ForD group ++
+ decls hs_docs DocD group ++
+ decls hs_instds InstD group ++
+ decls (typesigs . hs_valds) SigD group
where
- sigs (ValBindsOut _ x) = x
+ typesigs (ValBindsOut _ sigs) = filter isVanillaLSig sigs
-- | Take a field of declarations from a data structure and create HsDecls
@@ -283,9 +284,6 @@ filterClasses decls = [ if isClassD d then (L loc (filterClass d), doc) else x
-- | Collect the docs and attach them to the right declaration.
--- Ideally, input should contain all kinds of declarations, so that we don't
--- attach docs to the wrong declaration. An exception to this is function and
--- value declarations - we assume (for now) that they are not part of the input.
collectDocs :: [Decl] -> [(Decl, (Maybe Doc))]
collectDocs decls = collect Nothing DocEmpty decls