packages feed

haddock-library 1.10.0 → 1.11.0

raw patch · 12 files changed

+105/−75 lines, 12 filesdep −bytestringdep −transformersdep ~QuickCheckdep ~basedep ~base-compatPVP ok

version bump matches the API change (PVP)

Dependencies removed: bytestring, transformers

Dependency ranges changed: QuickCheck, base, base-compat, containers, deepseq, hspec, optparse-applicative, text, tree-diff

API changes (from Hackage documentation)

- Documentation.Haddock.Types: DocOrderedList :: [DocH mod id] -> DocH mod id
+ Documentation.Haddock.Types: DocOrderedList :: [(Int, DocH mod id)] -> DocH mod id
- Documentation.Haddock.Types: Markup :: a -> (String -> a) -> (a -> a) -> (a -> a -> a) -> (id -> a) -> (mod -> a) -> (ModLink a -> a) -> (a -> a) -> (a -> a) -> (a -> a) -> (a -> a) -> ([a] -> a) -> ([a] -> a) -> ([(a, a)] -> a) -> (a -> a) -> (Hyperlink a -> a) -> (String -> a) -> (Picture -> a) -> (String -> a) -> (String -> a) -> (String -> a) -> ([Example] -> a) -> (Header a -> a) -> (Table a -> a) -> DocMarkupH mod id a
+ Documentation.Haddock.Types: Markup :: a -> (String -> a) -> (a -> a) -> (a -> a -> a) -> (id -> a) -> (mod -> a) -> (ModLink a -> a) -> (a -> a) -> (a -> a) -> (a -> a) -> (a -> a) -> ([a] -> a) -> ([(Int, a)] -> a) -> ([(a, a)] -> a) -> (a -> a) -> (Hyperlink a -> a) -> (String -> a) -> (Picture -> a) -> (String -> a) -> (String -> a) -> (String -> a) -> ([Example] -> a) -> (Header a -> a) -> (Table a -> a) -> DocMarkupH mod id a
- Documentation.Haddock.Types: [markupOrderedList] :: DocMarkupH mod id a -> [a] -> a
+ Documentation.Haddock.Types: [markupOrderedList] :: DocMarkupH mod id a -> [(Int, a)] -> a

Files

CHANGES.md view
@@ -1,7 +1,10 @@-## Changes in version 1.10.0+## Changes in version 1.11.0 - * Add support for labeled module references (#1319, #1315)+  * Add support for linking identifiers with a quote between backticks (#1408) +## Changes in version 1.10.0++  * Add support for labeled module references (#1360) ## Changes in version 1.9.0   * Fix build-time regression for `base < 4.7` (#1119)
fixtures/Fixtures.hs view
@@ -9,8 +9,7 @@ import Data.List (foldl') import Data.Traversable (for) import GHC.Generics (Generic)-import Prelude ()-import Prelude.Compat+import Prelude import System.Directory (getDirectoryContents) import System.Exit (exitFailure) import System.FilePath
fixtures/examples/linkInlineMarkup.parsed view
@@ -3,7 +3,6 @@      (DocString "Bla ")      (DocHyperlink         Hyperlink-          {hyperlinkLabel = Just-                              (DocAppend-                                 (DocString "link ") (DocEmphasis (DocString "emphasized"))),+          {hyperlinkLabel = Just (DocAppend (DocString "link ")+                                            (DocEmphasis (DocString "emphasized"))),            hyperlinkUrl = "http://example.com"}))
haddock-library.cabal view
@@ -1,6 +1,6 @@-cabal-version:        2.2+cabal-version:        3.0 name:                 haddock-library-version:              1.10.0+version:              1.11.0 synopsis:             Library exposing some functionality of Haddock.  description:          Haddock is a documentation-generation tool for Haskell@@ -28,6 +28,7 @@                     , GHC == 8.8.3                     , GHC == 8.10.1                     , GHC == 9.0.1+                    , GHC == 9.2.0  extra-source-files:   CHANGES.md@@ -38,11 +39,9 @@   default-language: Haskell2010    build-depends:-    , base         >= 4.5     && < 4.16-    , bytestring   ^>= 0.9.2.1 || ^>= 0.10.0.0+    , base         >= 4.5     && < 4.17     , containers   ^>= 0.4.2.1 || ^>= 0.5.0.0 || ^>= 0.6.0.1-    , transformers ^>= 0.3.0.0 || ^>= 0.4.1.0 || ^>= 0.5.0.0-    , text         ^>= 1.2.3.0+    , text         ^>= 1.2.3.0 || ^>= 2.0     , parsec       ^>= 3.1.13.0    ghc-options: -funbox-strict-fields -Wall@@ -87,7 +86,7 @@     Documentation.Haddock.Parser.Identifier    build-depends:-    , base-compat  ^>= 0.9.3 || ^>= 0.11.0+    , base-compat  ^>= 0.12.0     , QuickCheck   ^>= 2.11  || ^>= 2.13.2 || ^>= 2.14      , deepseq      ^>= 1.3.0.0 || ^>= 1.4.0.0 @@ -96,10 +95,10 @@   --     version of `hspec` & `hspec-discover` to ensure   --     intercompatibility   build-depends:-    , hspec                          >= 2.4.4    && < 2.8+    , hspec                          >= 2.4.4    && < 2.10    build-tool-depends:-    , hspec-discover:hspec-discover  >= 2.4.4    && < 2.8+    , hspec-discover:hspec-discover  >= 2.4.4    && < 2.10  test-suite fixtures   type:             exitcode-stdio-1.0@@ -114,11 +113,11 @@     , base        -- extra dependencies-    , base-compat           ^>= 0.9.3 || ^>= 0.11.0+    , base-compat           ^>= 0.12.0     , directory             ^>= 1.3.0.2     , filepath              ^>= 1.4.1.2     , optparse-applicative  ^>= 0.15-    , tree-diff             ^>= 0.1+    , tree-diff             ^>= 0.2  source-repository head   type:     git
src/CompatPrelude.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} -#if !MIN_VERSION_base(4,5,0)+#ifdef __HLINT__+#elif !MIN_VERSION_base(4,5,0) # error This module doesn't provide compat-shims for versions prior to base-4.5 #endif 
src/Documentation/Haddock/Markup.hs view
@@ -22,7 +22,7 @@ markup m (DocBold d)                    = markupBold m (markup m d) markup m (DocMonospaced d)              = markupMonospaced m (markup m d) markup m (DocUnorderedList ds)          = markupUnorderedList m (map (markup m) ds)-markup m (DocOrderedList ds)            = markupOrderedList m (map (markup m) ds)+markup m (DocOrderedList ds)            = markupOrderedList m (map (\(index, a) -> (index, markup m a)) ds) markup m (DocDefList ds)                = markupDefList m (map (markupPair m) ds) markup m (DocCodeBlock d)               = markupCodeBlock m (markup m d) markup m (DocHyperlink (Hyperlink u l)) = markupHyperlink m (Hyperlink u (fmap (markup m) l))
src/Documentation/Haddock/Parser.hs view
@@ -78,7 +78,7 @@     g (DocMonospaced x) = DocMonospaced $ g x     g (DocBold x) = DocBold $ g x     g (DocUnorderedList x) = DocUnorderedList $ fmap g x-    g (DocOrderedList x) = DocOrderedList $ fmap g x+    g (DocOrderedList x) = DocOrderedList $ fmap (\(index, a) -> (index, g a)) x     g (DocDefList x) = DocDefList $ fmap (\(y, z) -> (g y, g z)) x     g (DocCodeBlock x) = DocCodeBlock $ g x     g (DocHyperlink (Hyperlink u x)) = DocHyperlink (Hyperlink u (fmap g x))@@ -173,11 +173,11 @@ -- Once we have checked for any of these and tried to parse the -- relevant markup, we can assume they are used as regular text. specialChar :: [Char]-specialChar = "_/<@\"&'`# "+specialChar = "_/<@\"&'`#[ "  -- | Plain, regular parser for text. Called as one of the last parsers -- to ensure that we have already given a chance to more meaningful parsers--- before capturing their characers.+-- before capturing their characters. string' :: Parser (DocH mod a) string' = DocString . unescape . T.unpack <$> takeWhile1_ (`notElem` specialChar)   where@@ -361,7 +361,7 @@     firstRow <- parseFirstRow     let len = T.length firstRow -    -- then we parse all consequtive rows starting and ending with + or |,+    -- then we parse all consecutive rows starting and ending with + or |,     -- of the width `len`.     restRows <- many (try (parseRestRows len)) @@ -577,10 +577,24 @@ orderedList :: Text -> Parser (DocH mod Identifier) orderedList indent = DocOrderedList <$> p   where-    p = (paren <|> dot) *> innerList indent p+    p = do+      index <- paren <|> dot+      innerList' indent p index     dot = (decimal :: Parser Int) <* "."     paren = "(" *> decimal <* ")" +-- | Like 'innerList' but takes the parsed index of the list item+innerList' :: Text -> Parser [(Int, DocH mod Identifier)]+           -> Int+           -> Parser [(Int, DocH mod Identifier)]+innerList' indent item index = do+  c <- takeLine+  (cs, items) <- more indent item+  let contents = docParagraph . parseText . dropNLs . T.unlines $ c : cs+  return $ case items of+    Left p -> [(index, contents `docAppend` p)]+    Right i -> (index, contents) : i+ -- | Generic function collecting any further lines belonging to the -- list entry and recursively collecting any further lists in the -- same paragraph. Usually used as@@ -710,7 +724,7 @@                  Just (' ',t') -> Just t'                  _ -> Nothing --- | Parses examples. Examples are a paragraph level entitity (separated by an empty line).+-- | Parses examples. Examples are a paragraph level entity (separated by an empty line). -- Consecutive examples are accepted. examples :: Parser (DocH mod a) examples = DocExamples <$> (many (try (skipHorizontalSpace *> "\n")) *> go)
src/Documentation/Haddock/Parser/Identifier.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE BangPatterns #-}-{-# LANGUAGE ViewPatterns #-} -- | -- Module      :  Documentation.Haddock.Parser.Identifier -- Copyright   :  (c) Alec Theriault 2019,@@ -150,9 +149,9 @@       | otherwise = Nothing      -- | Parse all but the last quote off the front of the input-    -- PRECONDITION: T.head t == '\''+    -- PRECONDITION: T.head t `elem` ['\'', '`']     quotes :: Text -> (Int, Text)-    quotes t = let !n = T.length (T.takeWhile (== '\'') t) - 1+    quotes t = let !n = T.length (T.takeWhile (`elem` ['\'', '`']) t) - 1                in (n, T.drop n t)      -- | Parse an operator off the front of the input
src/Documentation/Haddock/Parser/Monad.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE BangPatterns #-}-{-# LANGUAGE TypeSynonymInstances #-} -- | -- Module      :  Documentation.Haddock.Parser.Monad -- Copyright   :  (c) Alec Theriault 2018-2019,@@ -40,7 +39,7 @@ import           Prelude hiding (takeWhile) import           CompatPrelude --- | The only bit of information we really care about truding along with us+-- | The only bit of information we really care about trudging along with us -- through parsing is the version attached to a @\@since@ annotation - if -- the doc even contained one. newtype ParserState = ParserState {
src/Documentation/Haddock/Types.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, DeriveFunctor, DeriveFoldable, DeriveTraversable #-}+{-# LANGUAGE CPP, DeriveTraversable #-}  -- | -- Module      :  Documentation.Haddock.Types@@ -124,7 +124,7 @@   | DocMonospaced (DocH mod id)   | DocBold (DocH mod id)   | DocUnorderedList [DocH mod id]-  | DocOrderedList [DocH mod id]+  | DocOrderedList [(Int, DocH mod id)]   | DocDefList [(DocH mod id, DocH mod id)]   | DocCodeBlock (DocH mod id)   | DocHyperlink (Hyperlink (DocH mod id))@@ -154,7 +154,7 @@   bimap f g (DocMonospaced doc) = DocMonospaced (bimap f g doc)   bimap f g (DocBold doc) = DocBold (bimap f g doc)   bimap f g (DocUnorderedList docs) = DocUnorderedList (map (bimap f g) docs)-  bimap f g (DocOrderedList docs) = DocOrderedList (map (bimap f g) docs)+  bimap f g (DocOrderedList docs) = DocOrderedList (map (\(index, a) -> (index, bimap f g a)) docs)   bimap f g (DocDefList docs) = DocDefList (map (bimap f g *** bimap f g) docs)   bimap f g (DocCodeBlock doc) = DocCodeBlock (bimap f g doc)   bimap f g (DocHyperlink (Hyperlink url lbl)) = DocHyperlink (Hyperlink url (fmap (bimap f g) lbl))@@ -180,7 +180,7 @@   bifoldr f g z (DocMonospaced doc) = bifoldr f g z doc   bifoldr f g z (DocBold doc) = bifoldr f g z doc   bifoldr f g z (DocUnorderedList docs) = foldr (flip (bifoldr f g)) z docs-  bifoldr f g z (DocOrderedList docs) = foldr (flip (bifoldr f g)) z docs+  bifoldr f g z (DocOrderedList docs) = foldr (flip (bifoldr f g)) z (map snd docs)   bifoldr f g z (DocDefList docs) = foldr (\(l, r) acc -> bifoldr f g (bifoldr f g acc l) r) z docs   bifoldr f g z (DocCodeBlock doc) = bifoldr f g z doc   bifoldr f g z (DocHeader (Header _ title)) = bifoldr f g z title@@ -201,7 +201,8 @@   bitraverse f g (DocMonospaced doc) = DocMonospaced <$> bitraverse f g doc   bitraverse f g (DocBold doc) = DocBold <$> bitraverse f g doc   bitraverse f g (DocUnorderedList docs) = DocUnorderedList <$> traverse (bitraverse f g) docs-  bitraverse f g (DocOrderedList docs) = DocOrderedList <$> traverse (bitraverse f g) docs+  bitraverse f g (DocOrderedList docs) = DocOrderedList <$> traverseSnd (bitraverse f g) docs+    where traverseSnd f' = traverse (\(x, a) -> (\b -> (x, b)) <$> f' a)   bitraverse f g (DocDefList docs) = DocDefList <$> traverse (bitraverse (bitraverse f g) (bitraverse f g)) docs   bitraverse f g (DocCodeBlock doc) = DocCodeBlock <$> bitraverse f g doc   bitraverse f g (DocHyperlink (Hyperlink url lbl)) = DocHyperlink <$> (Hyperlink url <$> traverse (bitraverse f g) lbl)@@ -246,7 +247,7 @@   , markupBold                 :: a -> a   , markupMonospaced           :: a -> a   , markupUnorderedList        :: [a] -> a-  , markupOrderedList          :: [a] -> a+  , markupOrderedList          :: [(Int,a)] -> a   , markupDefList              :: [(a,a)] -> a   , markupCodeBlock            :: a -> a   , markupHyperlink            :: Hyperlink a -> a
test/Documentation/Haddock/Parser/UtilSpec.hs view
@@ -1,11 +1,14 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Documentation.Haddock.Parser.UtilSpec (main, spec) where  import Documentation.Haddock.Parser.Monad import Documentation.Haddock.Parser.Util-import Data.Either.Compat (isLeft)+import Data.Either (isLeft) import Test.Hspec+#if !(MIN_VERSION_base(4,8,0)) import Control.Applicative+#endif  main :: IO () main = hspec spec
test/Documentation/Haddock/ParserSpec.hs view
@@ -121,6 +121,9 @@       it "can parse identifiers ending with a single quote" $ do         "'foo''" `shouldParseTo` DocIdentifier "foo'" +      it "can parse identifiers in backticks ending with a single quote" $ do+        "`foo'`" `shouldParseTo` DocIdentifier "foo'"+       it "can parse an identifier containing a digit" $ do         "'f0'" `shouldParseTo` DocIdentifier "f0" @@ -576,28 +579,38 @@         it "turns it into a code block" $ do           "@foo@" `shouldParseTo` DocCodeBlock "foo" -      context "when a paragraph starts with a markdown link" $ do-        it "correctly parses it as a text paragraph (not a definition list)" $ do-          "[label](url)" `shouldParseTo`-            DocParagraph (hyperlink "url" "label")+      context "when a paragraph contains a markdown link" $ do+        it "correctly parses the link" $ do+          "Blah [label](url)" `shouldParseTo`+            DocParagraph ("Blah " <> hyperlink "url" "label") -        it "can be followed by an other paragraph" $ do-          "[label](url)\n\nfoobar" `shouldParseTo`-            DocParagraph (hyperlink "url" "label") <> DocParagraph "foobar"+        context "when the paragraph starts with the markdown link" $ do+          it "correctly parses it as a text paragraph (not a definition list)" $ do+            "[label](url)" `shouldParseTo`+              DocParagraph (hyperlink "url" "label") -        context "when paragraph contains additional text" $ do-          it "accepts more text after the link" $ do-            "[label](url) foo bar baz" `shouldParseTo`-              DocParagraph (hyperlink "url" "label" <> " foo bar baz")+          it "can be followed by an other paragraph" $ do+            "[label](url)\n\nfoobar" `shouldParseTo`+              DocParagraph (hyperlink "url" "label") <> DocParagraph "foobar" -          it "accepts a newline right after the markdown link" $ do-            "[label](url)\nfoo bar baz" `shouldParseTo`-              DocParagraph (hyperlink "url" "label" <> " foo bar baz")+          context "when paragraph contains additional text" $ do+            it "accepts more text after the link" $ do+              "[label](url) foo bar baz" `shouldParseTo`+                DocParagraph (hyperlink "url" "label" <> " foo bar baz") -          it "can be followed by an other paragraph" $ do-            "[label](url)foo\n\nbar" `shouldParseTo`-              DocParagraph (hyperlink "url" "label" <> "foo") <> DocParagraph "bar"+            it "accepts a newline right after the markdown link" $ do+              "[label](url)\nfoo bar baz" `shouldParseTo`+                DocParagraph (hyperlink "url" "label" <> " foo bar baz") +            it "can be followed by an other paragraph" $ do+              "[label](url)foo\n\nbar" `shouldParseTo`+                DocParagraph (hyperlink "url" "label" <> "foo") <> DocParagraph "bar"++        context "when the link starts on a new line not at the beginning of the paragraph" $ do+          it "correctly parses the link" $ do+            "Bla\n[label](url)" `shouldParseTo`+              DocParagraph ("Bla\n" <> hyperlink "url" "label")+     context "when parsing birdtracks" $ do       it "parses them as a code block" $ do         unlines [@@ -810,7 +823,7 @@       it "can nest another type of list inside" $ do         "* foo\n\n    1. bar" `shouldParseTo`           DocUnorderedList [ DocParagraph "foo"-                             <> DocOrderedList [DocParagraph "bar"]]+                             <> DocOrderedList [(1, DocParagraph "bar")]]        it "can nest a code block inside" $ do         "* foo\n\n    @foo bar baz@" `shouldParseTo`@@ -849,7 +862,7 @@           DocUnorderedList [ DocParagraph "foo"                              <> DocUnorderedList [ DocParagraph "bar" ]                            ]-          <> DocOrderedList [ DocParagraph "baz" ]+          <> DocOrderedList [ (1, DocParagraph "baz") ]        it "allows arbitrary initial indent of a list" $ do         unlines@@ -873,20 +886,20 @@           DocDefList [ ("foo", "foov"                                <> DocDefList [ ("bar", "barv") ])                      ]-          <> DocOrderedList [ DocParagraph "baz" ]+          <> DocOrderedList [ (1, DocParagraph "baz") ]        it "list order is preserved in presence of nesting + extra text" $ do         "1. Foo\n\n    > Some code\n\n2. Bar\n\nSome text"           `shouldParseTo`-          DocOrderedList [ DocParagraph "Foo" <> DocCodeBlock "Some code"-                         , DocParagraph "Bar"+          DocOrderedList [ (1, DocParagraph "Foo" <> DocCodeBlock "Some code")+                         , (2, DocParagraph "Bar")                          ]           <> DocParagraph (DocString "Some text")          "1. Foo\n\n2. Bar\n\nSome text"           `shouldParseTo`-          DocOrderedList [ DocParagraph "Foo"-                         , DocParagraph "Bar"+          DocOrderedList [ (1, DocParagraph "Foo")+                         , (2, DocParagraph "Bar")                          ]           <> DocParagraph (DocString "Some text") @@ -970,9 +983,9 @@           , " 3. three"           ]         `shouldParseTo` DocOrderedList [-            DocParagraph "one"-          , DocParagraph "two"-          , DocParagraph "three"+            (1, DocParagraph "one")+          , (1, DocParagraph "two")+          , (3, DocParagraph "three")           ]        it "ignores empty lines between list items" $ do@@ -982,12 +995,12 @@           , "2. two"           ]         `shouldParseTo` DocOrderedList [-            DocParagraph "one"-          , DocParagraph "two"+            (1, DocParagraph "one")+          , (2, DocParagraph "two")           ]        it "accepts an empty list item" $ do-        "1." `shouldParseTo` DocOrderedList [DocParagraph DocEmpty]+        "1." `shouldParseTo` DocOrderedList [(1, DocParagraph DocEmpty)]        it "accepts multi-line list items" $ do         unlines [@@ -997,12 +1010,12 @@           , "more two"           ]         `shouldParseTo` DocOrderedList [-            DocParagraph "point one\n  more one"-          , DocParagraph "point two\nmore two"+            (1, DocParagraph "point one\n  more one")+          , (1, DocParagraph "point two\nmore two")           ]        it "accepts markup in list items" $ do-        "1. /foo/" `shouldParseTo` DocOrderedList [DocParagraph (DocEmphasis "foo")]+        "1. /foo/" `shouldParseTo` DocOrderedList [(1, DocParagraph (DocEmphasis "foo"))]        it "requires empty lines between list and other paragraphs" $ do         unlines [@@ -1012,7 +1025,7 @@           , ""           , "baz"           ]-        `shouldParseTo` DocParagraph "foo" <> DocOrderedList [DocParagraph "bar"] <> DocParagraph "baz"+        `shouldParseTo` DocParagraph "foo" <> DocOrderedList [(1, DocParagraph "bar")] <> DocParagraph "baz"      context "when parsing definition lists" $ do       it "parses a simple list" $ do@@ -1099,8 +1112,8 @@                 ] `shouldParseTo`           DocUnorderedList [ DocParagraph "bullet"                            , DocParagraph "different bullet"]-          <> DocOrderedList [ DocParagraph "ordered"-                            , DocParagraph "different bullet"+          <> DocOrderedList [ (1, DocParagraph "ordered")+                            , (2, DocParagraph "different bullet")                             ]           <> DocDefList [ ("cat", "kitten")                         , ("pineapple", "fruit")