diff options
Diffstat (limited to 'src/Haddock')
-rw-r--r-- | src/Haddock/Interface/Create.hs | 39 |
1 files 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 ] @@ -278,6 +266,29 @@ warnAboutFilteredDecls mod decls = do -------------------------------------------------------------------------------- +-- 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 -------------------------------------------------------------------------------- |