[commit: haddock] ghc-7.6: Properly handle deprecation messages for re-exported things (fixes #220) (37a4e2c)

Simon Hengel <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/haddock

On branch  : ghc-7.6

http://hackage.haskell.org/trac/ghc/changeset/37a4e2c3b71280fdee7b217dd9ddff090ed34873

>---------------------------------------------------------------

commit 37a4e2c3b71280fdee7b217dd9ddff090ed34873
Author: Simon Hengel <[email protected]>
Date:   Sun Oct 14 16:03:43 2012 +0200

    Properly handle deprecation messages for re-exported things (fixes #220)

>---------------------------------------------------------------

 src/Haddock/Interface/Create.hs                    |    7 ++++---
 src/Haddock/Types.hs                               |    5 +++++
 tests/html-tests/tests/DeprecatedReExport.hs       |    3 +++
 ...ction2.html.ref => DeprecatedReExport.html.ref} |   15 +++++++++++----
 ...4.html.ref => mini_DeprecatedReExport.html.ref} |    4 ++--
 5 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs
index 2ffe8de..6c121ad 100644
--- a/src/Haddock/Interface/Create.hs
+++ b/src/Haddock/Interface/Create.hs
@@ -92,7 +92,9 @@ createInterface tm flags modMap instIfaceMap = do
 
   warningMap <- liftErrMsg $ mkWarningMap dflags warnings gre exportedNames
 
-  exportItems <- mkExportItems modMap mdl warningMap gre exportedNames decls maps exports
+  let allWarnings = M.unions (warningMap : map ifaceWarningMap (M.elems modMap))
+
+  exportItems <- mkExportItems modMap mdl allWarnings gre exportedNames decls maps exports
                    instances instIfaceMap dflags
 
   let !visibleNames = mkVisibleNames exportItems opts
@@ -135,6 +137,7 @@ createInterface tm flags modMap instIfaceMap = do
   , ifaceModuleAliases   = aliases
   , ifaceInstances       = instances
   , ifaceHaddockCoverage = coverage
+  , ifaceWarningMap      = warningMap
   }
 
 mkAliasMap :: DynFlags -> Maybe RenamedSource -> M.Map Module ModuleName
@@ -170,8 +173,6 @@ lookupModuleDyn dflags Nothing mdlName =
 -- Warnings
 -------------------------------------------------------------------------------
 
-type WarningMap = DocMap Name
-
 mkWarningMap :: DynFlags -> Warnings -> GlobalRdrEnv -> [Name] -> ErrMsgM WarningMap
 mkWarningMap dflags warnings gre exps = case warnings of
   NoWarnings  -> return M.empty
diff --git a/src/Haddock/Types.hs b/src/Haddock/Types.hs
index 9be4674..181ea02 100644
--- a/src/Haddock/Types.hs
+++ b/src/Haddock/Types.hs
@@ -114,8 +114,13 @@ data Interface = Interface
     -- | The number of haddockable and haddocked items in the module, as a
     -- tuple. Haddockable items are the exports and the module itself.
   , ifaceHaddockCoverage :: !(Int, Int)
+
+    -- | Warnings for things defined in this module.
+  , ifaceWarningMap :: !WarningMap
   }
 
+type WarningMap = DocMap Name
+
 
 -- | A subset of the fields of 'Interface' that we store in the interface
 -- files.
diff --git a/tests/html-tests/tests/DeprecatedReExport.hs b/tests/html-tests/tests/DeprecatedReExport.hs
new file mode 100644
index 0000000..10a8c6a
--- /dev/null
+++ b/tests/html-tests/tests/DeprecatedReExport.hs
@@ -0,0 +1,3 @@
+module DeprecatedReExport (foo) where
+
+import DeprecatedFunction
diff --git a/tests/html-tests/tests/DeprecatedFunction2.html.ref b/tests/html-tests/tests/DeprecatedReExport.html.ref
similarity index 89%
copy from tests/html-tests/tests/DeprecatedFunction2.html.ref
copy to tests/html-tests/tests/DeprecatedReExport.html.ref
index b5068c8..1798895 100644
--- a/tests/html-tests/tests/DeprecatedFunction2.html.ref
+++ b/tests/html-tests/tests/DeprecatedReExport.html.ref
@@ -3,13 +3,13 @@
 ><head
   ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
      /><title
-    >DeprecatedFunction2</title
+    >DeprecatedReExport</title
     ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
      /><script src="haddock-util.js" type="text/javascript"
     ></script
     ><script type="text/javascript"
     >//<![CDATA[
-window.onload = function () {pageLoad();setSynopsis("mini_DeprecatedFunction2.html");};
+window.onload = function () {pageLoad();setSynopsis("mini_DeprecatedReExport.html");};
 //]]>
 </script
     ></head
@@ -39,7 +39,7 @@ window.onload = function () {pageLoad();setSynopsis("mini_DeprecatedFunction2.ht
 	    ></tr
 	  ></table
 	><p class="caption"
-	>DeprecatedFunction2</p
+	>DeprecatedReExport</p
 	></div
       ><div id="synopsis"
       ><p id="control.syn" class="caption expander" onclick="toggleSection('syn')"
@@ -66,9 +66,16 @@ window.onload = function () {pageLoad();setSynopsis("mini_DeprecatedFunction2.ht
 	  ><div class="doc"
 	  ><div class="warning"
 	    ><p
-	      >Deprecated: use bar instead
+	      >Deprecated: use <code
+		><a href=""
+		  >bar</a
+		  ></code
+		> instead
 </p
 	      ></div
+	    ><p
+	    >some documentation for foo
+</p
 	    ></div
 	  ></div
 	></div
diff --git a/tests/html-tests/tests/mini_Bug4.html.ref b/tests/html-tests/tests/mini_DeprecatedReExport.html.ref
similarity index 92%
copy from tests/html-tests/tests/mini_Bug4.html.ref
copy to tests/html-tests/tests/mini_DeprecatedReExport.html.ref
index b403e94..de5dcf9 100644
--- a/tests/html-tests/tests/mini_Bug4.html.ref
+++ b/tests/html-tests/tests/mini_DeprecatedReExport.html.ref
@@ -3,7 +3,7 @@
 ><head
   ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
      /><title
-    >Bug4</title
+    >DeprecatedReExport</title
     ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
      /><script src="haddock-util.js" type="text/javascript"
     ></script
@@ -16,7 +16,7 @@ window.onload = function () {pageLoad();};
   ><body id="mini"
   ><div id="module-header"
     ><p class="caption"
-      >Bug4</p
+      >DeprecatedReExport</p
       ></div
     ><div id="interface"
     ><div class="top"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.