From d9c0ac268c5f08c35a3c8a8fc792a07757182cda Mon Sep 17 00:00:00 2001 From: Simon Hengel Date: Thu, 12 Jan 2012 17:44:45 +0100 Subject: Expand type signatures for modules without explicit export list --- src/Haddock/Interface/Create.hs | 15 +- tests/html-tests/tests/BugDeprecated.hs | 18 ++ tests/html-tests/tests/BugDeprecated.html.ref | 192 +++++++++++++++++++++ tests/html-tests/tests/mini_BugDeprecated.html.ref | 61 +++++++ 4 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 tests/html-tests/tests/BugDeprecated.hs create mode 100644 tests/html-tests/tests/BugDeprecated.html.ref create mode 100644 tests/html-tests/tests/mini_BugDeprecated.html.ref diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs index eb0d5f0d..2d903133 100644 --- a/src/Haddock/Interface/Create.hs +++ b/src/Haddock/Interface/Create.hs @@ -641,8 +641,21 @@ moduleExports thisMod expMod dflags gre _exports decls ifaceMap instIfaceMap map fullModuleContents :: DynFlags -> GlobalRdrEnv -> Maps -> [LHsDecl Name] -> ErrMsgGhc [ExportItem Name] fullModuleContents dflags gre (docMap, argMap, subMap, declMap) decls = - liftM catMaybes $ mapM mkExportItem decls + liftM catMaybes $ mapM mkExportItem (expandSig decls) where + -- A type signature can have multiple names, like: + -- foo, bar :: Types.. + -- + -- We go through the list of declarations and expand type signatures, so + -- that every type signature has exactly one name! + expandSig :: [LHsDecl name] -> [LHsDecl name] + expandSig = foldr f [] + where + f :: LHsDecl name -> [LHsDecl name] -> [LHsDecl name] + f (L l (SigD (TypeSig names t))) xs = foldr (\n acc -> L l (SigD (TypeSig [n] t)) : acc) xs names + f (L l (SigD (GenericSig names t))) xs = foldr (\n acc -> L l (SigD (GenericSig [n] t)) : acc) xs names + f x xs = x : xs + mkExportItem (L _ (DocD (DocGroup lev docStr))) = do mbDoc <- liftErrMsg $ lexParseRnHaddockComment dflags DocSectionComment gre docStr return $ fmap (ExportGroup lev "") mbDoc diff --git a/tests/html-tests/tests/BugDeprecated.hs b/tests/html-tests/tests/BugDeprecated.hs new file mode 100644 index 00000000..0f7ac2eb --- /dev/null +++ b/tests/html-tests/tests/BugDeprecated.hs @@ -0,0 +1,18 @@ +module BugDeprecated where + +foo, bar, baz :: Int +foo = 23 +bar = 23 +baz = 23 +{-# DEPRECATED foo "for foo" #-} +{-# DEPRECATED bar "for bar" #-} +{-# DEPRECATED baz "for baz" #-} + +-- | some documentation for one, two and three +one, two, three :: Int +one = 23 +two = 23 +three = 23 +{-# DEPRECATED one "for one" #-} +{-# DEPRECATED two "for two" #-} +{-# DEPRECATED three "for three" #-} diff --git a/tests/html-tests/tests/BugDeprecated.html.ref b/tests/html-tests/tests/BugDeprecated.html.ref new file mode 100644 index 00000000..394ce279 --- /dev/null +++ b/tests/html-tests/tests/BugDeprecated.html.ref @@ -0,0 +1,192 @@ + +BugDeprecated

 

Safe HaskellNone

BugDeprecated

Synopsis

Documentation

foo :: Int

Deprecated: for foo

baz :: Int

Deprecated: for baz

bar :: Int

Deprecated: for bar

one :: Int

Deprecated: for one

some documentation for one, two and three +

three :: Int

Deprecated: for three

some documentation for one, two and three +

two :: Int

Deprecated: for two

some documentation for one, two and three +

diff --git a/tests/html-tests/tests/mini_BugDeprecated.html.ref b/tests/html-tests/tests/mini_BugDeprecated.html.ref new file mode 100644 index 00000000..f0410137 --- /dev/null +++ b/tests/html-tests/tests/mini_BugDeprecated.html.ref @@ -0,0 +1,61 @@ + +BugDeprecated

BugDeprecated

-- cgit v1.2.3