diff options
author | David Waern <david.waern@gmail.com> | 2008-08-03 11:42:59 +0000 |
---|---|---|
committer | David Waern <david.waern@gmail.com> | 2008-08-03 11:42:59 +0000 |
commit | ae0011a4761c0e6d935ecd5781e97b9d19d08782 (patch) | |
tree | 48ceeee4e57267e3ffcbd55f5a7f921394d2c9ba | |
parent | f624c3a9cba921a8a9d415ab635470c9d61e8273 (diff) |
Filter out ForeignExports
-rw-r--r-- | src/Haddock/Interface/Create.hs | 19 |
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 ] |