From 7abad07c183af9710e14a96ce3a5ab982c2bbd50 Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Mon, 28 Jan 2019 16:23:28 -0800
Subject: Loosen 'QuickCheck' and 'hspec' bounds
It looks like the new versions don't cause any breakage
and loosening the bounds helps deps fit in one stack resolver.
---
haddock-library/haddock-library.cabal | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 0b4405b9..17f556aa 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -76,8 +76,8 @@ test-suite spec
, bytestring >= 0.9.2.1 && < 0.11
, containers >= 0.4.2.1 && < 0.7
, transformers >= 0.3.0 && < 0.6
- , hspec >= 2.4.4 && < 2.6
- , QuickCheck ^>= 2.11
+ , hspec >= 2.4.4 && < 2.7
+ , QuickCheck >= 2.11 && < 2.13
, text >= 1.2.3.0 && < 1.3
, parsec >= 3.1.13.0 && < 3.2
, deepseq >= 1.3 && < 1.5
--
cgit v1.2.3
From cacd245a5e0a0f2e14d4ed34e877835fdef3367f Mon Sep 17 00:00:00 2001
From: Oleg Grenrus
Date: Mon, 4 Feb 2019 18:44:25 +0200
Subject: Make a fixture of weird parsing of lists (#997)
The second example is interesting.
If there's a list directly after the header, and that list has
deeper structure, the parser is confused: It finds two lists:
- One with the first nested element,
- everything after it
I'm not trying to fix this, as I'm not even sure this is a bug,
and not a feature.
---
haddock-library/fixtures/examples/list-blocks1.input | 15 +++++++++++++++
haddock-library/fixtures/examples/list-blocks1.parsed | 12 ++++++++++++
haddock-library/fixtures/examples/list-blocks2.input | 10 ++++++++++
haddock-library/fixtures/examples/list-blocks2.parsed | 10 ++++++++++
haddock-library/haddock-library.cabal | 1 -
5 files changed, 47 insertions(+), 1 deletion(-)
create mode 100644 haddock-library/fixtures/examples/list-blocks1.input
create mode 100644 haddock-library/fixtures/examples/list-blocks1.parsed
create mode 100644 haddock-library/fixtures/examples/list-blocks2.input
create mode 100644 haddock-library/fixtures/examples/list-blocks2.parsed
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/haddock-library/fixtures/examples/list-blocks1.input b/haddock-library/fixtures/examples/list-blocks1.input
new file mode 100644
index 00000000..72a0640b
--- /dev/null
+++ b/haddock-library/fixtures/examples/list-blocks1.input
@@ -0,0 +1,15 @@
+* Something about foo
+
+ @
+ foo :: a -> b -> c
+ foo a b = bar c b
+ @
+
+* Something about bar
+
+ @
+ bar :: a -> b -> c
+ bar a b = foo b a
+ @
+
+* And then we continue
diff --git a/haddock-library/fixtures/examples/list-blocks1.parsed b/haddock-library/fixtures/examples/list-blocks1.parsed
new file mode 100644
index 00000000..9fc4f0ba
--- /dev/null
+++ b/haddock-library/fixtures/examples/list-blocks1.parsed
@@ -0,0 +1,12 @@
+DocUnorderedList
+ [DocAppend
+ (DocParagraph (DocString "Something about foo"))
+ (DocCodeBlock
+ (DocString
+ (concat ["foo :: a -> b -> c\n", "foo a b = bar c b\n"]))),
+ DocAppend
+ (DocParagraph (DocString "Something about bar"))
+ (DocCodeBlock
+ (DocString
+ (concat ["bar :: a -> b -> c\n", "bar a b = foo b a\n"]))),
+ DocParagraph (DocString "And then we continue")]
diff --git a/haddock-library/fixtures/examples/list-blocks2.input b/haddock-library/fixtures/examples/list-blocks2.input
new file mode 100644
index 00000000..91492adb
--- /dev/null
+++ b/haddock-library/fixtures/examples/list-blocks2.input
@@ -0,0 +1,10 @@
+=== Title
+
+* List directly
+* after the title
+
+ @
+ with some inline things
+ @
+
+* is parsed weirdly
diff --git a/haddock-library/fixtures/examples/list-blocks2.parsed b/haddock-library/fixtures/examples/list-blocks2.parsed
new file mode 100644
index 00000000..169677b7
--- /dev/null
+++ b/haddock-library/fixtures/examples/list-blocks2.parsed
@@ -0,0 +1,10 @@
+DocAppend
+ (DocAppend
+ (DocHeader
+ Header {headerLevel = 3, headerTitle = DocString "Title"})
+ (DocUnorderedList
+ [DocParagraph (DocString "List directly"),
+ DocAppend
+ (DocParagraph (DocString "after the title"))
+ (DocCodeBlock (DocString "with some inline things\n"))]))
+ (DocUnorderedList [DocParagraph (DocString "is parsed weirdly")])
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 17f556aa..32ffc110 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -91,7 +91,6 @@ test-suite fixtures
main-is: Fixtures.hs
ghc-options: -Wall -O0
hs-source-dirs: fixtures
- buildable: False
build-depends:
base >= 4.5 && < 4.13
, base-compat >= 0.9.3 && < 0.11
--
cgit v1.2.3
From a5199600c39d25d7b71dcb2328000c1c49ad95a2 Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Wed, 6 Feb 2019 01:01:41 -0800
Subject: Better identifier parsing
* '(<|>)' and '`elem`' now get parsed and rendered properly as links
* 'DbModule'/'DbUnitId' now properly get split apart into two links
* tuple names now get parsed properly
* some more small niceties...
The identifier parsing code is more precise and more efficient (although to be
fair: it is also longer and in its own module). On the rendering side, we need
to pipe through information about backticks/parens/neither all the way through
from renaming to the backends.
In terms of impact: a total of 35 modules in the entirety of the bootlib + ghc
lib docs change. The only "regression" is things like '\0'. These should be
changed to @\\0@ (the path by which this previously worked seems accidental).
---
doc/markup.rst | 9 +-
haddock-api/src/Haddock.hs | 2 +-
haddock-api/src/Haddock/Backends/Hoogle.hs | 2 +-
haddock-api/src/Haddock/Backends/LaTeX.hs | 19 +-
.../src/Haddock/Backends/Xhtml/DocMarkup.hs | 16 +-
haddock-api/src/Haddock/Backends/Xhtml/Names.hs | 28 +-
haddock-api/src/Haddock/Interface/Json.hs | 5 +-
haddock-api/src/Haddock/Interface/LexParseRn.hs | 58 +++--
haddock-api/src/Haddock/Interface/Rename.hs | 4 +-
haddock-api/src/Haddock/InterfaceFile.hs | 27 +-
haddock-api/src/Haddock/Parser.hs | 19 +-
haddock-api/src/Haddock/Types.hs | 28 +-
haddock-library/haddock-library.cabal | 2 +
.../src/Documentation/Haddock/Parser.hs | 63 +----
.../src/Documentation/Haddock/Parser/Identifier.hs | 186 ++++++++++++++
.../src/Documentation/Haddock/Parser/Monad.hs | 13 +-
.../test/Documentation/Haddock/ParserSpec.hs | 9 +-
haddock.cabal | 1 +
html-test/ref/Identifiers.html | 286 +++++++++++++++++++++
html-test/ref/Test.html | 2 +-
html-test/src/Identifiers.hs | 35 +++
21 files changed, 679 insertions(+), 135 deletions(-)
create mode 100644 haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
create mode 100644 html-test/ref/Identifiers.html
create mode 100644 html-test/src/Identifiers.hs
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/doc/markup.rst b/doc/markup.rst
index 48a6f4ad..56238855 100644
--- a/doc/markup.rst
+++ b/doc/markup.rst
@@ -932,14 +932,9 @@ necessary to escape the single quote when used as an apostrophe: ::
Nothing special is needed to hyperlink identifiers which contain
apostrophes themselves: to hyperlink ``foo'`` one would simply type
-``'foo''``. Hyperlinking operators works in exactly the same way.
+``'foo''``. Hyperlinking operators works in exactly the same way. ::
-Note that it is not possible to directly hyperlink an identifier in infix
-form or an operator in prefix form. The next best thing to do is to wrap
-the whole identifier in monospaced text and put the parentheses/backticks
-outside of the identifier, but inside the link: ::
-
- -- | A prefix operator @('++')@ and an infix identifier @\``elem`\`@.
+ -- | A prefix operator @'(++)'@ and an infix identifier @'`elem`'@.
Emphasis, Bold and Monospaced Text
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/haddock-api/src/Haddock.hs b/haddock-api/src/Haddock.hs
index 1378c173..3e0332b5 100644
--- a/haddock-api/src/Haddock.hs
+++ b/haddock-api/src/Haddock.hs
@@ -663,7 +663,7 @@ getPrologue dflags flags =
h <- openFile filename ReadMode
hSetEncoding h utf8
str <- hGetContents h -- semi-closes the handle
- return . Just $! second rdrName $ parseParas dflags Nothing str
+ return . Just $! second (fmap rdrName) $ parseParas dflags Nothing str
_ -> throwE "multiple -p/--prologue options"
diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs
index 9e3186e5..f581c01a 100644
--- a/haddock-api/src/Haddock/Backends/Hoogle.hs
+++ b/haddock-api/src/Haddock/Backends/Hoogle.hs
@@ -334,7 +334,7 @@ markupTag dflags = Markup {
markupString = str,
markupAppend = (++),
markupIdentifier = box (TagInline "a") . str . out dflags,
- markupIdentifierUnchecked = box (TagInline "a") . str . out dflags . snd,
+ markupIdentifierUnchecked = box (TagInline "a") . str . showWrapped (out dflags . snd),
markupModule = box (TagInline "a") . str,
markupWarning = box (TagInline "i"),
markupEmphasis = box (TagInline "i"),
diff --git a/haddock-api/src/Haddock/Backends/LaTeX.hs b/haddock-api/src/Haddock/Backends/LaTeX.hs
index d0752506..85769b13 100644
--- a/haddock-api/src/Haddock/Backends/LaTeX.hs
+++ b/haddock-api/src/Haddock/Backends/LaTeX.hs
@@ -1106,8 +1106,8 @@ ppSymName name
| otherwise = ppName name
-ppVerbOccName :: OccName -> LaTeX
-ppVerbOccName = text . latexFilter . occNameString
+ppVerbOccName :: Wrap OccName -> LaTeX
+ppVerbOccName = text . latexFilter . showWrapped occNameString
ppIPName :: HsIPName -> LaTeX
ppIPName = text . ('?':) . unpackFS . hsIPNameFS
@@ -1115,13 +1115,12 @@ ppIPName = text . ('?':) . unpackFS . hsIPNameFS
ppOccName :: OccName -> LaTeX
ppOccName = text . occNameString
+ppVerbDocName :: Wrap DocName -> LaTeX
+ppVerbDocName = text . latexFilter . showWrapped (occNameString . nameOccName . getName)
-ppVerbDocName :: DocName -> LaTeX
-ppVerbDocName = ppVerbOccName . nameOccName . getName
-
-ppVerbRdrName :: RdrName -> LaTeX
-ppVerbRdrName = ppVerbOccName . rdrNameOcc
+ppVerbRdrName :: Wrap RdrName -> LaTeX
+ppVerbRdrName = text . latexFilter . showWrapped (occNameString . rdrNameOcc)
ppDocName :: DocName -> LaTeX
@@ -1182,7 +1181,7 @@ parLatexMarkup ppId = Markup {
markupString = \s v -> text (fixString v s),
markupAppend = \l r v -> l v <> r v,
markupIdentifier = markupId ppId,
- markupIdentifierUnchecked = markupId (ppVerbOccName . snd),
+ markupIdentifierUnchecked = markupId (ppVerbOccName . fmap snd),
markupModule = \m _ -> let (mdl,_ref) = break (=='#') m in tt (text mdl),
markupWarning = \p v -> emph (p v),
markupEmphasis = \p v -> emph (p v),
@@ -1239,11 +1238,11 @@ parLatexMarkup ppId = Markup {
where theid = ppId_ id
-latexMarkup :: DocMarkup DocName (StringContext -> LaTeX)
+latexMarkup :: DocMarkup (Wrap DocName) (StringContext -> LaTeX)
latexMarkup = parLatexMarkup ppVerbDocName
-rdrLatexMarkup :: DocMarkup RdrName (StringContext -> LaTeX)
+rdrLatexMarkup :: DocMarkup (Wrap RdrName) (StringContext -> LaTeX)
rdrLatexMarkup = parLatexMarkup ppVerbRdrName
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs b/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
index 09aabc0c..1901cf05 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
@@ -171,12 +171,12 @@ flatten x = [x]
-- extract/append the underlying 'Doc' and convert it to 'Html'. For
-- 'CollapsingHeader', we attach extra info to the generated 'Html'
-- that allows us to expand/collapse the content.
-hackMarkup :: DocMarkup id Html -> Maybe Package -> Hack (ModuleName, OccName) id -> Html
+hackMarkup :: DocMarkup id Html -> Maybe Package -> Hack (Wrap (ModuleName, OccName)) id -> Html
hackMarkup fmt' currPkg h' =
let (html, ms) = hackMarkup' fmt' h'
in html +++ renderMeta fmt' currPkg (metaConcat ms)
where
- hackMarkup' :: DocMarkup id Html -> Hack (ModuleName, OccName) id
+ hackMarkup' :: DocMarkup id Html -> Hack (Wrap (ModuleName, OccName)) id
-> (Html, [Meta])
hackMarkup' fmt h = case h of
UntouchedDoc d -> (markup fmt $ _doc d, [_meta d])
@@ -206,7 +206,7 @@ renderMeta _ _ _ = noHtml
-- | Goes through 'hackMarkup' to generate the 'Html' rather than
-- skipping straight to 'markup': this allows us to employ XHtml
-- specific hacks to the tree first.
-markupHacked :: DocMarkup id Html
+markupHacked :: DocMarkup (Wrap id) Html
-> Maybe Package -- this package
-> Maybe String
-> MDoc id
@@ -220,7 +220,7 @@ docToHtml :: Maybe String -- ^ Name of the thing this doc is for. See
-> Maybe Package -- ^ Current package
-> Qualification -> MDoc DocName -> Html
docToHtml n pkg qual = markupHacked fmt pkg n . cleanup
- where fmt = parHtmlMarkup qual True (ppDocName qual Raw)
+ where fmt = parHtmlMarkup qual True (ppWrappedDocName qual Raw)
-- | Same as 'docToHtml' but it doesn't insert the 'anchor' element
-- in links. This is used to generate the Contents box elements.
@@ -228,16 +228,16 @@ docToHtmlNoAnchors :: Maybe String -- ^ See 'toHack'
-> Maybe Package -- ^ Current package
-> Qualification -> MDoc DocName -> Html
docToHtmlNoAnchors n pkg qual = markupHacked fmt pkg n . cleanup
- where fmt = parHtmlMarkup qual False (ppDocName qual Raw)
+ where fmt = parHtmlMarkup qual False (ppWrappedDocName qual Raw)
origDocToHtml :: Maybe Package -> Qualification -> MDoc Name -> Html
origDocToHtml pkg qual = markupHacked fmt pkg Nothing . cleanup
- where fmt = parHtmlMarkup qual True (const $ ppName Raw)
+ where fmt = parHtmlMarkup qual True (const (ppWrappedName Raw))
rdrDocToHtml :: Maybe Package -> Qualification -> MDoc RdrName -> Html
rdrDocToHtml pkg qual = markupHacked fmt pkg Nothing . cleanup
- where fmt = parHtmlMarkup qual True (const ppRdrName)
+ where fmt = parHtmlMarkup qual True (const (ppRdrName . unwrap))
docElement :: (Html -> Html) -> Html -> Html
@@ -273,7 +273,7 @@ cleanup = overDoc (markup fmtUnParagraphLists)
unParagraph (DocParagraph d) = d
unParagraph doc = doc
- fmtUnParagraphLists :: DocMarkup a (Doc a)
+ fmtUnParagraphLists :: DocMarkup (Wrap a) (Doc a)
fmtUnParagraphLists = idMarkup {
markupUnorderedList = DocUnorderedList . map unParagraph,
markupOrderedList = DocOrderedList . map unParagraph
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Names.hs b/haddock-api/src/Haddock/Backends/Xhtml/Names.hs
index 574045e0..6a047747 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Names.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Names.hs
@@ -13,7 +13,8 @@
module Haddock.Backends.Xhtml.Names (
ppName, ppDocName, ppLDocName, ppRdrName, ppUncheckedLink,
ppBinder, ppBinderInfix, ppBinder',
- ppModule, ppModuleRef, ppIPName, linkId, Notation(..)
+ ppModule, ppModuleRef, ppIPName, linkId, Notation(..),
+ ppWrappedDocName, ppWrappedName,
) where
@@ -24,7 +25,7 @@ import Haddock.Utils
import Text.XHtml hiding ( name, p, quote )
import qualified Data.Map as M
-import qualified Data.List as List
+import Data.List ( stripPrefix )
import GHC hiding (LexicalFixity(..))
import Name
@@ -49,9 +50,11 @@ ppIPName :: HsIPName -> Html
ppIPName = toHtml . ('?':) . unpackFS . hsIPNameFS
-ppUncheckedLink :: Qualification -> (ModuleName, OccName) -> Html
-ppUncheckedLink _ (mdl, occ) = linkIdOcc' mdl (Just occ) << ppOccName occ -- TODO: apply ppQualifyName
-
+ppUncheckedLink :: Qualification -> Wrap (ModuleName, OccName) -> Html
+ppUncheckedLink _ x = linkIdOcc' mdl (Just occ) << occHtml
+ where
+ (mdl, occ) = unwrap x
+ occHtml = toHtml (showWrapped (occNameString . snd) x) -- TODO: apply ppQualifyName
-- The Bool indicates if it is to be rendered in infix notation
ppLDocName :: Qualification -> Notation -> Located DocName -> Html
@@ -68,6 +71,19 @@ ppDocName qual notation insertAnchors docName =
ppQualifyName qual notation name (nameModule name)
| otherwise -> ppName notation name
+
+ppWrappedDocName :: Qualification -> Notation -> Bool -> Wrap DocName -> Html
+ppWrappedDocName qual notation insertAnchors docName = case docName of
+ Unadorned n -> ppDocName qual notation insertAnchors n
+ Parenthesized n -> ppDocName qual Prefix insertAnchors n
+ Backticked n -> ppDocName qual Infix insertAnchors n
+
+ppWrappedName :: Notation -> Wrap Name -> Html
+ppWrappedName notation docName = case docName of
+ Unadorned n -> ppName notation n
+ Parenthesized n -> ppName Prefix n
+ Backticked n -> ppName Infix n
+
-- | Render a name depending on the selected qualification mode
ppQualifyName :: Qualification -> Notation -> Name -> Module -> Html
ppQualifyName qual notation name mdl =
@@ -79,7 +95,7 @@ ppQualifyName qual notation name mdl =
then ppName notation name
else ppFullQualName notation mdl name
RelativeQual localmdl ->
- case List.stripPrefix (moduleString localmdl) (moduleString mdl) of
+ case stripPrefix (moduleString localmdl) (moduleString mdl) of
-- local, A.x -> x
Just [] -> ppName notation name
-- sub-module, A.B.x -> B.x
diff --git a/haddock-api/src/Haddock/Interface/Json.hs b/haddock-api/src/Haddock/Interface/Json.hs
index 636d3e19..a9834fa0 100644
--- a/haddock-api/src/Haddock/Interface/Json.hs
+++ b/haddock-api/src/Haddock/Interface/Json.hs
@@ -62,7 +62,10 @@ jsonMDoc MetaDoc{..} =
]
jsonDoc :: Doc Name -> JsonDoc
-jsonDoc doc = jsonString (show (bimap (moduleNameString . fst) nameStableString doc))
+jsonDoc doc = jsonString (show (bimap showModName showName doc))
+ where
+ showModName = showWrapped (moduleNameString . fst)
+ showName = showWrapped nameStableString
jsonModule :: Module -> JsonDoc
jsonModule = JSString . moduleStableString
diff --git a/haddock-api/src/Haddock/Interface/LexParseRn.hs b/haddock-api/src/Haddock/Interface/LexParseRn.hs
index 66083cf5..faf23728 100644
--- a/haddock-api/src/Haddock/Interface/LexParseRn.hs
+++ b/haddock-api/src/Haddock/Interface/LexParseRn.hs
@@ -22,6 +22,7 @@ module Haddock.Interface.LexParseRn
import Avail
import Control.Arrow
import Control.Monad
+import Data.Functor (($>))
import Data.List
import Data.Ord
import Documentation.Haddock.Doc (metaDocConcat)
@@ -95,8 +96,9 @@ rename dflags gre = rn
rn d = case d of
DocAppend a b -> DocAppend <$> rn a <*> rn b
DocParagraph doc -> DocParagraph <$> rn doc
- DocIdentifier (NsRdrName ns x) -> do
- let occ = rdrNameOcc x
+ DocIdentifier i -> do
+ let NsRdrName ns x = unwrap i
+ occ = rdrNameOcc x
isValueName = isDataOcc occ || isVarOcc occ
let valueNsChoices | isValueName = [x]
@@ -119,7 +121,7 @@ rename dflags gre = rn
case choices of
-- The only way this can happen is if a value namespace was
-- specified on something that cannot be a value.
- [] -> invalidValue dflags x
+ [] -> invalidValue dflags i
-- There was nothing in the environment so we need to
-- pick some default from what's available to us. We
@@ -129,14 +131,14 @@ rename dflags gre = rn
-- type constructor names (such as in #253). So now we
-- only get type constructor links if they are actually
-- in scope.
- a:_ -> outOfScope dflags ns a
+ a:_ -> outOfScope dflags ns (i $> a)
-- There is only one name in the environment that matches so
-- use it.
- [a] -> pure (DocIdentifier (gre_name a))
+ [a] -> pure (DocIdentifier (i $> gre_name a))
-- There are multiple names available.
- gres -> ambiguous dflags x gres
+ gres -> ambiguous dflags i gres
DocWarning doc -> DocWarning <$> rn doc
DocEmphasis doc -> DocEmphasis <$> rn doc
@@ -168,13 +170,13 @@ rename dflags gre = rn
-- users shouldn't rely on this doing the right thing. See tickets
-- #253 and #375 on the confusion this causes depending on which
-- default we pick in 'rename'.
-outOfScope :: DynFlags -> Namespace -> RdrName -> ErrMsgM (Doc a)
+outOfScope :: DynFlags -> Namespace -> Wrap RdrName -> ErrMsgM (Doc a)
outOfScope dflags ns x =
- case x of
- Unqual occ -> warnAndMonospace occ
- Qual mdl occ -> pure (DocIdentifierUnchecked (mdl, occ))
- Orig _ occ -> warnAndMonospace occ
- Exact name -> warnAndMonospace name -- Shouldn't happen since x is out of scope
+ case unwrap x of
+ Unqual occ -> warnAndMonospace (x $> occ)
+ Qual mdl occ -> pure (DocIdentifierUnchecked (x $> (mdl, occ)))
+ Orig _ occ -> warnAndMonospace (x $> occ)
+ Exact name -> warnAndMonospace (x $> name) -- Shouldn't happen since x is out of scope
where
prefix = case ns of
Value -> "the value "
@@ -182,11 +184,11 @@ outOfScope dflags ns x =
None -> ""
warnAndMonospace a = do
- tell ["Warning: " ++ prefix ++ "'" ++ showPpr dflags a ++ "' is out of scope.\n" ++
- " If you qualify the identifier, haddock can try to link it\n" ++
- " it anyway."]
- pure (monospaced a)
- monospaced a = DocMonospaced (DocString (showPpr dflags a))
+ let a' = showWrapped (showPpr dflags) a
+ tell ["Warning: " ++ prefix ++ "'" ++ a' ++ "' is out of scope.\n" ++
+ " If you qualify the identifier, haddock can try to link it anyway."]
+ pure (monospaced a')
+ monospaced = DocMonospaced . DocString
-- | Handle ambiguous identifiers.
--
@@ -194,36 +196,42 @@ outOfScope dflags ns x =
--
-- Emits a warning if the 'GlobalRdrElts's don't belong to the same type or class.
ambiguous :: DynFlags
- -> RdrName
+ -> Wrap NsRdrName
-> [GlobalRdrElt] -- ^ More than one @gre@s sharing the same `RdrName` above.
-> ErrMsgM (Doc Name)
ambiguous dflags x gres = do
let noChildren = map availName (gresToAvailInfo gres)
dflt = maximumBy (comparing (isLocalName &&& isTyConName)) noChildren
- msg = "Warning: " ++ x_str ++ " is ambiguous. It is defined\n" ++
+ msg = "Warning: " ++ showNsRdrName dflags x ++ " is ambiguous. It is defined\n" ++
concatMap (\n -> " * " ++ defnLoc n ++ "\n") (map gre_name gres) ++
" You may be able to disambiguate the identifier by qualifying it or\n" ++
" by specifying the type/value namespace explicitly.\n" ++
- " Defaulting to " ++ x_str ++ " defined " ++ defnLoc dflt
+ " Defaulting to the one defined " ++ defnLoc dflt
-- TODO: Once we have a syntax for namespace qualification (#667) we may also
-- want to emit a warning when an identifier is a data constructor for a type
-- of the same name, but not the only constructor.
-- For example, for @data D = C | D@, someone may want to reference the @D@
-- constructor.
when (length noChildren > 1) $ tell [msg]
- pure (DocIdentifier dflt)
+ pure (DocIdentifier (x $> dflt))
where
isLocalName (nameSrcLoc -> RealSrcLoc {}) = True
isLocalName _ = False
- x_str = '\'' : showPpr dflags x ++ "'"
defnLoc = showSDoc dflags . pprNameDefnLoc
-- | Handle value-namespaced names that cannot be for values.
--
-- Emits a warning that the value-namespace is invalid on a non-value identifier.
-invalidValue :: DynFlags -> RdrName -> ErrMsgM (Doc a)
+invalidValue :: DynFlags -> Wrap NsRdrName -> ErrMsgM (Doc a)
invalidValue dflags x = do
- tell ["Warning: '" ++ showPpr dflags x ++ "' cannot be value, yet it is\n" ++
+ tell ["Warning: " ++ showNsRdrName dflags x ++ " cannot be value, yet it is\n" ++
" namespaced as such. Did you mean to specify a type namespace\n" ++
" instead?"]
- pure (DocMonospaced (DocString (showPpr dflags x)))
+ pure (DocMonospaced (DocString (showNsRdrName dflags x)))
+
+-- | Printable representation of a wrapped and namespaced name
+showNsRdrName :: DynFlags -> Wrap NsRdrName -> String
+showNsRdrName dflags = (\p i -> p ++ "'" ++ i ++ "'") <$> prefix <*> ident
+ where
+ ident = showWrapped (showPpr dflags . rdrName)
+ prefix = renderNs . namespace . unwrap
diff --git a/haddock-api/src/Haddock/Interface/Rename.hs b/haddock-api/src/Haddock/Interface/Rename.hs
index 57e6d699..88238f04 100644
--- a/haddock-api/src/Haddock/Interface/Rename.hs
+++ b/haddock-api/src/Haddock/Interface/Rename.hs
@@ -173,8 +173,8 @@ renameLDocHsSyn :: LHsDocString -> RnM LHsDocString
renameLDocHsSyn = return
-renameDoc :: Traversable t => t Name -> RnM (t DocName)
-renameDoc = traverse rename
+renameDoc :: Traversable t => t (Wrap Name) -> RnM (t (Wrap DocName))
+renameDoc = traverse (traverse rename)
renameFnArgsDoc :: FnArgsDoc Name -> RnM (FnArgsDoc DocName)
renameFnArgsDoc = mapM renameDoc
diff --git a/haddock-api/src/Haddock/InterfaceFile.hs b/haddock-api/src/Haddock/InterfaceFile.hs
index e1d8dbe1..7645b1bb 100644
--- a/haddock-api/src/Haddock/InterfaceFile.hs
+++ b/haddock-api/src/Haddock/InterfaceFile.hs
@@ -83,7 +83,7 @@ binaryInterfaceMagic = 0xD0Cface
--
binaryInterfaceVersion :: Word16
#if (__GLASGOW_HASKELL__ >= 807) && (__GLASGOW_HASKELL__ < 809)
-binaryInterfaceVersion = 34
+binaryInterfaceVersion = 35
binaryInterfaceVersionCompatibility :: [Word16]
binaryInterfaceVersionCompatibility = [binaryInterfaceVersion]
@@ -701,3 +701,28 @@ instance Binary DocName where
name <- get bh
return (Undocumented name)
_ -> error "get DocName: Bad h"
+
+instance Binary n => Binary (Wrap n) where
+ put_ bh (Unadorned n) = do
+ putByte bh 0
+ put_ bh n
+ put_ bh (Parenthesized n) = do
+ putByte bh 1
+ put_ bh n
+ put_ bh (Backticked n) = do
+ putByte bh 2
+ put_ bh n
+
+ get bh = do
+ h <- getByte bh
+ case h of
+ 0 -> do
+ name <- get bh
+ return (Unadorned name)
+ 1 -> do
+ name <- get bh
+ return (Parenthesized name)
+ 2 -> do
+ name <- get bh
+ return (Backticked name)
+ _ -> error "get Wrap: Bad h"
diff --git a/haddock-api/src/Haddock/Parser.hs b/haddock-api/src/Haddock/Parser.hs
index 8b7dda7c..6d5dc103 100644
--- a/haddock-api/src/Haddock/Parser.hs
+++ b/haddock-api/src/Haddock/Parser.hs
@@ -15,27 +15,32 @@ module Haddock.Parser ( parseParas
import qualified Documentation.Haddock.Parser as P
import Documentation.Haddock.Types
-import Haddock.Types (NsRdrName(..))
+import Haddock.Types
import DynFlags ( DynFlags )
import FastString ( fsLit )
import Lexer ( mkPState, unP, ParseResult(POk) )
import Parser ( parseIdentifier )
-import RdrName ( RdrName )
import SrcLoc ( mkRealSrcLoc, GenLocated(..) )
import StringBuffer ( stringToStringBuffer )
-parseParas :: DynFlags -> Maybe Package -> String -> MetaDoc mod NsRdrName
+
+parseParas :: DynFlags -> Maybe Package -> String -> MetaDoc mod (Wrap NsRdrName)
parseParas d p = overDoc (P.overIdentifier (parseIdent d)) . P.parseParas p
-parseString :: DynFlags -> String -> DocH mod NsRdrName
+parseString :: DynFlags -> String -> DocH mod (Wrap NsRdrName)
parseString d = P.overIdentifier (parseIdent d) . P.parseString
-parseIdent :: DynFlags -> Namespace -> String -> Maybe NsRdrName
+parseIdent :: DynFlags -> Namespace -> String -> Maybe (Wrap NsRdrName)
parseIdent dflags ns str0 =
- let buffer = stringToStringBuffer str0
+ let buffer = stringToStringBuffer str1
realSrcLc = mkRealSrcLoc (fsLit "") 0 0
pstate = mkPState dflags buffer realSrcLc
+ (wrap,str1) = case str0 of
+ '(' : s@(c : _) | c /= ',', c /= ')' -- rule out tuple names
+ -> (Parenthesized, init s)
+ '`' : s@(_ : _) -> (Backticked, init s)
+ _ -> (Unadorned, str0)
in case unP parseIdentifier pstate of
- POk _ (L _ name) -> Just (NsRdrName ns name)
+ POk _ (L _ name) -> Just (wrap (NsRdrName ns name))
_ -> Nothing
diff --git a/haddock-api/src/Haddock/Types.hs b/haddock-api/src/Haddock/Types.hs
index e8da4120..cd4ac1a1 100644
--- a/haddock-api/src/Haddock/Types.hs
+++ b/haddock-api/src/Haddock/Types.hs
@@ -42,7 +42,7 @@ import GHC
import DynFlags (Language)
import qualified GHC.LanguageExtensions as LangExt
import OccName
-import Outputable
+import Outputable hiding ((<>))
-----------------------------------------------------------------------------
-- * Convenient synonyms
@@ -334,6 +334,26 @@ instance SetName DocName where
setName name' (Documented _ mdl) = Documented name' mdl
setName name' (Undocumented _) = Undocumented name'
+-- | Adds extra "wrapper" information to a name.
+--
+-- This is to work around the fact that most name types in GHC ('Name', 'RdrName',
+-- 'OccName', ...) don't include backticks or parens.
+data Wrap n
+ = Unadorned { unwrap :: n } -- ^ don't do anything to the name
+ | Parenthesized { unwrap :: n } -- ^ add parentheses around the name
+ | Backticked { unwrap :: n } -- ^ add backticks around the name
+ deriving (Show, Functor, Foldable, Traversable)
+
+-- | Useful for debugging
+instance Outputable n => Outputable (Wrap n) where
+ ppr (Unadorned n) = ppr n
+ ppr (Parenthesized n) = hcat [ char '(', ppr n, char ')' ]
+ ppr (Backticked n) = hcat [ char '`', ppr n, char '`' ]
+
+showWrapped :: (a -> String) -> Wrap a -> String
+showWrapped f (Unadorned n) = f n
+showWrapped f (Parenthesized n) = "(" ++ f n ++ ")"
+showWrapped f (Backticked n) = "`" ++ f n ++ "`"
-----------------------------------------------------------------------------
@@ -429,10 +449,10 @@ instance NamedThing name => NamedThing (InstOrigin name) where
type LDoc id = Located (Doc id)
-type Doc id = DocH (ModuleName, OccName) id
-type MDoc id = MetaDoc (ModuleName, OccName) id
+type Doc id = DocH (Wrap (ModuleName, OccName)) (Wrap id)
+type MDoc id = MetaDoc (Wrap (ModuleName, OccName)) (Wrap id)
-type DocMarkup id a = DocMarkupH (ModuleName, OccName) id a
+type DocMarkup id a = DocMarkupH (Wrap (ModuleName, OccName)) id a
instance (NFData a, NFData mod)
=> NFData (DocH mod a) where
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index b24db5d4..5475d61b 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -49,6 +49,7 @@ library
other-modules:
Documentation.Haddock.Parser.Util
Documentation.Haddock.Parser.Monad
+ Documentation.Haddock.Parser.Identifier
test-suite spec
import: lib-defaults
@@ -70,6 +71,7 @@ test-suite spec
Documentation.Haddock.Parser.UtilSpec
Documentation.Haddock.ParserSpec
Documentation.Haddock.Types
+ Documentation.Haddock.Parser.Identifier
build-depends:
, base-compat ^>= 0.9.3 || ^>= 0.10.0
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index e9b1c496..36c8bb5b 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -27,8 +27,7 @@ module Documentation.Haddock.Parser (
import Control.Applicative
import Control.Arrow (first)
import Control.Monad
-import Data.Char (chr, isUpper, isAlpha, isAlphaNum, isSpace)
-import Data.Foldable (asum)
+import Data.Char (chr, isUpper, isAlpha, isSpace)
import Data.List (intercalate, unfoldr, elemIndex)
import Data.Maybe (fromMaybe, mapMaybe)
import Data.Monoid
@@ -37,6 +36,7 @@ import Documentation.Haddock.Doc
import Documentation.Haddock.Markup ( markup, plainMarkup )
import Documentation.Haddock.Parser.Monad
import Documentation.Haddock.Parser.Util
+import Documentation.Haddock.Parser.Identifier
import Documentation.Haddock.Types
import Prelude hiding (takeWhile)
import qualified Prelude as P
@@ -47,37 +47,10 @@ import Text.Parsec (try)
import qualified Data.Text as T
import Data.Text (Text)
-#if MIN_VERSION_base(4,9,0)
-import Text.Read.Lex (isSymbolChar)
-#else
-import Data.Char (GeneralCategory (..),
- generalCategory)
-#endif
-- $setup
-- >>> :set -XOverloadedStrings
-#if !MIN_VERSION_base(4,9,0)
--- inlined from base-4.10.0.0
-isSymbolChar :: Char -> Bool
-isSymbolChar c = not (isPuncChar c) && case generalCategory c of
- MathSymbol -> True
- CurrencySymbol -> True
- ModifierSymbol -> True
- OtherSymbol -> True
- DashPunctuation -> True
- OtherPunctuation -> c `notElem` ("'\"" :: String)
- ConnectorPunctuation -> c /= '_'
- _ -> False
- where
- -- | The @special@ character class as defined in the Haskell Report.
- isPuncChar :: Char -> Bool
- isPuncChar = (`elem` (",;()[]{}`" :: String))
-#endif
-
--- | Identifier string surrounded with opening and closing quotes/backticks.
-data Identifier = Identifier !Namespace !Char String !Char
-
-- | Drops the quotes/backticks around all identifiers, as if they
-- were valid but still 'String's.
toRegular :: DocH mod Identifier -> DocH mod String
@@ -838,34 +811,6 @@ autoUrl = mkLink <$> url
mkHyperlink lnk = Hyperlink (T.unpack lnk) Nothing
-
--- | Parses strings between identifier delimiters. Consumes all input that it
--- deems to be valid in an identifier. Note that it simply blindly consumes
--- characters and does no actual validation itself.
-parseValid :: Parser String
-parseValid = p some
- where
- idChar = Parsec.satisfy (\c -> isAlphaNum c || isSymbolChar c || c == '_')
-
- p p' = do
- vs <- p' idChar
- c <- peekChar'
- case c of
- '`' -> return vs
- '\'' -> choice' [ (\x -> vs ++ "'" ++ x) <$> ("'" *> p many), return vs ]
- _ -> fail "outofvalid"
-
--- | Parses identifiers with help of 'parseValid'. Asks GHC for
--- 'String' from the string it deems valid.
+-- | Parses identifiers with help of 'parseValid'.
identifier :: Parser (DocH mod Identifier)
-identifier = do
- ns <- asum [ Value <$ Parsec.char 'v'
- , Type <$ Parsec.char 't'
- , pure None
- ]
- o <- idDelim
- vid <- parseValid
- e <- idDelim
- return $ DocIdentifier (Identifier ns o vid e)
- where
- idDelim = Parsec.oneOf "'`"
+identifier = DocIdentifier <$> parseValid
diff --git a/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs b/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
new file mode 100644
index 00000000..7bc98b62
--- /dev/null
+++ b/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
@@ -0,0 +1,186 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE ViewPatterns #-}
+-- |
+-- Module : Documentation.Haddock.Parser.Identifier
+-- Copyright : (c) Alec Theriault 2019,
+-- License : BSD-like
+--
+-- Maintainer : haddock@projects.haskell.org
+-- Stability : experimental
+-- Portability : portable
+--
+-- Functionality for parsing identifiers and operators
+
+module Documentation.Haddock.Parser.Identifier (
+ Identifier(..),
+ parseValid,
+) where
+
+import Documentation.Haddock.Types ( Namespace(..) )
+import Documentation.Haddock.Parser.Monad
+import qualified Text.Parsec as Parsec
+import Text.Parsec.Pos ( updatePosChar )
+import Text.Parsec ( State(..)
+ , getParserState, setParserState )
+
+import Data.Text (Text)
+import qualified Data.Text as T
+
+import Data.Char (isAlpha, isAlphaNum)
+import Control.Monad (guard)
+import Data.Functor (($>))
+#if MIN_VERSION_base(4,9,0)
+import Text.Read.Lex (isSymbolChar)
+#else
+import Data.Char (GeneralCategory (..),
+ generalCategory)
+#endif
+
+import Data.Maybe
+
+-- | Identifier string surrounded with namespace, opening, and closing quotes/backticks.
+data Identifier = Identifier !Namespace !Char String !Char
+ deriving (Show, Eq)
+
+parseValid :: Parser Identifier
+parseValid = do
+ s@State{ stateInput = inp, statePos = pos } <- getParserState
+
+ case takeIdentifier inp of
+ Nothing -> Parsec.parserFail "parseValid: Failed to match a valid identifier"
+ Just (ns, op, ident, cl, inp') ->
+ let posOp = updatePosChar pos op
+ posIdent = T.foldl updatePosChar posOp ident
+ posCl = updatePosChar posIdent cl
+ s' = s{ stateInput = inp', statePos = posCl }
+ in setParserState s' $> Identifier ns op (T.unpack ident) cl
+
+
+#if !MIN_VERSION_base(4,9,0)
+-- inlined from base-4.10.0.0
+isSymbolChar :: Char -> Bool
+isSymbolChar c = not (isPuncChar c) && case generalCategory c of
+ MathSymbol -> True
+ CurrencySymbol -> True
+ ModifierSymbol -> True
+ OtherSymbol -> True
+ DashPunctuation -> True
+ OtherPunctuation -> c `notElem` "'\""
+ ConnectorPunctuation -> c /= '_'
+ _ -> False
+ where
+ -- | The @special@ character class as defined in the Haskell Report.
+ isPuncChar :: Char -> Bool
+ isPuncChar = (`elem` (",;()[]{}`" :: String))
+#endif
+
+-- | Try to parse a delimited identifier off the front of the given input.
+--
+-- This tries to match as many valid Haskell identifiers/operators as possible,
+-- to the point of sometimes accepting invalid things (ex: keywords). Some
+-- considerations:
+--
+-- - operators and identifiers can have module qualifications
+-- - operators can be wrapped in parens (for prefix)
+-- - identifiers can be wrapped in backticks (for infix)
+-- - delimiters are backticks or regular ticks
+-- - since regular ticks are also valid in identifiers, we opt for the
+-- longest successful parse
+--
+-- This function should make /O(1)/ allocations
+takeIdentifier :: Text -> Maybe (Namespace, Char, Text, Char, Text)
+takeIdentifier input = listToMaybe $ do
+
+ -- Optional namespace
+ let (ns, input') = case T.uncons input of
+ Just ('v', i) -> (Value, i)
+ Just ('t', i) -> (Type, i)
+ _ -> (None, input)
+
+ -- Opening tick
+ (op, input'') <- maybeToList (T.uncons input')
+ guard (op == '\'' || op == '`')
+
+ -- Identifier/operator
+ (ident, input''') <- wrapped input''
+
+ -- Closing tick
+ (cl, input'''') <- maybeToList (T.uncons input''')
+ guard (cl == '\'' || cl == '`')
+
+ pure (ns, op, ident, cl, input'''')
+
+ where
+
+ -- | Parse out a wrapped, possibly qualified, operator or identifier
+ wrapped t = do
+ (c, t' ) <- maybeToList (T.uncons t)
+ -- Tuples
+ case c of
+ '(' | Just (c', _) <- T.uncons t'
+ , c' == ',' || c' == ')'
+ -> do let (commas, t'') = T.span (== ',') t'
+ (')', t''') <- maybeToList (T.uncons t'')
+ pure (T.take (T.length commas + 2) t, t''')
+
+ -- Parenthesized
+ '(' -> do (n, t'' ) <- general False 0 [] t'
+ (')', t''') <- maybeToList (T.uncons t'')
+ pure (T.take (n + 2) t, t''')
+
+ -- Backticked
+ '`' -> do (n, t'' ) <- general False 0 [] t'
+ ('`', t''') <- maybeToList (T.uncons t'')
+ pure (T.take (n + 2) t, t''')
+
+ -- Unadorned
+ _ -> do (n, t'' ) <- general False 0 [] t
+ pure (T.take n t, t'')
+
+ -- | Parse out a possibly qualified operator or identifier
+ general :: Bool -- ^ refuse inputs starting with operators
+ -> Int -- ^ total characters \"consumed\" so far
+ -> [(Int, Text)] -- ^ accumulated results
+ -> Text -- ^ current input
+ -> [(Int, Text)] -- ^ total characters parsed & what remains
+ general !identOnly !i acc t
+ -- Starts with an identifier (either just an identifier, or a module qual)
+ | Just (n, rest) <- identLike t
+ = if T.null rest
+ then acc
+ else case T.head rest of
+ '`' -> (n + i, rest) : acc
+ ')' -> (n + i, rest) : acc
+ '.' -> general False (n + i + 1) acc (T.tail rest)
+ '\'' -> let (m, rest') = quotes rest
+ in general True (n + m + 1 + i) ((n + m + i, rest') : acc) (T.tail rest')
+ _ -> acc
+
+ -- An operator
+ | Just (n, rest) <- optr t
+ , not identOnly
+ = (n + i, rest) : acc
+
+ -- Anything else
+ | otherwise
+ = acc
+
+ -- | Parse an identifier off the front of the input
+ identLike t
+ | T.null t = Nothing
+ | isAlpha (T.head t) || '_' == T.head t
+ = let !(idt, rest) = T.span (\c -> isAlphaNum c || c == '_') t
+ !(octos, rest') = T.span (== '#') rest
+ in Just (T.length idt + T.length octos, rest')
+ | otherwise = Nothing
+
+ -- | Parse all but the last quote off the front of the input
+ -- PRECONDITION: T.head t == '\''
+ quotes :: Text -> (Int, Text)
+ quotes t = let !n = T.length (T.takeWhile (== '\'') t) - 1
+ in (n, T.drop n t)
+
+ -- | Parse an operator off the front of the input
+ optr t = let !(op, rest) = T.span isSymbolChar t
+ in if T.null op then Nothing else Just (T.length op, rest)
diff --git a/haddock-library/src/Documentation/Haddock/Parser/Monad.hs b/haddock-library/src/Documentation/Haddock/Parser/Monad.hs
index 8f5bd217..fa46f536 100644
--- a/haddock-library/src/Documentation/Haddock/Parser/Monad.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser/Monad.hs
@@ -4,6 +4,18 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeSynonymInstances #-}
+-- |
+-- Module : Documentation.Haddock.Parser.Monad
+-- Copyright : (c) Alec Theriault 2018-2019,
+-- License : BSD-like
+--
+-- Maintainer : haddock@projects.haskell.org
+-- Stability : experimental
+-- Portability : portable
+--
+-- Defines the Parsec monad over which all parsing is done and also provides
+-- more efficient versions of the usual parsec combinator functions (but
+-- specialized to 'Text').
module Documentation.Haddock.Parser.Monad where
@@ -96,7 +108,6 @@ takeWhile f = do
s' = s{ stateInput = inp', statePos = pos' }
setParserState s' $> t
-
-- | Like 'takeWhile', but fails if no characters matched.
--
-- Equivalent to @fmap T.pack . Parsec.many1@, but more efficient.
diff --git a/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
index e186a5cf..bc40a0a2 100644
--- a/haddock-library/test/Documentation/Haddock/ParserSpec.hs
+++ b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
@@ -112,7 +112,7 @@ spec = do
"``" `shouldParseTo` "``"
it "can parse an identifier in infix notation enclosed within backticks" $ do
- "``infix``" `shouldParseTo` "`" <> DocIdentifier "infix" <> "`"
+ "``infix``" `shouldParseTo` DocIdentifier "`infix`"
it "can parse identifiers containing a single quote" $ do
"'don't'" `shouldParseTo` DocIdentifier "don't"
@@ -138,6 +138,13 @@ spec = do
it "can parse type-namespaced identifiers" $ do
"t'foo'" `shouldParseTo` DocIdentifier "foo"
+ it "can parse parenthesized operators and backticked identifiers" $ do
+ "'(<|>)'" `shouldParseTo` DocIdentifier "(<|>)"
+ "'`elem`'" `shouldParseTo` DocIdentifier "`elem`"
+
+ it "can properly figure out the end of identifiers" $ do
+ "'DbModule'/'DbUnitId'" `shouldParseTo` DocIdentifier "DbModule" <> "/" <> DocIdentifier "DbUnitId"
+
context "when parsing operators" $ do
it "can parse an operator enclosed within single quotes" $ do
"'.='" `shouldParseTo` DocIdentifier ".="
diff --git a/haddock.cabal b/haddock.cabal
index 2b8ee6ff..91a5ea3d 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -89,6 +89,7 @@ executable haddock
other-modules:
Documentation.Haddock.Parser
Documentation.Haddock.Parser.Monad
+ Documentation.Haddock.Parser.Identifier
Documentation.Haddock.Types
Documentation.Haddock.Doc
Documentation.Haddock.Parser.Util
diff --git a/html-test/ref/Identifiers.html b/html-test/ref/Identifiers.html
new file mode 100644
index 00000000..1a0a18a5
--- /dev/null
+++ b/html-test/ref/Identifiers.html
@@ -0,0 +1,286 @@
+Identifiers
diff --git a/html-test/ref/Test.html b/html-test/ref/Test.html
index b76622e7..aefc4d14 100644
--- a/html-test/ref/Test.html
+++ b/html-test/ref/Test.html
@@ -2364,7 +2364,7 @@ is at the beginning of the line).f'
- but f' doesn't get link'd 'f\''
Date: Sun, 26 May 2019 15:19:27 -0400
Subject: Release haddock-2.23, haddock-library-1.8.0
Tentatively adjust bounds and changelogs for the release to be bundled
with GHC 8.8.1.
---
CHANGES.md | 4 +++-
haddock-api/haddock-api.cabal | 6 +++---
haddock-library/haddock-library.cabal | 2 +-
.../src/Documentation/Haddock/Parser/Identifier.hs | 10 +++++-----
haddock-test/haddock-test.cabal | 2 +-
haddock.cabal | 11 +++++------
6 files changed, 18 insertions(+), 17 deletions(-)
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/CHANGES.md b/CHANGES.md
index a6d96fed..88656da4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,4 @@
-## Changes in TBA
+## Changes in 2.23.0
* "Linuwial" is the new default theme (#721, #782, #949)
@@ -29,6 +29,8 @@
* Many fixes to the LaTeX backend, mostly focused on not crashing
as well as generating LaTeX source that compiles
+ * More flexible parsing of the module header
+
## Changes in version 2.22.0
* Make `--package-version` optional for `--hoogle` (#899)
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index c427e752..9a120f5d 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.0
name: haddock-api
-version: 2.22.0
+version: 2.23.0
synopsis: A documentation-generation tool for Haskell libraries
description: Haddock is a documentation-generation tool for Haskell
libraries
@@ -42,7 +42,7 @@ library
default-language: Haskell2010
-- this package typically supports only single major versions
- build-depends: base ^>= 4.12.0
+ build-depends: base ^>= 4.13.0
, ghc ^>= 8.8
, ghc-paths ^>= 0.1.0.9
, haddock-library ^>= 1.8.0
@@ -65,7 +65,7 @@ library
ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2
ghc-options: -Wall
if impl(ghc >= 8.0)
- ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
+ ghc-options: -Wcompat -Wnoncanonical-monad-instances
exposed-modules:
Documentation.Haddock
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 5c744082..99773475 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -33,7 +33,7 @@ common lib-defaults
ghc-options: -funbox-strict-fields -Wall -fwarn-tabs
if impl(ghc >= 8.0)
- ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
+ ghc-options: -Wcompat -Wnoncanonical-monad-instances
library
import: lib-defaults
diff --git a/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs b/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
index 7bc98b62..a83e5abf 100644
--- a/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
@@ -109,7 +109,7 @@ takeIdentifier input = listToMaybe $ do
(cl, input'''') <- maybeToList (T.uncons input''')
guard (cl == '\'' || cl == '`')
- pure (ns, op, ident, cl, input'''')
+ return (ns, op, ident, cl, input'''')
where
@@ -122,21 +122,21 @@ takeIdentifier input = listToMaybe $ do
, c' == ',' || c' == ')'
-> do let (commas, t'') = T.span (== ',') t'
(')', t''') <- maybeToList (T.uncons t'')
- pure (T.take (T.length commas + 2) t, t''')
+ return (T.take (T.length commas + 2) t, t''')
-- Parenthesized
'(' -> do (n, t'' ) <- general False 0 [] t'
(')', t''') <- maybeToList (T.uncons t'')
- pure (T.take (n + 2) t, t''')
+ return (T.take (n + 2) t, t''')
-- Backticked
'`' -> do (n, t'' ) <- general False 0 [] t'
('`', t''') <- maybeToList (T.uncons t'')
- pure (T.take (n + 2) t, t''')
+ return (T.take (n + 2) t, t''')
-- Unadorned
_ -> do (n, t'' ) <- general False 0 [] t
- pure (T.take n t, t'')
+ return (T.take n t, t'')
-- | Parse out a possibly qualified operator or identifier
general :: Bool -- ^ refuse inputs starting with operators
diff --git a/haddock-test/haddock-test.cabal b/haddock-test/haddock-test.cabal
index 23b5953c..ed174e4f 100644
--- a/haddock-test/haddock-test.cabal
+++ b/haddock-test/haddock-test.cabal
@@ -16,7 +16,7 @@ library
default-language: Haskell2010
ghc-options: -Wall
hs-source-dirs: src
- build-depends: base >= 4.3 && < 4.13, bytestring, directory, process, filepath, Cabal, xml, xhtml
+ build-depends: base >= 4.3 && < 4.14, bytestring, directory, process, filepath, Cabal, xml, xhtml
exposed-modules:
Test.Haddock
diff --git a/haddock.cabal b/haddock.cabal
index 078955fb..563955b9 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.0
name: haddock
-version: 2.22.0
+version: 2.23.0
synopsis: A documentation-generation tool for Haskell libraries
description:
This is Haddock, a tool for automatically generating documentation
@@ -23,7 +23,7 @@ description:
without any documentation annotations, Haddock can generate useful documentation
from your source code.
.
- <>
+ <>
license: BSD3
license-file: LICENSE
author: Simon Marlow, David Waern
@@ -33,7 +33,7 @@ bug-reports: https://github.com/haskell/haddock/issues
copyright: (c) Simon Marlow, David Waern
category: Documentation
build-type: Simple
-tested-with: GHC==8.6.*
+tested-with: GHC==8.8.*
extra-source-files:
CHANGES.md
@@ -64,8 +64,7 @@ executable haddock
-- haddock typically only supports a single GHC major version
build-depends:
- -- FIXME: drop 4.12.0.0 once GHC HEAD updates to 4.13.0.0
- base ^>= 4.12.0.0 || ^>= 4.13.0.0
+ base ^>= 4.13.0.0
if flag(in-ghc-tree)
hs-source-dirs: haddock-api/src, haddock-library/src
@@ -141,7 +140,7 @@ executable haddock
else
-- in order for haddock's advertised version number to have proper meaning,
-- we pin down to a single haddock-api version.
- build-depends: haddock-api == 2.22.0
+ build-depends: haddock-api == 2.23.0
test-suite html-test
type: exitcode-stdio-1.0
--
cgit v1.2.3
From 395205c0d86efd006bc8ccde7ddeb425dffe2e9e Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Fri, 20 Sep 2019 03:21:00 -0400
Subject: Fix Travis CI, loosen .cabal bounds (#1089)
Tentatively for the 2.23 release:
* updated Travis CI to work again
* tweaked bounds in the `.cabal` files
* adjusted `extra-source-files` to properly identify test files
---
.travis.yml | 200 +++++++++++++++++++---------------
haddock-api/haddock-api.cabal | 8 +-
haddock-library/haddock-library.cabal | 16 +--
haddock.cabal | 13 ++-
4 files changed, 135 insertions(+), 102 deletions(-)
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/.travis.yml b/.travis.yml
index 2417dea9..896087ba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,104 +1,134 @@
-# NOTE: manually changes were made to an otherwise autogenerated script. This is to
-# query GHC CI artifacts instead of going via Herbert's PPA
-#
# This Travis job script has been generated by a script via
#
-# make_travis_yml_2.hs 'haddock.cabal'
+# haskell-ci 'haddock.cabal' '--output' '.travis.yml'
+#
+# For more information, see https://github.com/haskell-CI/haskell-ci
#
-# For more information, see https://github.com/hvr/multi-ghc-travis
+# version: 0.5.20190916
#
language: c
-sudo: false
-
+dist: xenial
git:
- submodules: false # whether to recursively clone submodules
-
+ # whether to recursively clone submodules
+ submodules: false
cache:
directories:
- $HOME/.cabal/packages
- $HOME/.cabal/store
-
before_cache:
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
+ - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
# remove files that are regenerated by 'cabal update'
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
-
- - rm -rfv $HOME/.cabal/packages/head.hackage
-
+ - rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*
+ - rm -fv $CABALHOME/packages/hackage.haskell.org/*.json
+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache
+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
+ - rm -rfv $CABALHOME/packages/head.hackage
matrix:
include:
- - os: linux
- addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head], sources: [hvr-ghc]}}
- env:
- - GHC_ZIP='https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/download?job=validate-x86_64-linux-deb8'
-
+ - compiler: ghc-8.8.1
+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}
before_install:
- # Manually install GHC validate artifact
- - travis_retry curl -L $GHC_ZIP --output artifact.zip
- - unzip artifact.zip
- - tar xpf ghc.tar.xz --strip-components 1
- - ./configure
- - sudo make V=1 install
-
- # Set up some vars
- - HC=ghc
- - HCPKG=${HC/ghc/ghc-pkg}
- - PATH=/usr/local/bin:/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
- - PKGNAME='haddock'
-
+ - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
+ - WITHCOMPILER="-w $HC"
+ - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')
+ - HCPKG="$HC-pkg"
+ - unset CC
+ - CABAL=/opt/ghc/bin/cabal
+ - CABALHOME=$HOME/.cabal
+ - export PATH="$CABALHOME/bin:$PATH"
+ - TOP=$(pwd)
+ - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
+ - echo $HCNUMVER
+ - CABAL="$CABAL -vnormal+nowrap+markoutput"
+ - set -o pipefail
+ - |
+ echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
+ echo 'BEGIN { state = "output"; }' >> .colorful.awk
+ echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
+ echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
+ echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
+ echo ' if (state == "cabal") {' >> .colorful.awk
+ echo ' print blue($0)' >> .colorful.awk
+ echo ' } else {' >> .colorful.awk
+ echo ' print $0' >> .colorful.awk
+ echo ' }' >> .colorful.awk
+ echo '}' >> .colorful.awk
+ - cat .colorful.awk
+ - |
+ color_cabal_output () {
+ awk -f $TOP/.colorful.awk
+ }
+ - echo text | color_cabal_output
install:
- - cabal --version
- - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
- - BENCH=--enable-benchmarks
- - TEST=--enable-tests
- - travis_retry cabal update -v
- - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
- - rm -fv cabal.project.local
- - rm -f cabal.project.freeze
- # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage
- - |
- sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config
- for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done
-
- echo 'repository head.hackage' >> ${HOME}/.cabal/config
- echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config
- echo ' secure: True' >> ${HOME}/.cabal/config
- echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config
- echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config
- echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config
- echo ' key-threshold: 3' >> ${HOME}/.cabal.config
-
- grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
-
- cabal new-update head.hackage -v
- - travis_retry cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 --allow-newer --constraint 'setup.Cabal installed' all
- - travis_retry cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 --allow-newer --constraint 'setup.Cabal installed' all
-
-# Here starts the actual work to be performed for the package under test;
-# any command which exits with a non-zero exit code causes the build to fail.
+ - ${CABAL} --version
+ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
+ - TEST=--enable-tests
+ - BENCH=--enable-benchmarks
+ - HEADHACKAGE=false
+ - rm -f $CABALHOME/config
+ - |
+ echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
+ echo "remote-build-reporting: anonymous" >> $CABALHOME/config
+ echo "write-ghc-environment-files: always" >> $CABALHOME/config
+ echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
+ echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
+ echo "world-file: $CABALHOME/world" >> $CABALHOME/config
+ echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
+ echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
+ echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
+ echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
+ echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
+ echo "install-dirs user" >> $CABALHOME/config
+ echo " prefix: $CABALHOME" >> $CABALHOME/config
+ echo "repository hackage.haskell.org" >> $CABALHOME/config
+ echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
+ - |
+ echo "program-default-options" >> $CABALHOME/config
+ echo " ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config
+ - cat $CABALHOME/config
+ - rm -fv cabal.project.local cabal.project.freeze
+ - travis_retry ${CABAL} v2-update -v
+ # Generate cabal.project
+ - rm -rf cabal.project.local cabal.project.freeze
+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(haddock)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
+ - cat cabal.project || true
+ - cat cabal.project.local || true
+ - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output
+ - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
+ - rm cabal.project.freeze
+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output
+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all | color_cabal_output
script:
- - if [ -f configure.ac ]; then autoreconf -i; fi
- - rm -rf dist/
- - cabal new-sdist # test that a source-distribution can be generated
- - cd dist-newstyle/sdist/
- - SRCTAR=(${PKGNAME}-*.tar.gz)
- - SRC_BASENAME="${SRCTAR/%.tar.gz}"
- - tar -xvf "./$SRC_BASENAME.tar.gz"
- - cd "$SRC_BASENAME/"
-## from here on, CWD is inside the extracted source-tarball
- - rm -fv cabal.project.local
- # this builds all libraries and executables (without tests/benchmarks)
- - rm -f cabal.project.freeze
- - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --allow-newer --constraint 'setup.Cabal installed' all
- # this builds all libraries and executables (including tests/benchmarks)
- # - rm -rf ./dist-newstyle
-
- # build & run tests
- - cabal new-build -w ${HC} ${TEST} ${BENCH} --allow-newer --constraint 'setup.Cabal installed' all
- - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} --allow-newer --constraint 'setup.Cabal installed' all; fi
+ - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
+ # Packaging...
+ - ${CABAL} v2-sdist all | color_cabal_output
+ # Unpacking...
+ - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
+ - cd ${DISTDIR} || false
+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;
+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
+ # Generate cabal.project
+ - rm -rf cabal.project cabal.project.local cabal.project.freeze
+ - touch cabal.project
+ - |
+ echo "packages: ./haddock-*" >> cabal.project
+ - |
+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(haddock)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
+ - cat cabal.project || true
+ - cat cabal.project.local || true
+ # Building...
+ # this builds all libraries and executables (without tests/benchmarks)
+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
+ # Building with tests and benchmarks...
+ # build & run tests, build benchmarks
+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
+ # Testing...
+ - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
+ # Building without installed constraints for packages in global-db...
+ - rm -f cabal.project.local
+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
+# REGENDATA ["haddock.cabal","--output",".travis.yml"]
# EOF
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index 9a120f5d..f8558dca 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -166,11 +166,11 @@ test-suite spec
Haddock.Backends.Hyperlinker.Types
build-depends: ghc ^>= 8.8
- , ghc-paths ^>= 0.1.0.9
+ , ghc-paths ^>= 0.1.0.12
, haddock-library ^>= 1.8.0
, xhtml ^>= 3000.2.2
- , hspec >= 2.4.4 && < 2.7
- , QuickCheck >= 2.11 && < 2.13
+ , hspec >= 2.4.4 && < 2.8
+ , QuickCheck >= 2.11 && < 2.14
-- Versions for the dependencies below are transitively pinned by
-- the non-reinstallable `ghc` package and hence need no version
@@ -186,7 +186,7 @@ test-suite spec
, transformers
build-tool-depends:
- hspec-discover:hspec-discover >= 2.4.4 && < 2.7
+ hspec-discover:hspec-discover >= 2.4.4 && < 2.8
source-repository head
type: git
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 99773475..fe6aeede 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -19,6 +19,8 @@ bug-reports: https://github.com/haskell/haddock/issues
category: Documentation
extra-source-files:
CHANGES.md
+ fixtures/examples/*.input
+ fixtures/examples/*.parsed
common lib-defaults
default-language: Haskell2010
@@ -74,8 +76,8 @@ test-suite spec
Documentation.Haddock.Parser.Identifier
build-depends:
- , base-compat ^>= 0.9.3 || ^>= 0.10.0
- , QuickCheck ^>= 2.11 || ^>= 2.12
+ , base-compat ^>= 0.9.3 || ^>= 0.11.0
+ , QuickCheck ^>= 2.11 || ^>= 2.13.2
, deepseq ^>= 1.3.0.0 || ^>= 1.4.0.0
-- NB: build-depends & build-tool-depends have independent
@@ -83,10 +85,10 @@ test-suite spec
-- version of `hspec` & `hspec-discover` to ensure
-- intercompatibility
build-depends:
- , hspec >= 2.4.4 && < 2.7
+ , hspec >= 2.4.4 && < 2.8
build-tool-depends:
- , hspec-discover:hspec-discover >= 2.4.4 && < 2.7
+ , hspec-discover:hspec-discover >= 2.4.4 && < 2.8
test-suite fixtures
type: exitcode-stdio-1.0
@@ -101,11 +103,11 @@ test-suite fixtures
, base
-- extra dependencies
- , base-compat >= 0.9.3 && < 0.11
+ , base-compat ^>= 0.9.3 || ^>= 0.11.0
, directory ^>= 1.3.0.2
, filepath ^>= 1.4.1.2
- , optparse-applicative ^>= 0.14.0.0
- , tree-diff ^>= 0.0.0.1
+ , optparse-applicative ^>= 0.15
+ , tree-diff ^>= 0.1
source-repository head
type: git
diff --git a/haddock.cabal b/haddock.cabal
index 563955b9..0173fd84 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -1,4 +1,4 @@
-cabal-version: 2.0
+cabal-version: 2.4
name: haddock
version: 2.23.0
synopsis: A documentation-generation tool for Haskell libraries
@@ -24,7 +24,7 @@ description:
from your source code.
.
<>
-license: BSD3
+license: BSD-3-Clause
license-file: LICENSE
author: Simon Marlow, David Waern
maintainer: Alec Theriault , Alex Biehl , Simon Hengel , Mateusz Kowalczyk
@@ -47,9 +47,10 @@ extra-source-files:
html-test/ref/*.html
hypsrc-test/src/*.hs
hypsrc-test/ref/src/*.html
- latex-test/src/Simple/*.hs
- latex-test/ref/Simple/*.tex
- latex-test/ref/Simple/*.sty
+ latex-test/src/**/*.hs
+ latex-test/ref/**/*.tex
+ hoogle-test/src/**/*.hs
+ hoogle-test/ref/**/*.txt
flag in-ghc-tree
description: Are we in a GHC tree?
@@ -62,7 +63,7 @@ executable haddock
hs-source-dirs: driver
ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2 -threaded
- -- haddock typically only supports a single GHC major version
+ -- haddock typically only supports a single GHC major version
build-depends:
base ^>= 4.13.0.0
--
cgit v1.2.3
From be8b02c4e3cffe7d45b3dad0a0f071d35a274d65 Mon Sep 17 00:00:00 2001
From: Herbert Valerio Riedel
Date: Sun, 8 Dec 2019 11:53:39 +0100
Subject: Fix build-failure regression for base < 4.7
The `$>` operator definition is available only since base-4.7 which
unfortunately wasn't caught before release to Hackage (but has been
fixed up by a metadata-revision)
This commit introduces a `CompatPrelude` module which allows to reduce
the amount of CPP by ousting it to a central location, i.e. the new
`CompatPrelude` module. This pattern also tends to reduce the tricks
needed to silence unused import warnings.
Addresses #1119
---
haddock-library/CHANGES.md | 4 ++
haddock-library/haddock-library.cabal | 3 +-
haddock-library/src/CompatPrelude.hs | 52 ++++++++++++++++++++++
.../src/Documentation/Haddock/Parser.hs | 1 -
.../src/Documentation/Haddock/Parser/Identifier.hs | 28 +-----------
.../src/Documentation/Haddock/Parser/Monad.hs | 3 +-
6 files changed, 61 insertions(+), 30 deletions(-)
create mode 100644 haddock-library/src/CompatPrelude.hs
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/haddock-library/CHANGES.md b/haddock-library/CHANGES.md
index 265579ca..d112db45 100644
--- a/haddock-library/CHANGES.md
+++ b/haddock-library/CHANGES.md
@@ -1,3 +1,7 @@
+## Changes in version 1.8.0.1
+
+ * Fix build-time regression for `base < 4.7` (#1119)
+
## Changes in version 1.8.0
* Support inline markup in markdown-style links (#875)
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index fe6aeede..7f91fd19 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: haddock-library
-version: 1.8.0
+version: 1.8.0.1
synopsis: Library exposing some functionality of Haddock.
description: Haddock is a documentation-generation tool for Haskell
@@ -49,6 +49,7 @@ library
Documentation.Haddock.Types
other-modules:
+ CompatPrelude
Documentation.Haddock.Parser.Util
Documentation.Haddock.Parser.Monad
Documentation.Haddock.Parser.Identifier
diff --git a/haddock-library/src/CompatPrelude.hs b/haddock-library/src/CompatPrelude.hs
new file mode 100644
index 00000000..60fa94d9
--- /dev/null
+++ b/haddock-library/src/CompatPrelude.hs
@@ -0,0 +1,52 @@
+{-# LANGUAGE CPP #-}
+
+#if !MIN_VERSION_base(4,5,0)
+# error This module doesn't provide compat-shims for versions prior to base-4.5
+#endif
+
+-- | Bridge impedance mismatch of different @base@ versions back till @base-4.5@ (GHC 7.4.2)
+module CompatPrelude
+ ( ($>)
+ , isSymbolChar
+ ) where
+
+#if MIN_VERSION_base(4,7,0)
+import Data.Functor ( ($>) )
+#else
+import Data.Functor ( (<$) )
+#endif
+
+#if MIN_VERSION_base(4,9,0)
+import Text.Read.Lex (isSymbolChar)
+#else
+import Data.Char (GeneralCategory(..), generalCategory)
+#endif
+
+
+#if !MIN_VERSION_base(4,7,0)
+infixl 4 $>
+
+-- | Flipped version of '<$'.
+--
+-- @since 4.7.0.0
+($>) :: Functor f => f a -> b -> f b
+($>) = flip (<$)
+#endif
+
+#if !MIN_VERSION_base(4,9,0)
+-- inlined from base-4.10.0.0
+isSymbolChar :: Char -> Bool
+isSymbolChar c = not (isPuncChar c) && case generalCategory c of
+ MathSymbol -> True
+ CurrencySymbol -> True
+ ModifierSymbol -> True
+ OtherSymbol -> True
+ DashPunctuation -> True
+ OtherPunctuation -> c `notElem` "'\""
+ ConnectorPunctuation -> c /= '_'
+ _ -> False
+ where
+ -- | The @special@ character class as defined in the Haskell Report.
+ isPuncChar :: Char -> Bool
+ isPuncChar = (`elem` (",;()[]{}`" :: String))
+#endif
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index 36c8bb5b..028422a7 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
-- |
diff --git a/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs b/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
index a83e5abf..b8afb951 100644
--- a/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ViewPatterns #-}
-- |
@@ -29,15 +28,8 @@ import qualified Data.Text as T
import Data.Char (isAlpha, isAlphaNum)
import Control.Monad (guard)
-import Data.Functor (($>))
-#if MIN_VERSION_base(4,9,0)
-import Text.Read.Lex (isSymbolChar)
-#else
-import Data.Char (GeneralCategory (..),
- generalCategory)
-#endif
-
import Data.Maybe
+import CompatPrelude
-- | Identifier string surrounded with namespace, opening, and closing quotes/backticks.
data Identifier = Identifier !Namespace !Char String !Char
@@ -57,24 +49,6 @@ parseValid = do
in setParserState s' $> Identifier ns op (T.unpack ident) cl
-#if !MIN_VERSION_base(4,9,0)
--- inlined from base-4.10.0.0
-isSymbolChar :: Char -> Bool
-isSymbolChar c = not (isPuncChar c) && case generalCategory c of
- MathSymbol -> True
- CurrencySymbol -> True
- ModifierSymbol -> True
- OtherSymbol -> True
- DashPunctuation -> True
- OtherPunctuation -> c `notElem` "'\""
- ConnectorPunctuation -> c /= '_'
- _ -> False
- where
- -- | The @special@ character class as defined in the Haskell Report.
- isPuncChar :: Char -> Bool
- isPuncChar = (`elem` (",;()[]{}`" :: String))
-#endif
-
-- | Try to parse a delimited identifier off the front of the given input.
--
-- This tries to match as many valid Haskell identifiers/operators as possible,
diff --git a/haddock-library/src/Documentation/Haddock/Parser/Monad.hs b/haddock-library/src/Documentation/Haddock/Parser/Monad.hs
index fa46f536..7c73a168 100644
--- a/haddock-library/src/Documentation/Haddock/Parser/Monad.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser/Monad.hs
@@ -29,7 +29,6 @@ import qualified Data.Text as T
import Data.Text ( Text )
import Control.Monad ( mfilter )
-import Data.Functor ( ($>) )
import Data.String ( IsString(..) )
import Data.Bits ( Bits(..) )
import Data.Char ( ord )
@@ -37,7 +36,9 @@ import Data.List ( foldl' )
import Control.Applicative as App
import Documentation.Haddock.Types ( Version )
+
import Prelude hiding (takeWhile)
+import CompatPrelude
-- | The only bit of information we really care about truding along with us
-- through parsing is the version attached to a @\@since@ annotation - if
--
cgit v1.2.3
From 5bef8bd8a72465a0abb1753a8bbeb94634a9d698 Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Sun, 22 Mar 2020 11:46:42 -0400
Subject: Clean up warnings
* unused imports
* imports of `Data.List` without import lists
* missing `CompatPrelude` file in `.cabal`
---
haddock-api/src/Haddock/Backends/Hoogle.hs | 3 +--
haddock-api/src/Haddock/Backends/LaTeX.hs | 9 +-------
haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 1 -
.../src/Haddock/Backends/Xhtml/DocMarkup.hs | 2 +-
haddock-api/src/Haddock/Interface.hs | 2 +-
.../src/Haddock/Interface/AttachInstances.hs | 2 +-
haddock-api/src/Haddock/Interface/Create.hs | 2 +-
haddock-api/src/Haddock/Interface/LexParseRn.hs | 2 +-
haddock-api/src/Haddock/Interface/Rename.hs | 2 --
haddock-api/src/Haddock/InterfaceFile.hs | 2 +-
haddock-api/src/Haddock/Utils.hs | 1 -
haddock-api/src/Haddock/Utils/Json.hs | 2 +-
haddock-library/haddock-library.cabal | 26 ++++++++++------------
haddock.cabal | 1 +
14 files changed, 22 insertions(+), 35 deletions(-)
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs
index 1f98ef9c..b38d4047 100644
--- a/haddock-api/src/Haddock/Backends/Hoogle.hs
+++ b/haddock-api/src/Haddock/Backends/Hoogle.hs
@@ -27,10 +27,9 @@ import Haddock.Utils hiding (out)
import GHC
import Outputable
-import NameSet
import Data.Char
-import Data.List
+import Data.List (isPrefixOf, intercalate)
import Data.Maybe
import Data.Version
diff --git a/haddock-api/src/Haddock/Backends/LaTeX.hs b/haddock-api/src/Haddock/Backends/LaTeX.hs
index f2fb1041..63b12a14 100644
--- a/haddock-api/src/Haddock/Backends/LaTeX.hs
+++ b/haddock-api/src/Haddock/Backends/LaTeX.hs
@@ -38,7 +38,7 @@ import System.FilePath
import Data.Char
import Control.Monad
import Data.Maybe
-import Data.List
+import Data.List ( sort )
import Prelude hiding ((<>))
import Haddock.Doc (combineDocumentation)
@@ -517,12 +517,6 @@ ppSubSigLike unicode typ argDocs subdocs leader = do_args 0 leader typ
gadtOpen = char '{'
-ppForAllSeparator :: Bool -> ForallVisFlag -> LaTeX
-ppForAllSeparator unicode fvf =
- case fvf of
- ForallVis -> text "\\ " <> arrow unicode
- ForallInvis -> dot
-
ppTypeSig :: [Name] -> HsType DocNameI -> Bool -> LaTeX
ppTypeSig nms ty unicode =
hsep (punctuate comma $ map ppSymName nms)
@@ -1063,7 +1057,6 @@ ppForAllPart unicode tvs fvf = hsep (forallSymbol unicode : tvs') <> fv
ForallVis -> text "\\ " <> arrow unicode
ForallInvis -> dot
-
ppr_mono_lty :: LHsType DocNameI -> Bool -> LaTeX
ppr_mono_lty ty unicode = ppr_mono_ty (unLoc ty) unicode
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
index c7ae15ca..b450dc94 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
@@ -36,7 +36,6 @@ import Text.XHtml hiding ( name, title, p, quote )
import BasicTypes (PromotionFlag(..), isPromoted)
import GHC hiding (LexicalFixity(..))
-import qualified GHC
import GHC.Exts
import Name
import BooleanFormula
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs b/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
index edab4b16..0d7accfc 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
@@ -19,7 +19,7 @@ module Haddock.Backends.Xhtml.DocMarkup (
docElement, docSection, docSection_,
) where
-import Data.List
+import Data.List (intersperse)
import Documentation.Haddock.Markup
import Haddock.Backends.Xhtml.Names
import Haddock.Backends.Xhtml.Utils
diff --git a/haddock-api/src/Haddock/Interface.hs b/haddock-api/src/Haddock/Interface.hs
index c2c0d733..24568235 100644
--- a/haddock-api/src/Haddock/Interface.hs
+++ b/haddock-api/src/Haddock/Interface.hs
@@ -44,7 +44,7 @@ import Haddock.Utils
import Control.Monad
import Control.Exception (evaluate)
-import Data.List
+import Data.List (foldl', isPrefixOf, nub)
import qualified Data.Map as Map
import qualified Data.Set as Set
import Text.Printf
diff --git a/haddock-api/src/Haddock/Interface/AttachInstances.hs b/haddock-api/src/Haddock/Interface/AttachInstances.hs
index 35f24ee5..685dca01 100644
--- a/haddock-api/src/Haddock/Interface/AttachInstances.hs
+++ b/haddock-api/src/Haddock/Interface/AttachInstances.hs
@@ -21,7 +21,7 @@ import Haddock.GhcUtils
import Control.Applicative ((<|>))
import Control.Arrow hiding ((<+>))
-import Data.List
+import Data.List (sortBy)
import Data.Ord (comparing)
import Data.Maybe ( maybeToList, mapMaybe, fromMaybe )
import qualified Data.Map as Map
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index d5cbdaf5..b182a615 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -32,7 +32,7 @@ import Data.Bifunctor
import Data.Bitraversable
import qualified Data.Map as M
import Data.Map (Map)
-import Data.List
+import Data.List (find, foldl', sortBy)
import Data.Maybe
import Data.Ord
import Control.Applicative
diff --git a/haddock-api/src/Haddock/Interface/LexParseRn.hs b/haddock-api/src/Haddock/Interface/LexParseRn.hs
index 0b40ed3c..08a3c0f8 100644
--- a/haddock-api/src/Haddock/Interface/LexParseRn.hs
+++ b/haddock-api/src/Haddock/Interface/LexParseRn.hs
@@ -22,7 +22,7 @@ module Haddock.Interface.LexParseRn
import Control.Arrow
import Control.Monad
import Data.Functor (($>))
-import Data.List
+import Data.List (maximumBy, (\\))
import Data.Ord
import Documentation.Haddock.Doc (metaDocConcat)
import DynFlags (languageExtensions)
diff --git a/haddock-api/src/Haddock/Interface/Rename.hs b/haddock-api/src/Haddock/Interface/Rename.hs
index 72d063dc..0b122b07 100644
--- a/haddock-api/src/Haddock/Interface/Rename.hs
+++ b/haddock-api/src/Haddock/Interface/Rename.hs
@@ -22,14 +22,12 @@ import Haddock.Types
import Bag (emptyBag)
import GHC hiding (NoLink)
import Name
-import Outputable ( panic )
import RdrName (RdrName(Exact))
import TysWiredIn (eqTyCon_RDR)
import Control.Applicative
import Control.Arrow ( first )
import Control.Monad hiding (mapM)
-import Data.List
import qualified Data.Map as Map hiding ( Map )
import Prelude hiding (mapM)
diff --git a/haddock-api/src/Haddock/InterfaceFile.hs b/haddock-api/src/Haddock/InterfaceFile.hs
index b5be311a..3ce2fabb 100644
--- a/haddock-api/src/Haddock/InterfaceFile.hs
+++ b/haddock-api/src/Haddock/InterfaceFile.hs
@@ -26,7 +26,7 @@ import Haddock.Utils hiding (out)
import Control.Monad
import Data.Array
import Data.IORef
-import Data.List
+import Data.List (mapAccumR)
import qualified Data.Map as Map
import Data.Map (Map)
import Data.Word
diff --git a/haddock-api/src/Haddock/Utils.hs b/haddock-api/src/Haddock/Utils.hs
index 79673365..3eb702c9 100644
--- a/haddock-api/src/Haddock/Utils.hs
+++ b/haddock-api/src/Haddock/Utils.hs
@@ -65,7 +65,6 @@ import BasicTypes ( PromotionFlag(..) )
import Exception (ExceptionMonad)
import GHC
import Name
-import Outputable ( panic )
import Control.Monad ( liftM )
import Data.Char ( isAlpha, isAlphaNum, isAscii, ord, chr )
diff --git a/haddock-api/src/Haddock/Utils/Json.hs b/haddock-api/src/Haddock/Utils/Json.hs
index e3c3dddc..2270a547 100644
--- a/haddock-api/src/Haddock/Utils/Json.hs
+++ b/haddock-api/src/Haddock/Utils/Json.hs
@@ -19,7 +19,7 @@ import Data.Char
import Data.Int
import Data.String
import Data.Word
-import Data.List
+import Data.List (intersperse)
import Data.Monoid
import Data.ByteString.Builder (Builder)
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index e58fe2ef..294ef5be 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -59,22 +59,20 @@ test-suite spec
type: exitcode-stdio-1.0
main-is: Spec.hs
hs-source-dirs:
- test
- src
-
- cpp-options:
- -DTEST
+ test
+ src
other-modules:
- Documentation.Haddock.Doc
- Documentation.Haddock.Markup
- Documentation.Haddock.Parser
- Documentation.Haddock.Parser.Monad
- Documentation.Haddock.Parser.Util
- Documentation.Haddock.Parser.UtilSpec
- Documentation.Haddock.ParserSpec
- Documentation.Haddock.Types
- Documentation.Haddock.Parser.Identifier
+ CompatPrelude
+ Documentation.Haddock.Doc
+ Documentation.Haddock.Markup
+ Documentation.Haddock.Parser
+ Documentation.Haddock.Parser.Monad
+ Documentation.Haddock.Parser.Util
+ Documentation.Haddock.Parser.UtilSpec
+ Documentation.Haddock.ParserSpec
+ Documentation.Haddock.Types
+ Documentation.Haddock.Parser.Identifier
build-depends:
, base-compat ^>= 0.9.3 || ^>= 0.11.0
diff --git a/haddock.cabal b/haddock.cabal
index 92fe249e..425ed454 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -87,6 +87,7 @@ executable haddock
transformers
other-modules:
+ CompatPrelude
Documentation.Haddock.Parser
Documentation.Haddock.Parser.Monad
Documentation.Haddock.Parser.Identifier
--
cgit v1.2.3
From 03dbfdd70186e484135ba1ea8d27672264cd9712 Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Sun, 22 Mar 2020 20:10:52 -0400
Subject: Tentative 2.24 release
Adjusted changelogs and versions in `.cabal` files in preparation for
the upcoming release bundled with GHC 8.10.
---
CHANGES.md | 7 +++++++
haddock-api/haddock-api.cabal | 6 +++---
haddock-api/src/Haddock/Backends/Hoogle.hs | 2 +-
haddock-api/src/Haddock/InterfaceFile.hs | 2 +-
haddock-library/CHANGES.md | 4 +++-
haddock-library/haddock-library.cabal | 2 +-
haddock.cabal | 4 ++--
7 files changed, 18 insertions(+), 9 deletions(-)
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/CHANGES.md b/CHANGES.md
index 88656da4..b0600381 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,10 @@
+## Changes in 2.24.0
+
+ * Reify oversaturated data family instances correctly (#1103)
+
+ * Removed the majority of Haddock's possible `panic` routes through
+ the TTG refactor to make extension variants empty
+
## Changes in 2.23.0
* "Linuwial" is the new default theme (#721, #782, #949)
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index 8ad0ae64..0324fcd6 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.0
name: haddock-api
-version: 2.23.0
+version: 2.24.0
synopsis: A documentation-generation tool for Haskell libraries
description: Haddock is a documentation-generation tool for Haskell
libraries
@@ -45,7 +45,7 @@ library
build-depends: base ^>= 4.14.0
, ghc ^>= 8.10
, ghc-paths ^>= 0.1.0.9
- , haddock-library ^>= 1.8.0
+ , haddock-library ^>= 1.9.0
, xhtml ^>= 3000.2.2
-- Versions for the dependencies below are transitively pinned by
@@ -167,7 +167,7 @@ test-suite spec
build-depends: ghc ^>= 8.10
, ghc-paths ^>= 0.1.0.12
- , haddock-library ^>= 1.8.0
+ , haddock-library ^>= 1.9.0
, xhtml ^>= 3000.2.2
, hspec >= 2.4.4 && < 2.8
, QuickCheck >= 2.11 && < 2.14
diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs
index b38d4047..b4a605f2 100644
--- a/haddock-api/src/Haddock/Backends/Hoogle.hs
+++ b/haddock-api/src/Haddock/Backends/Hoogle.hs
@@ -260,7 +260,7 @@ ppCtor dflags dat subdocs con@ConDeclH98 {}
tyVarBndr2Type :: HsTyVarBndr GhcRn -> HsType GhcRn
tyVarBndr2Type (UserTyVar _ n) = HsTyVar noExtField NotPromoted n
tyVarBndr2Type (KindedTyVar _ n k) = HsKindSig noExtField (reL (HsTyVar noExtField NotPromoted n)) k
- tyVarBndr2Type (XTyVarBndr _) = panic "haddock:ppCtor"
+ tyVarBndr2Type (XTyVarBndr nec) = noExtCon nec
ppCtor dflags _dat subdocs con@(ConDeclGADT { })
= concatMap (lookupCon dflags subdocs) (getConNames con) ++ f
diff --git a/haddock-api/src/Haddock/InterfaceFile.hs b/haddock-api/src/Haddock/InterfaceFile.hs
index 3ce2fabb..17be6fa1 100644
--- a/haddock-api/src/Haddock/InterfaceFile.hs
+++ b/haddock-api/src/Haddock/InterfaceFile.hs
@@ -83,7 +83,7 @@ binaryInterfaceMagic = 0xD0Cface
--
binaryInterfaceVersion :: Word16
#if (__GLASGOW_HASKELL__ >= 809) && (__GLASGOW_HASKELL__ < 811)
-binaryInterfaceVersion = 35
+binaryInterfaceVersion = 36
binaryInterfaceVersionCompatibility :: [Word16]
binaryInterfaceVersionCompatibility = [binaryInterfaceVersion]
diff --git a/haddock-library/CHANGES.md b/haddock-library/CHANGES.md
index d112db45..5b400d7c 100644
--- a/haddock-library/CHANGES.md
+++ b/haddock-library/CHANGES.md
@@ -1,7 +1,9 @@
-## Changes in version 1.8.0.1
+## Changes in version 1.9.0
* Fix build-time regression for `base < 4.7` (#1119)
+ * Update parsing to strip whitespace from table cells (#1074)
+
## Changes in version 1.8.0
* Support inline markup in markdown-style links (#875)
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 294ef5be..57f45887 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: haddock-library
-version: 1.8.0.1
+version: 1.9.0
synopsis: Library exposing some functionality of Haddock.
description: Haddock is a documentation-generation tool for Haskell
diff --git a/haddock.cabal b/haddock.cabal
index 425ed454..f01fe8fc 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: haddock
-version: 2.23.0
+version: 2.24.0
synopsis: A documentation-generation tool for Haskell libraries
description:
This is Haddock, a tool for automatically generating documentation
@@ -144,7 +144,7 @@ executable haddock
else
-- in order for haddock's advertised version number to have proper meaning,
-- we pin down to a single haddock-api version.
- build-depends: haddock-api == 2.23.0
+ build-depends: haddock-api == 2.24.0
test-suite html-test
type: exitcode-stdio-1.0
--
cgit v1.2.3
From 7013f52cca144e8d5e4deb08913370f1819dbc68 Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Thu, 26 Mar 2020 18:18:07 -0400
Subject: Update `.travis.yml` to work with GHC 8.10.1
* Regenerated the Travis file with `haskell-ci`
* Beef up `.cabal` files with more `tested-with` information
---
.travis.yml | 108 ++++++++++++++++++++--------------
haddock-api/haddock-api.cabal | 1 +
haddock-library/haddock-library.cabal | 13 +++-
haddock-test/haddock-test.cabal | 1 +
4 files changed, 78 insertions(+), 45 deletions(-)
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/.travis.yml b/.travis.yml
index 88292b40..32ac3065 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,12 +1,14 @@
# This Travis job script has been generated by a script via
#
-# haskell-ci 'haddock.cabal' '--output' '.travis.yml'
+# haskell-ci 'cabal.project' '--output=.travis.yml'
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
-# version: 0.5.20190916
+# version: 0.9.20200321
#
+version: ~> 1.0
language: c
+os: linux
dist: xenial
git:
# whether to recursively clone submodules
@@ -15,6 +17,7 @@ cache:
directories:
- $HOME/.cabal/packages
- $HOME/.cabal/store
+ - $HOME/.hlint
before_cache:
- rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
# remove files that are regenerated by 'cabal update'
@@ -24,13 +27,13 @@ before_cache:
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
- rm -rfv $CABALHOME/packages/head.hackage
-matrix:
+jobs:
include:
- - os: linux
- addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head], sources: [hvr-ghc]}}
- env:
- - GHC_ZIP='https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/download?job=validate-x86_64-linux-deb9'
-
+ - compiler: ghc-8.10.1
+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.10.1","cabal-install-3.2"]}}
+ os: linux
+ allow_failures:
+ - compiler: ghc-8.10.1
before_install:
- HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
- WITHCOMPILER="-w $HC"
@@ -43,32 +46,12 @@ before_install:
- TOP=$(pwd)
- "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
- echo $HCNUMVER
- - CABAL="$CABAL -vnormal+nowrap+markoutput"
+ - CABAL="$CABAL -vnormal+nowrap"
- set -o pipefail
- - |
- echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
- echo 'BEGIN { state = "output"; }' >> .colorful.awk
- echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
- echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
- echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
- echo ' if (state == "cabal") {' >> .colorful.awk
- echo ' print blue($0)' >> .colorful.awk
- echo ' } else {' >> .colorful.awk
- echo ' print $0' >> .colorful.awk
- echo ' }' >> .colorful.awk
- echo '}' >> .colorful.awk
- - cat .colorful.awk
- - |
- color_cabal_output () {
- awk -f $TOP/.colorful.awk
- }
- - echo text | color_cabal_output
-install:
- - ${CABAL} --version
- - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
- TEST=--enable-tests
- BENCH=--enable-benchmarks
- HEADHACKAGE=false
+ - HEADHACKAGE=true
- rm -f $CABALHOME/config
- |
echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
@@ -86,52 +69,89 @@ install:
echo " prefix: $CABALHOME" >> $CABALHOME/config
echo "repository hackage.haskell.org" >> $CABALHOME/config
echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
+ - |
+ if $HEADHACKAGE; then
+ echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config
+ echo "repository head.hackage.ghc.haskell.org" >> $CABALHOME/config
+ echo " url: https://ghc.gitlab.haskell.org/head.hackage/" >> $CABALHOME/config
+ echo " secure: True" >> $CABALHOME/config
+ echo " root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d" >> $CABALHOME/config
+ echo " 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329" >> $CABALHOME/config
+ echo " f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89" >> $CABALHOME/config
+ echo " key-threshold: 3" >> $CABALHOME/config
+ fi
+install:
+ - ${CABAL} --version
+ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
- |
echo "program-default-options" >> $CABALHOME/config
echo " ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config
- cat $CABALHOME/config
- - rm -fv cabal.project.local cabal.project.freeze
+ - rm -fv cabal.project cabal.project.local cabal.project.freeze
- travis_retry ${CABAL} v2-update -v
# Generate cabal.project
- - rm -rf cabal.project.local cabal.project.freeze
- - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(haddock)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
+ - rm -rf cabal.project cabal.project.local cabal.project.freeze
+ - touch cabal.project
+ - |
+ echo "packages: ." >> cabal.project
+ echo "packages: ./haddock-api" >> cabal.project
+ echo "packages: ./haddock-library" >> cabal.project
+ echo "packages: ./haddock-test" >> cabal.project
+ - |
+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(haddock|haddock-api|haddock-library|haddock-test)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
- cat cabal.project || true
- cat cabal.project.local || true
- if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
- - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output
+ - if [ -f "./haddock-api/configure.ac" ]; then (cd "./haddock-api" && autoreconf -i); fi
+ - if [ -f "./haddock-library/configure.ac" ]; then (cd "./haddock-library" && autoreconf -i); fi
+ - if [ -f "./haddock-test/configure.ac" ]; then (cd "./haddock-test" && autoreconf -i); fi
+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
- rm cabal.project.freeze
- - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output
- - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all | color_cabal_output
+ - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all
+ - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all
script:
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
# Packaging...
- - ${CABAL} v2-sdist all | color_cabal_output
+ - ${CABAL} v2-sdist all
# Unpacking...
- mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
- cd ${DISTDIR} || false
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
+ - PKGDIR_haddock="$(find . -maxdepth 1 -type d -regex '.*/haddock-[0-9.]*')"
+ - PKGDIR_haddock_api="$(find . -maxdepth 1 -type d -regex '.*/haddock-api-[0-9.]*')"
+ - PKGDIR_haddock_library="$(find . -maxdepth 1 -type d -regex '.*/haddock-library-[0-9.]*')"
+ - PKGDIR_haddock_test="$(find . -maxdepth 1 -type d -regex '.*/haddock-test-[0-9.]*')"
# Generate cabal.project
- rm -rf cabal.project cabal.project.local cabal.project.freeze
- touch cabal.project
- |
- echo "packages: ./haddock-*" >> cabal.project
+ echo "packages: ${PKGDIR_haddock}" >> cabal.project
+ echo "packages: ${PKGDIR_haddock_api}" >> cabal.project
+ echo "packages: ${PKGDIR_haddock_library}" >> cabal.project
+ echo "packages: ${PKGDIR_haddock_test}" >> cabal.project
- |
- - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(haddock)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(haddock|haddock-api|haddock-library|haddock-test)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
- cat cabal.project || true
- cat cabal.project.local || true
# Building...
# this builds all libraries and executables (without tests/benchmarks)
- - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
# Building with tests and benchmarks...
# build & run tests, build benchmarks
- - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
# Testing...
- - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
+ - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all
+ # cabal check...
+ - (cd ${PKGDIR_haddock} && ${CABAL} -vnormal check)
+ - (cd ${PKGDIR_haddock_api} && ${CABAL} -vnormal check)
+ - (cd ${PKGDIR_haddock_library} && ${CABAL} -vnormal check)
+ # haddock...
+ - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all
# Building without installed constraints for packages in global-db...
- rm -f cabal.project.local
- - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
-# REGENDATA ["haddock.cabal","--output",".travis.yml"]
+# REGENDATA ("0.9.20200321",["cabal.project","--output=.travis.yml"])
# EOF
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index 0324fcd6..54255e09 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -13,6 +13,7 @@ bug-reports: https://github.com/haskell/haddock/issues
copyright: (c) Simon Marlow, David Waern
category: Documentation
build-type: Simple
+tested-with: GHC==8.10.*
extra-source-files:
CHANGES.md
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 57f45887..1a06d0e5 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -12,11 +12,22 @@ description: Haddock is a documentation-generation tool for Haskell
itself, see the [haddock package](https://hackage.haskell.org/package/haddock).
license: BSD-2-Clause
-license-files: LICENSE
+license-file: LICENSE
maintainer: Alec Theriault , Alex Biehl , Simon Hengel , Mateusz Kowalczyk
homepage: http://www.haskell.org/haddock/
bug-reports: https://github.com/haskell/haddock/issues
category: Documentation
+tested-with: GHC == 7.4.2
+ , GHC == 7.6.3
+ , GHC == 7.8.4
+ , GHC == 7.10.3
+ , GHC == 8.0.2
+ , GHC == 8.2.2
+ , GHC == 8.4.4
+ , GHC == 8.6.5
+ , GHC == 8.8.3
+ , GHC == 8.10.1
+
extra-source-files:
CHANGES.md
fixtures/examples/*.input
diff --git a/haddock-test/haddock-test.cabal b/haddock-test/haddock-test.cabal
index 0dd3eb47..a722c30e 100644
--- a/haddock-test/haddock-test.cabal
+++ b/haddock-test/haddock-test.cabal
@@ -9,6 +9,7 @@ bug-reports: https://github.com/haskell/haddock/issues
copyright: (c) Simon Marlow, David Waern
category: Documentation
build-type: Simple
+tested-with: GHC==8.10.*
cabal-version: >= 1.10
stability: experimental
--
cgit v1.2.3
From 8edc70fef3f3a54238d981153a6ac42b2d7f0bde Mon Sep 17 00:00:00 2001
From: Alec Theriault
Date: Sat, 28 Mar 2020 13:12:50 -0400
Subject: Cleanup up GHC flags in `.cabal` files
* enable more useful warning flags in `haddock-api`, handle the new
warnings generated
* remove `-fwarn-tabs` (now we'd use `-Wtabs`, but this has been in
`-Wall` for a while now)
---
haddock-api/haddock-api.cabal | 12 ++++++++----
haddock-api/src/Haddock/Interface/Specialize.hs | 2 +-
haddock-api/src/Haddock/InterfaceFile.hs | 2 +-
haddock-library/haddock-library.cabal | 2 +-
haddock.cabal | 2 +-
5 files changed, 12 insertions(+), 8 deletions(-)
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index 54255e09..4abfd984 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -63,10 +63,14 @@ library
hs-source-dirs: src
- ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2
- ghc-options: -Wall
- if impl(ghc >= 8.0)
- ghc-options: -Wcompat -Wnoncanonical-monad-instances
+ ghc-options: -funbox-strict-fields -O2
+ -Wall
+ -Wcompat
+ -Widentities
+ -Wredundant-constraints
+ -Wnoncanonical-monad-instances
+ -Wmissing-home-modules
+
exposed-modules:
Documentation.Haddock
diff --git a/haddock-api/src/Haddock/Interface/Specialize.hs b/haddock-api/src/Haddock/Interface/Specialize.hs
index 19b03596..492818bd 100644
--- a/haddock-api/src/Haddock/Interface/Specialize.hs
+++ b/haddock-api/src/Haddock/Interface/Specialize.hs
@@ -295,7 +295,7 @@ renameBinder (KindedTyVar x lname lkind) =
renameBinder (XTyVarBndr nec) = noExtCon nec
-- | Core renaming logic.
-renameName :: (Eq name, SetName name) => name -> Rename name name
+renameName :: SetName name => name -> Rename name name
renameName name = do
RenameEnv { .. } <- get
case Map.lookup (getName name) rneCtx of
diff --git a/haddock-api/src/Haddock/InterfaceFile.hs b/haddock-api/src/Haddock/InterfaceFile.hs
index 7b0f29f4..cb60fb00 100644
--- a/haddock-api/src/Haddock/InterfaceFile.hs
+++ b/haddock-api/src/Haddock/InterfaceFile.hs
@@ -158,7 +158,7 @@ writeInterfaceFile filename iface = do
type NameCacheAccessor m = (m NameCache, NameCache -> m ())
-nameCacheFromGhc :: forall m. (GhcMonad m, MonadIO m) => NameCacheAccessor m
+nameCacheFromGhc :: GhcMonad m => NameCacheAccessor m
nameCacheFromGhc = ( read_from_session , write_to_session )
where
read_from_session = do
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 1a06d0e5..24ca920f 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -44,7 +44,7 @@ common lib-defaults
, text ^>= 1.2.3.0
, parsec ^>= 3.1.13.0
- ghc-options: -funbox-strict-fields -Wall -fwarn-tabs
+ ghc-options: -funbox-strict-fields -Wall
if impl(ghc >= 8.0)
ghc-options: -Wcompat -Wnoncanonical-monad-instances
diff --git a/haddock.cabal b/haddock.cabal
index f01fe8fc..1d6ad180 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -62,7 +62,7 @@ executable haddock
default-language: Haskell2010
main-is: Main.hs
hs-source-dirs: driver
- ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2 -threaded
+ ghc-options: -funbox-strict-fields -Wall -O2 -threaded
-- haddock typically only supports a single GHC major version
build-depends:
--
cgit v1.2.3
From 5d034ee2ed72839a8472dba59f83b1b348691cc5 Mon Sep 17 00:00:00 2001
From: Felix Yan
Date: Thu, 2 Apr 2020 04:43:40 +0800
Subject: Allow QuickCheck 2.14
Builds fine and all tests pass.
---
haddock-library/haddock-library.cabal | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'haddock-library/haddock-library.cabal')
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 24ca920f..9e707f1b 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -87,7 +87,7 @@ test-suite spec
build-depends:
, base-compat ^>= 0.9.3 || ^>= 0.11.0
- , QuickCheck ^>= 2.11 || ^>= 2.13.2
+ , QuickCheck ^>= 2.11 || ^>= 2.13.2 || ^>= 2.14
, deepseq ^>= 1.3.0.0 || ^>= 1.4.0.0
-- NB: build-depends & build-tool-depends have independent
--
cgit v1.2.3