aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Interface/Create.hs
diff options
context:
space:
mode:
authorSimon Hengel <sol@typeful.net>2012-01-12 12:50:36 +0100
committerDavid Waern <david.waern@gmail.com>2012-02-04 00:50:13 +0100
commit3dcda28c5a30652bd9ad8b69d996d8d0990902f5 (patch)
tree2421ae517f6cb03f1b40f9d97f02d3d443053658 /src/Haddock/Interface/Create.hs
parentd327e3dfea1dda473c065b0e6a7da2161c9e6668 (diff)
Add support for module warnings
Diffstat (limited to 'src/Haddock/Interface/Create.hs')
-rw-r--r--src/Haddock/Interface/Create.hs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs
index 2bca57d0..2f8e1f01 100644
--- a/src/Haddock/Interface/Create.hs
+++ b/src/Haddock/Interface/Create.hs
@@ -35,6 +35,8 @@ import HscTypes
import Name
import Bag
import RdrName (GlobalRdrEnv)
+import TcRnTypes (tcg_warns)
+import FastString (unpackFS)
-- | Use a 'TypecheckedModule' to produce an 'Interface'.
@@ -49,6 +51,7 @@ createInterface tm flags modMap instIfaceMap = do
dflags = ms_hspp_opts ms
instances = modInfoInstances mi
exportedNames = modInfoExports mi
+ warnings = tcg_warns . fst . tm_internals_ $ tm
-- The renamed source should always be available to us, but it's best
-- to be on the safe side.
@@ -68,7 +71,9 @@ createInterface tm flags modMap instIfaceMap = do
| Flag_IgnoreAllExports `elem` flags = OptIgnoreExports : opts0
| otherwise = opts0
- (info, mbDoc) <- liftErrMsg $ lexParseRnHaddockModHeader dflags gre mayDocHeader
+ (info, mbDoc) <- do
+ (i, d) <- liftErrMsg $ lexParseRnHaddockModHeader dflags gre mayDocHeader
+ return (i, addModuleWarnig warnings d)
let declsWithDocs = topDecls group_
(decls, _) = unzip declsWithDocs
@@ -125,6 +130,20 @@ createInterface tm flags modMap instIfaceMap = do
}
+warningToDoc :: WarningTxt -> Doc id
+warningToDoc w = case w of
+ (DeprecatedTxt msg) -> format "Deprecated: " msg
+ (WarningTxt msg) -> format "Warning: " msg
+ where
+ format x xs = DocWarning . DocParagraph . DocString . concat $ x : map unpackFS xs
+
+
+addModuleWarnig :: Warnings -> Maybe (Doc id) -> Maybe (Doc id)
+addModuleWarnig warnings
+ | WarnAll w <- warnings = let d = warningToDoc w in Just . maybe d (mappend d)
+ | otherwise = id
+
+
-------------------------------------------------------------------------------
-- Doc options
--