From 286a28681d96c79683a0280e4207362c39669332 Mon Sep 17 00:00:00 2001 From: David Waern Date: Sun, 3 Aug 2008 14:02:51 +0000 Subject: Filter out more declarations The previous refactorings in H.I.Create introduced a few bugs. Filtering of some types of declarations that we don't handle was removed. This patch fixes this. --- src/Haddock/Interface/Create.hs | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs index a432ad4a..8944ab7f 100644 --- a/src/Haddock/Interface/Create.hs +++ b/src/Haddock/Interface/Create.hs @@ -191,12 +191,9 @@ classDataSubs decl fields = concat [ fields | RecCon fields <- map con_details cons] --- All the sub declarations of a class (except default methods), ordered by +-- All the sub declarations of a class (that we handle), ordered by -- source location, with documentation attached if it exists. -classDecls = filter notDef . collectDocs . sortByLoc . declsFromClass - where - notDef (L _ (ValD _), _) = False - notDef _ = True +classDecls = filterDecls . collectDocs . sortByLoc . declsFromClass declsFromClass class_ = docs ++ defs ++ sigs ++ ats @@ -236,15 +233,6 @@ 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 ] @@ -277,6 +265,29 @@ warnAboutFilteredDecls mod decls = do ++ "following instances:\n" ++ (concat $ intersperse ", " instances) ] +-------------------------------------------------------------------------------- +-- Filtering of declarations +-- +-- We filter out declarations that we don't intend to handle later. +-------------------------------------------------------------------------------- + + +-- | 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 (SigD d) = isHandledSig d + isHandled (ValD d) = False + isHandled _ = True + + +-- | Is the 'Sig' handled by Haddock? +isHandledSig (TypeSig {}) = True +isHandledSig _ = False + + -------------------------------------------------------------------------------- -- Instances -------------------------------------------------------------------------------- -- cgit v1.2.3