[Git][ghc/ghc][master] 2 commits: haddock: Fix the testsuites of the haddock-library
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed May 22 04:35:50 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
9317c6fb by David Binder at 2024-05-22T00:34:21-04:00
haddock: Fix the testsuites of the haddock-library
- Apply all the metadata revisions from Hackage
to the cabal file.
- Fix the `ParserSpec.hs` file in the `spec`
testsuite of haddock-library.
- Make `CHANGES.md` an extra-doc-file instead of
an extra-source-file.
- - - - -
54073b02 by David Binder at 2024-05-22T00:34:21-04:00
haddock: Fix parser of @since pragma
The testsuite contained tests for annotations of
the form `@since foo-bar-0.5.0`, but the parser was
written incorrectly.
- - - - -
3 changed files:
- utils/haddock/haddock-library/haddock-library.cabal
- utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
- utils/haddock/haddock-library/test/Documentation/Haddock/ParserSpec.hs
Changes:
=====================================
utils/haddock/haddock-library/haddock-library.cabal
=====================================
@@ -30,8 +30,10 @@ tested-with: GHC == 7.4.2
, GHC == 9.0.1
, GHC == 9.2.0
-extra-source-files:
+extra-doc-files:
CHANGES.md
+
+extra-source-files:
fixtures/examples/*.input
fixtures/examples/*.parsed
@@ -86,19 +88,19 @@ test-suite spec
Documentation.Haddock.Parser.Identifier
build-depends:
- , base-compat ^>= 0.12.0
+ , base-compat ^>= 0.12.0 || ^>= 0.13.0
, QuickCheck ^>= 2.11 || ^>= 2.13.2 || ^>= 2.14
- , deepseq ^>= 1.3.0.0 || ^>= 1.4.0.0
+ , deepseq ^>= 1.3.0.0 || ^>= 1.4.0.0 || ^>=1.5.0.0
-- NB: build-depends & build-tool-depends have independent
-- install-plans, so it's best to limit to a single major
-- version of `hspec` & `hspec-discover` to ensure
-- intercompatibility
build-depends:
- , hspec >= 2.4.4 && < 2.10
+ , hspec >= 2.4.4 && < 2.12
build-tool-depends:
- , hspec-discover:hspec-discover >= 2.4.4 && < 2.10
+ , hspec-discover:hspec-discover >= 2.4.4 && < 2.12
test-suite fixtures
type: exitcode-stdio-1.0
@@ -113,11 +115,11 @@ test-suite fixtures
, base
-- extra dependencies
- , base-compat ^>= 0.12.0
+ , base-compat ^>= 0.12.0 || ^>=0.13.0
, directory ^>= 1.3.0.2
, filepath ^>= 1.4.1.2
- , optparse-applicative ^>= 0.15
- , tree-diff ^>= 0.2
+ , optparse-applicative >= 0.15 && < 0.19
+ , tree-diff ^>= 0.2 || ^>= 0.3
source-repository head
type: git
=====================================
utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
=====================================
@@ -28,7 +28,7 @@ import Control.Applicative
import Control.Arrow (first)
import Control.Monad
import Data.Char (chr, isAlpha, isSpace, isUpper)
-import Data.List (elemIndex, intercalate, unfoldr)
+import Data.List (elemIndex, intercalate, unfoldr, intersperse)
import Data.Maybe (fromMaybe, mapMaybe)
import Data.Monoid
import qualified Data.Set as Set
@@ -576,11 +576,12 @@ since = do
return DocEmpty
where
version = do
- pkg <- Parsec.optionMaybe $ Parsec.try $ package <* Parsec.char '-'
+ pkg <- Parsec.optionMaybe $ Parsec.try $ package
ver <- decimal `Parsec.sepBy1` "."
return (MetaSince pkg ver)
- package = Parsec.many1 $ Parsec.alphaNum <|> Parsec.oneOf "_-"
+ package = combine <$> (Parsec.many1 (Parsec.letter <|> Parsec.char '_')) `Parsec.endBy1` (Parsec.char '-')
+ combine = concat . intersperse "-"
-- | Headers inside the comment denoted with @=@ signs, up to 6 levels
-- deep.
=====================================
utils/haddock/haddock-library/test/Documentation/Haddock/ParserSpec.hs
=====================================
@@ -26,12 +26,6 @@ instance IsString (Doc String) where
instance IsString a => IsString (Maybe a) where
fromString = Just . fromString
-emptyMeta :: Meta
-emptyMeta =
- Meta
- { _metaSince = Nothing
- }
-
parseParas :: String -> MetaDoc () String
parseParas = overDoc Parse.toRegular . Parse.parseParas Nothing
@@ -543,21 +537,21 @@ spec = do
it "adds specified version to the result" $ do
parseParas "@since 0.5.0"
`shouldBe` MetaDoc
- { _meta = emptyMeta{_version = Just [0, 5, 0]}
+ { _meta = Meta{_metaSince = Just (MetaSince{sincePackage = Nothing, sinceVersion = [0, 5, 0]})}
, _doc = DocEmpty
}
it "ignores trailing whitespace" $ do
parseParas "@since 0.5.0 \t "
`shouldBe` MetaDoc
- { _meta = emptyMeta{_version = Just [0, 5, 0]}
+ { _meta = Meta{_metaSince = Just (MetaSince{sincePackage = Nothing, sinceVersion = [0, 5, 0]})}
, _doc = DocEmpty
}
it "does not allow trailing input" $ do
parseParas "@since 0.5.0 foo"
`shouldBe` MetaDoc
- { _meta = emptyMeta{_version = Nothing}
+ { _meta = Meta{_metaSince = Nothing}
, _doc = DocParagraph "@since 0.5.0 foo"
}
@@ -565,7 +559,7 @@ spec = do
parseParas "@since foo-bar-0.5.0"
`shouldBe` MetaDoc
{ _meta =
- emptyMeta
+ Meta
{ _metaSince =
Just $
MetaSince
@@ -573,7 +567,7 @@ spec = do
, sinceVersion = [0, 5, 0]
}
}
- , _doc = DocParagraph "@since 0.5.0 foo"
+ , _doc = DocEmpty
}
context "when given multiple times" $ do
@@ -586,7 +580,7 @@ spec = do
]
`shouldBe` MetaDoc
{ _meta =
- emptyMeta
+ Meta
{ _metaSince =
Just $
MetaSince
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3bad5d5550977eddf10ef1922c13984ba8646154...54073b02290369f71640cd714e83b8ba6557663c
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3bad5d5550977eddf10ef1922c13984ba8646154...54073b02290369f71640cd714e83b8ba6557663c
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240522/3dfc276e/attachment-0001.html>
More information about the ghc-commits
mailing list