aboutsummaryrefslogtreecommitdiff
path: root/haddock-library
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-06-25 15:02:48 +0200
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-06-25 15:04:49 +0200
commit64aee65f62c7184f31d6778d0d3d9b6dc96e4e91 (patch)
tree7ad6aa8dbb8e2e8a7dd43253bc686e6c71cc8a6f /haddock-library
parent526067188c056a5d73e7e44671ca98baf12d666b (diff)
Drop DocParagraph from front of headers
I can not remember why they were wrapped in paragraphs to begin with and it seems unnecessary now that I test it. Closes #307.
Diffstat (limited to 'haddock-library')
-rw-r--r--haddock-library/src/Documentation/Haddock/Parser.hs7
-rw-r--r--haddock-library/test/Documentation/Haddock/ParserSpec.hs9
2 files changed, 10 insertions, 6 deletions
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index f13cedc6..1d98601a 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -220,6 +220,11 @@ paragraph = examples <|> skipSpace *> (list <|> birdtracks <|> codeblock
-- | Headers inside the comment denoted with @=@ signs, up to 6 levels
-- deep.
+--
+-- >>> parseOnly header "= Hello"
+-- Right (DocHeader (Header {headerLevel = 1, headerTitle = DocString "Hello"}))
+-- >>> parseOnly header "== World"
+-- Right (DocHeader (Header {headerLevel = 2, headerTitle = DocString "World"}))
header :: Parser (DocH mod Identifier)
header = do
let psers = map (string . encodeUtf8 . concat . flip replicate "=") [6, 5 .. 1]
@@ -227,7 +232,7 @@ header = do
delim <- decodeUtf8 <$> pser
line <- skipHorizontalSpace *> nonEmptyLine >>= return . parseString
rest <- paragraph <|> return mempty
- return $ DocParagraph (DocHeader (Header (length delim) line)) <> rest
+ return $ DocHeader (Header (length delim) line) <> rest
textParagraph :: Parser (DocH mod Identifier)
textParagraph = docParagraph . parseString . intercalate "\n" <$> many1 nonEmptyLine
diff --git a/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
index 4bcbbec7..6d05791b 100644
--- a/haddock-library/test/Documentation/Haddock/ParserSpec.hs
+++ b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
@@ -808,16 +808,15 @@ spec = do
context "when parsing function documentation headers" $ do
it "can parse a simple header" $ do
"= Header 1\nHello." `shouldParseTo`
- DocParagraph (DocHeader (Header 1 "Header 1"))
+ (DocHeader (Header 1 "Header 1"))
<> DocParagraph "Hello."
it "allow consecutive headers" $ do
"= Header 1\n== Header 2" `shouldParseTo`
- DocParagraph (DocHeader (Header 1 "Header 1"))
- <> DocParagraph (DocHeader (Header 2 "Header 2"))
+ DocHeader (Header 1 "Header 1")
+ <> DocHeader (Header 2 "Header 2")
it "accepts markup in the header" $ do
"= /Header/ __1__\nFoo" `shouldParseTo`
- DocParagraph (DocHeader
- (Header 1 (DocEmphasis "Header" <> " " <> DocBold "1")))
+ DocHeader (Header 1 (DocEmphasis "Header" <> " " <> DocBold "1"))
<> DocParagraph "Foo"