aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Haddock/Interface/Create.hs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs
index a72c7ce3..a432ad4a 100644
--- a/src/Haddock/Interface/Create.hs
+++ b/src/Haddock/Interface/Create.hs
@@ -213,17 +213,19 @@ declName (ForD (ForeignImport n _ _)) = unLoc n
declName (SigD sig) = fromJust $ sigNameNoLoc sig
--- All the top-level declarations of a module, ordered by source location,
--- with documentation attached if it exists.
+-- | The top-level declarations of a module that we care about,
+-- ordered by source location, with documentation attached if it exists.
topDecls :: HsGroup Name -> [DeclWithDoc]
-topDecls = collectDocs . sortByLoc . declsFromGroup
+topDecls = filterDecls . collectDocs . sortByLoc . declsFromGroup
filterOutInstances = filter (\(L _ d, _) -> not (isInstance d))
--- | Pick out the declarations that we want from a group
+-- | Take all declarations in an 'HsGroup' and convert them into a list of
+-- 'LHsDecl's
declsFromGroup :: HsGroup Name -> [LHsDecl Name]
+-- TODO: actually take all declarations
declsFromGroup group =
decls hs_tyclds TyClD group ++
decls hs_fords ForD group ++
@@ -234,6 +236,15 @@ declsFromGroup group =
sigs (ValBindsOut _ x) = x
+-- | Filter out declarations that we don't handle in Haddock
+filterDecls :: [DeclWithDoc] -> [DeclWithDoc]
+filterDecls decls = filter (isHandled . unL . fst) decls
+ where
+ -- TODO: filter out exactly everything we don't handle
+ isHandled (ForD (ForeignExport {})) = False
+ isHandled _ = True
+
+
-- | Take a field of declarations from a data structure and create HsDecls
-- using the given constructor
decls field con struct = [ L loc (con decl) | L loc decl <- field struct ]