Repository : ssh://darcs.haskell.org//srv/darcs/haddock

On branch  : local

http://hackage.haskell.org/trac/ghc/changeset/38485aca06f9e4a162bd4f4cf13c2334f0057581

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

commit 38485aca06f9e4a162bd4f4cf13c2334f0057581
Author: Simon Hengel <[email protected]>
Date:   Thu Jan 12 17:44:45 2012 +0100

    Expand type signatures for modules without explicit export list

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

 src/Haddock/Interface/Create.hs                    |   15 +++-
 .../{BugExportHeadings.hs => BugDeprecated.hs}     |   21 +---
 ...ortHeadings.html.ref => BugDeprecated.html.ref} |  117 ++++++++------------
 ...i_Bug8.html.ref => mini_BugDeprecated.html.ref} |   22 ++--
 4 files changed, 75 insertions(+), 100 deletions(-)

diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs
index 0ab0e53..90597f6 100644
--- a/src/Haddock/Interface/Create.hs
+++ b/src/Haddock/Interface/Create.hs
@@ -638,8 +638,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/BugExportHeadings.hs 
b/tests/html-tests/tests/BugDeprecated.hs
similarity index 54%
copy from tests/html-tests/tests/BugExportHeadings.hs
copy to tests/html-tests/tests/BugDeprecated.hs
index a5493a0..0f7ac2e 100644
--- a/tests/html-tests/tests/BugExportHeadings.hs
+++ b/tests/html-tests/tests/BugDeprecated.hs
@@ -1,25 +1,14 @@
--- test for #192
-module BugExportHeadings (
--- * Foo
-  foo
--- * Bar
-, bar
--- * Baz
-, baz
-
--- * One
-, one
--- * Two
-, two
--- * Three
-, three
-) where
+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
diff --git a/tests/html-tests/tests/BugExportHeadings.html.ref 
b/tests/html-tests/tests/BugDeprecated.html.ref
similarity index 81%
copy from tests/html-tests/tests/BugExportHeadings.html.ref
copy to tests/html-tests/tests/BugDeprecated.html.ref
index 3705633..394ce27 100644
--- a/tests/html-tests/tests/BugExportHeadings.html.ref
+++ b/tests/html-tests/tests/BugDeprecated.html.ref
@@ -3,13 +3,13 @@
 ><head
   ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
      /><title
-    >BugExportHeadings</title
+    >BugDeprecated</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_BugExportHeadings.html");};
+window.onload = function () 
{pageLoad();setSynopsis("mini_BugDeprecated.html");};
 //]]>
 </script
     ></head
@@ -39,43 +39,7 @@ window.onload = function () 
{pageLoad();setSynopsis("mini_BugExportHeadings.html
            ></tr
          ></table
        ><p class="caption"
-       >BugExportHeadings</p
-       ></div
-      ><div id="table-of-contents"
-      ><p class="caption"
-       >Contents</p
-       ><ul
-       ><li
-         ><a href=""
-           >Foo
-</a
-           ></li
-         ><li
-         ><a href=""
-           >Bar
-</a
-           ></li
-         ><li
-         ><a href=""
-           >Baz
-</a
-           ></li
-         ><li
-         ><a href=""
-           >One
-</a
-           ></li
-         ><li
-         ><a href=""
-           >Two
-</a
-           ></li
-         ><li
-         ><a href=""
-           >Three
-</a
-           ></li
-         ></ul
+       >BugDeprecated</p
        ></div
       ><div id="synopsis"
       ><p id="control.syn" class="caption expander" 
onclick="toggleSection('syn')"
@@ -89,13 +53,13 @@ window.onload = function () 
{pageLoad();setSynopsis("mini_BugExportHeadings.html
            ></li
          ><li class="src short"
          ><a href=""
-           >bar</a
+           >baz</a
            > :: <a href=""
            >Int</a
            ></li
          ><li class="src short"
          ><a href=""
-           >baz</a
+           >bar</a
            > :: <a href=""
            >Int</a
            ></li
@@ -107,22 +71,21 @@ window.onload = function () 
{pageLoad();setSynopsis("mini_BugExportHeadings.html
            ></li
          ><li class="src short"
          ><a href=""
-           >two</a
+           >three</a
            > :: <a href=""
            >Int</a
            ></li
          ><li class="src short"
          ><a href=""
-           >three</a
+           >two</a
            > :: <a href=""
            >Int</a
            ></li
          ></ul
        ></div
       ><div id="interface"
-      ><h1 id="g:1"
-       >Foo
-</h1
+      ><h1
+       >Documentation</h1
        ><div class="top"
        ><p class="src"
          ><a name="v:foo" class="def"
@@ -130,32 +93,41 @@ window.onload = function () 
{pageLoad();setSynopsis("mini_BugExportHeadings.html
            > :: <a href=""
            >Int</a
            ></p
+         ><div class="doc"
+         ><div class="warning"
+           ><p
+             >Deprecated: for foo</p
+             ></div
+           ></div
          ></div
-       ><h1 id="g:2"
-       >Bar
-</h1
        ><div class="top"
        ><p class="src"
-         ><a name="v:bar" class="def"
-           >bar</a
+         ><a name="v:baz" class="def"
+           >baz</a
            > :: <a href=""
            >Int</a
            ></p
+         ><div class="doc"
+         ><div class="warning"
+           ><p
+             >Deprecated: for baz</p
+             ></div
+           ></div
          ></div
-       ><h1 id="g:3"
-       >Baz
-</h1
        ><div class="top"
        ><p class="src"
-         ><a name="v:baz" class="def"
-           >baz</a
+         ><a name="v:bar" class="def"
+           >bar</a
            > :: <a href=""
            >Int</a
            ></p
+         ><div class="doc"
+         ><div class="warning"
+           ><p
+             >Deprecated: for bar</p
+             ></div
+           ></div
          ></div
-       ><h1 id="g:4"
-       >One
-</h1
        ><div class="top"
        ><p class="src"
          ><a name="v:one" class="def"
@@ -168,40 +140,43 @@ window.onload = function () 
{pageLoad();setSynopsis("mini_BugExportHeadings.html
            ><p
              >Deprecated: for one</p
              ></div
+           ><p
+           >some documentation for one, two and three
+</p
            ></div
          ></div
-       ><h1 id="g:5"
-       >Two
-</h1
        ><div class="top"
        ><p class="src"
-         ><a name="v:two" class="def"
-           >two</a
+         ><a name="v:three" class="def"
+           >three</a
            > :: <a href=""
            >Int</a
            ></p
          ><div class="doc"
          ><div class="warning"
            ><p
-             >Deprecated: for two</p
+             >Deprecated: for three</p
              ></div
+           ><p
+           >some documentation for one, two and three
+</p
            ></div
          ></div
-       ><h1 id="g:6"
-       >Three
-</h1
        ><div class="top"
        ><p class="src"
-         ><a name="v:three" class="def"
-           >three</a
+         ><a name="v:two" class="def"
+           >two</a
            > :: <a href=""
            >Int</a
            ></p
          ><div class="doc"
          ><div class="warning"
            ><p
-             >Deprecated: for three</p
+             >Deprecated: for two</p
              ></div
+           ><p
+           >some documentation for one, two and three
+</p
            ></div
          ></div
        ></div
diff --git a/tests/html-tests/tests/mini_Bug8.html.ref 
b/tests/html-tests/tests/mini_BugDeprecated.html.ref
similarity index 86%
copy from tests/html-tests/tests/mini_Bug8.html.ref
copy to tests/html-tests/tests/mini_BugDeprecated.html.ref
index 070dbcf..f041013 100644
--- a/tests/html-tests/tests/mini_Bug8.html.ref
+++ b/tests/html-tests/tests/mini_BugDeprecated.html.ref
@@ -3,7 +3,7 @@
 ><head
   ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
      /><title
-    >Bug8</title
+    >BugDeprecated</title
     ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
      /><script src="haddock-util.js" type="text/javascript"
     ></script
@@ -16,45 +16,43 @@ window.onload = function () {pageLoad();};
   ><body id="mini"
   ><div id="module-header"
     ><p class="caption"
-      >Bug8</p
+      >BugDeprecated</p
       ></div
     ><div id="interface"
     ><div class="top"
       ><p class="src"
-       ><span class="keyword"
-         >data</span
-         > <a href="" target="main"
-         >Typ</a
-         > </p
+       ><a href="" target="main"
+         >foo</a
+         ></p
        ></div
       ><div class="top"
       ><p class="src"
        ><a href="" target="main"
-         >(--&gt;)</a
+         >baz</a
          ></p
        ></div
       ><div class="top"
       ><p class="src"
        ><a href="" target="main"
-         >(---&gt;)</a
+         >bar</a
          ></p
        ></div
       ><div class="top"
       ><p class="src"
        ><a href="" target="main"
-         >s</a
+         >one</a
          ></p
        ></div
       ><div class="top"
       ><p class="src"
        ><a href="" target="main"
-         >t</a
+         >three</a
          ></p
        ></div
       ><div class="top"
       ><p class="src"
        ><a href="" target="main"
-         >main</a
+         >two</a
          ></p
        ></div
       ></div



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to