and so should this
+because there's a space before closing @
+
this should
+> be dropped
+
+@
+ and so should this
+ because there's a space before closing @
+ @
+-}
+g :: ()
+g = ()
diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs
index cd7bb02..bd5cd20 100644
--- a/src/Haddock/Parser.hs
+++ b/src/Haddock/Parser.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE StandaloneDeriving
, FlexibleInstances, UndecidableInstances
, IncoherentInstances #-}
+{-# LANGUAGE LambdaCase #-}
-- |
-- Module : Haddock.Parser
-- Copyright : (c) Mateusz Kowalczyk 2013,
@@ -21,7 +22,7 @@ import Control.Applicative
import Data.Attoparsec.ByteString.Char8 hiding (parse, take, endOfLine)
import qualified Data.ByteString.Char8 as BS
import Data.Char (chr, isAsciiUpper)
-import Data.List (stripPrefix, intercalate)
+import Data.List (stripPrefix, intercalate, unfoldr)
import Data.Maybe (fromMaybe)
import Data.Monoid
import DynFlags
@@ -59,7 +60,8 @@ parseParas d = parse (p <* skipSpace) . encodeUtf8 . (++ "\n")
p :: Parser (Doc RdrName)
p = mconcat <$> paragraph d `sepBy` many (skipHorizontalSpace *> "\n")
--- | Parse a text paragraph.
+-- | Parse a text paragraph. Actually just a wrapper over 'parseStringBS' which
+-- drops leading whitespace and encodes the string to UTF8 first.
parseString :: DynFlags -> String -> Doc RdrName
parseString d = parseStringBS d . encodeUtf8 . dropWhile isSpace
@@ -366,8 +368,31 @@ property = DocProperty . strip . decodeUtf8 <$> ("prop>" *> takeWhile1 (/= '\n')
-- for markup.
codeblock :: DynFlags -> Parser (Doc RdrName)
codeblock d =
- DocCodeBlock . parseStringBS d <$> ("@" *> skipHorizontalSpace *> "\n" *> block' <* "@")
+ DocCodeBlock . parseStringBS d . dropSpaces
+ <$> ("@" *> skipHorizontalSpace *> "\n" *> block' <* "@")
where
+ dropSpaces xs =
+ let rs = decodeUtf8 xs
+ in case splitByNl rs of
+ [] -> xs
+ ys -> case last ys of
+ ' ':_ -> case mapM dropSpace ys of
+ Nothing -> xs
+ Just zs -> encodeUtf8 $ intercalate "\n" zs
+ _ -> xs
+
+ -- This is necessary because ?lines? swallows up a trailing newline
+ -- and we lose information about whether the last line belongs to @ or to
+ -- text which we need to decide whether we actually want to be dropping
+ -- anything at all.
+ splitByNl = unfoldr (\case '\n':s -> Just (span (/= '\n') s)
+ _ -> Nothing)
+ . ('\n' :)
+
+ dropSpace "" = Just ""
+ dropSpace (' ':xs) = Just xs
+ dropSpace _ = Nothing
+
block' = scan False p
where
p isNewline c
diff --git a/test/Haddock/ParserSpec.hs b/test/Haddock/ParserSpec.hs
index db843cc..f44b7d0 100644
--- a/test/Haddock/ParserSpec.hs
+++ b/test/Haddock/ParserSpec.hs
@@ -432,12 +432,34 @@ spec = before initStaticOpts $ do
] `shouldParseTo` DocCodeBlock "foo\n@\nbar\n"
it "accepts horizontal space before the @" $ do
+ unlines [ " @"
+ , "foo"
+ , ""
+ , "bar"
+ , "@"
+ ] `shouldParseTo` DocCodeBlock "foo\n\nbar\n"
+
+ it "strips a leading space from a @ block if present" $ do
+ unlines [ " @"
+ , " hello"
+ , " world"
+ , " @"
+ ] `shouldParseTo` DocCodeBlock "hello\nworld\n"
+
unlines [ " @"
- , " foo"
+ , " hello"
, ""
- , " bar"
+ , " world"
, " @"
- ] `shouldParseTo` DocCodeBlock " foo\n\n bar\n "
+ ] `shouldParseTo` DocCodeBlock "hello\n\nworld\n"
+
+ it "only drops whitespace if there's some before closing @" $ do
+ unlines [ "@"
+ , " Formatting"
+ , " matters."
+ , "@"
+ ]
+ `shouldParseTo` DocCodeBlock " Formatting\n matters.\n"
it "accepts unicode" $ do
"@foo ?????? bar@" `shouldParseTo` DocCodeBlock "foo ?????? bar"
From git at git.haskell.org Tue Apr 1 18:08:37 2014
From: git at git.haskell.org (git at git.haskell.org)
Date: Tue, 1 Apr 2014 18:08:37 +0000 (UTC)
Subject: [commit: haddock] v2.14: Crash when exporting record selectors of
data family instances (32c8d6c)
Message-ID: <20140401180837.58B0C2406B@ghc.haskell.org>
Repository : ssh://git at git.haskell.org/haddock
On branch : v2.14
Link : http://git.haskell.org/haddock.git/commitdiff/32c8d6c36798a0d70f477ee56cc14099ee3c723c
>---------------------------------------------------------------
commit 32c8d6c36798a0d70f477ee56cc14099ee3c723c
Author: Niklas Haas
Date: Mon Mar 31 20:02:36 2014 +0200
Crash when exporting record selectors of data family instances
This fixes bug #294.
This also fixes a related but never-before-mentioned bug about the
display of GADT record selectors with non-polymorphic type signatures.
Note: Associated data type constructors fail to show up if nothing is
exported that they could be attached to. Exporting any of the data types
in the instance head, or the class + data family itself, causes them to
show up, but in the absence of either of these, exporting just the
associated data type with the constructor itself will result in it
being hidden.
The only scenario I can come up that would involve this kind of
situation involved OverlappingInstances, and even then it can be
mitigated by just exporting the class itself, so I'm not going to solve
it since the logic would most likely be very complicated.
>---------------------------------------------------------------
32c8d6c36798a0d70f477ee56cc14099ee3c723c
.../ref/{HiddenInstances.html => Bug294.html} | 148 ++++++++++----------
html-test/src/Bug294.hs | 37 +++++
src/Haddock/Interface/Create.hs | 34 +++--
3 files changed, 136 insertions(+), 83 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 32c8d6c36798a0d70f477ee56cc14099ee3c723c
From git at git.haskell.org Tue Apr 1 18:08:39 2014
From: git at git.haskell.org (git at git.haskell.org)
Date: Tue, 1 Apr 2014 18:08:39 +0000 (UTC)
Subject: [commit: haddock] v2.14: Fix a few typos (0ca96fb)
Message-ID: <20140401180839.72D062406B@ghc.haskell.org>
Repository : ssh://git at git.haskell.org/haddock
On branch : v2.14
Link : http://git.haskell.org/haddock.git/commitdiff/0ca96fb4a79265bac69473b46bb62489e43d397f
>---------------------------------------------------------------
commit 0ca96fb4a79265bac69473b46bb62489e43d397f
Author: Herbert Valerio Riedel
Date: Sun Mar 23 18:01:01 2014 +0100
Fix a few typos
Signed-off-by: Herbert Valerio Riedel
>---------------------------------------------------------------
0ca96fb4a79265bac69473b46bb62489e43d397f
CHANGES | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/CHANGES b/CHANGES
index a98a0e0..7929160 100644
--- a/CHANGES
+++ b/CHANGES
@@ -96,7 +96,7 @@ Changes in version 2.11.0
* Improved --qual option (no crashes, proper error messages)
- * A new --qual option "aliased" which qualifies identifers by the module alias
+ * A new --qual option "aliased" which qualifies identifiers by the module alias
used in the source code
* The Haddock API restores GHC's static flags after invocation
@@ -275,7 +275,7 @@ Changed in version 2.5.0:
* Add --use-unicode flag for displaying prettier versions of common symbols
- * Mutiple verbosity levels: remove --verbose and add --verbosity=n
+ * Multiple verbosity levels: remove --verbose and add --verbosity=n
-----------------------------------------------------------------------------
@@ -304,7 +304,7 @@ Changed in version 2.4.2:
* Do not indicate that a constructor argument is unboxed
- * Fix problem with with non-working links to ghc-prim
+ * Fix problem with non-working links to ghc-prim
* Allow referring to a specific section within a module in a module link
(#65)
@@ -400,7 +400,7 @@ Changes in version 2.0.0.0:
* Haddock can generate documentation for some of the language extensions
in GHC 6.8.2
- * Format of module attributes has changed. The only way of specifiying
+ * Format of module attributes has changed. The only way of specifying
module attributes is via a new OPTIONS_HADDOCK pragma. Example:
{-# OPTIONS_HADDOCK hide, prune #-}
From git at git.haskell.org Tue Apr 1 18:08:41 2014
From: git at git.haskell.org (git at git.haskell.org)
Date: Tue, 1 Apr 2014 18:08:41 +0000 (UTC)
Subject: [commit: haddock] v2.14: Print kind signatures on GADTs (72d5d54)
Message-ID: <20140401180842.186562406B@ghc.haskell.org>
Repository : ssh://git at git.haskell.org/haddock
On branch : v2.14
Link : http://git.haskell.org/haddock.git/commitdiff/72d5d5490a324d3599085a009ce2d45a076988b6
>---------------------------------------------------------------
commit 72d5d5490a324d3599085a009ce2d45a076988b6
Author: Mateusz Kowalczyk
Date: Tue Apr 1 18:44:47 2014 +0100
Print kind signatures on GADTs
>---------------------------------------------------------------
72d5d5490a324d3599085a009ce2d45a076988b6
CHANGES | 4 ++
html-test/ref/AdvanceTypes.html | 2 +-
html-test/ref/{Ticket253_2.html => Bug85.html} | 86 +++++++++++++++---------
html-test/src/Bug85.hs | 15 +++++
src/Haddock/Backends/Xhtml/Decl.hs | 16 +++--
5 files changed, 85 insertions(+), 38 deletions(-)
diff --git a/CHANGES b/CHANGES
index 7929160..d587201 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+Changes in version 2.14.2
+
+ * Print kind signatures GADTs (#85)
+
Changes in version 2.14.1
* Render * and -> with their UnicodeSyntax equivalents if -U is enabled
diff --git a/html-test/ref/AdvanceTypes.html b/html-test/ref/AdvanceTypes.html
index 489b6e1..b594321 100644
--- a/html-test/ref/AdvanceTypes.html
+++ b/html-test/ref/AdvanceTypes.html
@@ -50,7 +50,7 @@ window.onload = function () {pageLoad();setSynopsis("mini_AdvanceTypes.html");};
>data Pattern :: [*] -> * where
) :: (a -> a) -> a -> a
+x <^> y = x y
+
+(<^) :: a -> a -> a
+x <^ y = x
+
+(^>) :: a -> a -> a
+x ^> y = y
+
+(?^) :: a -> a -> a
+x ?^ y = y
+
+-- | Links to '<^>' and '^>', '<^' and '?^'.
+f :: ()
+f = ()
diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs
index bd5cd20..ece9291 100644
--- a/src/Haddock/Parser.hs
+++ b/src/Haddock/Parser.hs
@@ -419,13 +419,21 @@ autoUrl = mkLink <$> url
-- characters and does no actual validation itself.
parseValid :: Parser String
parseValid = do
- vs <- many' $ satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:") <|> digit <|> letter_ascii
+ vs' <- many' $ utf8String "?" <|> return <$> idChar
+ let vs = concat vs'
c <- peekChar
case c of
Just '`' -> return vs
Just '\'' -> (\x -> vs ++ "'" ++ x) <$> ("'" *> parseValid)
<|> return vs
_ -> fail "outofvalid"
+ where
+ idChar = satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:^")
+ <|> digit <|> letter_ascii
+
+-- | Parses UTF8 strings from ByteString streams.
+utf8String :: String -> Parser String
+utf8String x = decodeUtf8 <$> string (encodeUtf8 x)
-- | Parses identifiers with help of 'parseValid'. Asks GHC for 'RdrName' from the
-- string it deems valid.
From git at git.haskell.org Fri Apr 11 18:04:03 2014
From: git at git.haskell.org (git at git.haskell.org)
Date: Fri, 11 Apr 2014 18:04:03 +0000 (UTC)
Subject: [commit: haddock] v2.14: We don't actually want unicode here (99e3705)
Message-ID: <20140411180404.9173024069@ghc.haskell.org>
Repository : ssh://git at git.haskell.org/haddock
On branch : v2.14
Link : http://git.haskell.org/haddock.git/commitdiff/99e37051a544a2abd801f4ec69106bcb93f9e508
>---------------------------------------------------------------
commit 99e37051a544a2abd801f4ec69106bcb93f9e508
Author: Mateusz Kowalczyk
Date: Fri Apr 11 16:52:23 2014 +0100
We don't actually want unicode here
>---------------------------------------------------------------
99e37051a544a2abd801f4ec69106bcb93f9e508
html-test/src/Bug85.hs | 1 -
1 file changed, 1 deletion(-)
diff --git a/html-test/src/Bug85.hs b/html-test/src/Bug85.hs
index 9c5b768..e29b266 100644
--- a/html-test/src/Bug85.hs
+++ b/html-test/src/Bug85.hs
@@ -1,5 +1,4 @@
{-# LANGUAGE GADTs, KindSignatures #-}
-{-# OPTIONS_HADDOCK use-unicode #-}
module Bug85 where
-- explicitly stated non-trivial kind
From git at git.haskell.org Fri Apr 11 18:04:01 2014
From: git at git.haskell.org (git at git.haskell.org)
Date: Fri, 11 Apr 2014 18:04:01 +0000 (UTC)
Subject: [commit: haddock] v2.14: Version bump. (c1e330f)
Message-ID: <20140411180404.76F372406D@ghc.haskell.org>
Repository : ssh://git at git.haskell.org/haddock
On branch : v2.14
Link : http://git.haskell.org/haddock.git/commitdiff/c1e330fb1fcef3dc0b8431029b97f0bc41651a3c
>---------------------------------------------------------------
commit c1e330fb1fcef3dc0b8431029b97f0bc41651a3c
Author: Mateusz Kowalczyk
Date: Fri Apr 11 18:48:39 2014 +0100
Version bump.
>---------------------------------------------------------------
c1e330fb1fcef3dc0b8431029b97f0bc41651a3c
doc/haddock.xml | 2 +-
haddock.cabal | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/haddock.xml b/doc/haddock.xml
index da89ab2..98df2c9 100644
--- a/doc/haddock.xml
+++ b/doc/haddock.xml
@@ -21,7 +21,7 @@
Simon Marlow, David Waern
- This document describes Haddock version 2.14.1, a Haskell
+ This document describes Haddock version 2.14.3, a Haskell
documentation tool.
diff --git a/haddock.cabal b/haddock.cabal
index 4814331..d070460 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -1,5 +1,5 @@
name: haddock
-version: 2.14.2
+version: 2.14.3
synopsis: A documentation-generation tool for Haskell libraries
description: Haddock is a documentation-generation tool for Haskell
libraries
From git at git.haskell.org Fri Apr 11 18:04:05 2014
From: git at git.haskell.org (git at git.haskell.org)
Date: Fri, 11 Apr 2014 18:04:05 +0000 (UTC)
Subject: [commit: haddock] v2.14: Ignore version string during HTML tests.
(4e9aa92)
Message-ID: <20140411180406.09D8A2406B@ghc.haskell.org>
Repository : ssh://git at git.haskell.org/haddock
On branch : v2.14
Link : http://git.haskell.org/haddock.git/commitdiff/4e9aa92d769ea334867e621033ca27cd6a284d3a
>---------------------------------------------------------------
commit 4e9aa92d769ea334867e621033ca27cd6a284d3a
Author: Mateusz Kowalczyk
Date: Fri Apr 11 18:47:41 2014 +0100
Ignore version string during HTML tests.
>---------------------------------------------------------------
4e9aa92d769ea334867e621033ca27cd6a284d3a
html-test/run.lhs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/html-test/run.lhs b/html-test/run.lhs
index e4c83da..153ab32 100755
--- a/html-test/run.lhs
+++ b/html-test/run.lhs
@@ -134,9 +134,21 @@ check modules strict = do
else do
putStrLn $ "Pass: " ++ mod ++ " (no .ref file)"
+-- | A rather nasty way to drop the Haddock version string from the
+-- end of the generated HTML files so that we don't have to change
+-- every single test every time we change versions. We rely on the the
+-- last paragraph of the document to be the version. We end up with
+-- malformed HTML but we don't care as we never look at it ourselves.
+dropVersion :: String -> String
+dropVersion = reverse . dropTillP . reverse
+ where
+ dropTillP [] = []
+ dropTillP ('p':'<':xs) = xs
+ dropTillP (_:xs) = dropTillP xs
haddockEq :: String -> String -> Bool
-haddockEq file1 file2 = stripLinks file1 == stripLinks file2
+haddockEq file1 file2 =
+ stripLinks (dropVersion file1) == stripLinks (dropVersion file2)
stripLinks :: String -> String
stripLinks str =
From git at git.haskell.org Fri Apr 11 18:04:08 2014
From: git at git.haskell.org (git at git.haskell.org)
Date: Fri, 11 Apr 2014 18:04:08 +0000 (UTC)
Subject: [commit: haddock] v2.14: Parse identifiers with ^ and ⋆ in them. (81c379d)
Message-ID: <20140411180408.388C72406B@ghc.haskell.org>
Repository : ssh://git at git.haskell.org/haddock
On branch : v2.14
Link : http://git.haskell.org/haddock.git/commitdiff/81c379daddb0e46c1f62cef5f34e933d481ec4a7
>---------------------------------------------------------------
commit 81c379daddb0e46c1f62cef5f34e933d481ec4a7
Author: Mateusz Kowalczyk
Date: Fri Apr 11 16:58:34 2014 +0100
Parse identifiers with ^ and ? in them.
Fixes #298.
>---------------------------------------------------------------
81c379daddb0e46c1f62cef5f34e933d481ec4a7
CHANGES | 4 ++
html-test/ref/{Bug201.html => Bug298.html} | 89 +++++++++++++++++++---------
html-test/src/Bug298.hs | 22 +++++++
src/Haddock/Parser.hs | 10 +++-
4 files changed, 95 insertions(+), 30 deletions(-)
diff --git a/CHANGES b/CHANGES
index b3fb8dc..1fe0249 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+Changes in version 2.14.3
+
+ * Fix parsing of identifiers with ^ or ? in them (#298)
+
Changes in version 2.14.2
* Always drop --split-objs GHC flag for performance reasons (#292)
diff --git a/html-test/ref/Bug201.html b/html-test/ref/Bug298.html
similarity index 56%
copy from html-test/ref/Bug201.html
copy to html-test/ref/Bug298.html
index 8b596cf..03ed5ee 100644
--- a/html-test/ref/Bug201.html
+++ b/html-test/ref/Bug298.html
@@ -3,13 +3,13 @@
>Bug201Bug298