[commit: haddock] 2.15, 2.15.0.1, 2.15.0.2, T6018-injective-type-families, adamse-D1033, clean, fix-travis, ghc-head, master, metainfo, v2.15, wip/10268, wip/10313, wip/D538, wip/D538-1, wip/D538-2, wip/D538-3, wip/D538-4, wip/D538-5, wip/D538-6, wip/D548-master, wip/D548-master-2, wip/T10483, wip/T8584, wip/T9840, wip/api-ann-hstylit, wip/api-ann-hstylit-1, wip/api-ann-hstylit-2, wip/api-ann-hstylit-3, wip/api-ann-hstylit-4, wip/api-ann-hstylit-5, wip/api-annot-tweaks-7.10, wip/api-annots-ghc-7.10-3, wip/ast-annotations-separate, wip/ast-prepare-annotations, wip/ast-prepare-annotations-final, wip/ast-prepare-annotations-final2, wip/ast-prepare-annotations-final3, wip/ast-prepare-annotations-final4, wip/ast-prepare-annotations-final5, wip/ast-prepare-annotations-final6, wip/attoparsec-update, wip/landmine-param-family, wip/orf-new, wip/orf-reboot, wip/pattern-synonyms, wip/rae, wip/remove-cabal-dep, wip/trac-9744: Drop DocParagraph from front of headers (64aee65)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:29:08 UTC 2015


Repository : ssh://git@git.haskell.org/haddock

On branches: 2.15,2.15.0.1,2.15.0.2,T6018-injective-type-families,adamse-D1033,clean,fix-travis,ghc-head,master,metainfo,v2.15,wip/10268,wip/10313,wip/D538,wip/D538-1,wip/D538-2,wip/D538-3,wip/D538-4,wip/D538-5,wip/D538-6,wip/D548-master,wip/D548-master-2,wip/T10483,wip/T8584,wip/T9840,wip/api-ann-hstylit,wip/api-ann-hstylit-1,wip/api-ann-hstylit-2,wip/api-ann-hstylit-3,wip/api-ann-hstylit-4,wip/api-ann-hstylit-5,wip/api-annot-tweaks-7.10,wip/api-annots-ghc-7.10-3,wip/ast-annotations-separate,wip/ast-prepare-annotations,wip/ast-prepare-annotations-final,wip/ast-prepare-annotations-final2,wip/ast-prepare-annotations-final3,wip/ast-prepare-annotations-final4,wip/ast-prepare-annotations-final5,wip/ast-prepare-annotations-final6,wip/attoparsec-update,wip/landmine-param-family,wip/orf-new,wip/orf-reboot,wip/pattern-synonyms,wip/rae,wip/remove-cabal-dep,wip/trac-9744
Link       : http://git.haskell.org/haddock.git/commitdiff/64aee65f62c7184f31d6778d0d3d9b6dc96e4e91

>---------------------------------------------------------------

commit 64aee65f62c7184f31d6778d0d3d9b6dc96e4e91
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date:   Wed Jun 25 15:02:48 2014 +0200

    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.


>---------------------------------------------------------------

64aee65f62c7184f31d6778d0d3d9b6dc96e4e91
 CHANGES                                                  | 2 ++
 haddock-library/src/Documentation/Haddock/Parser.hs      | 7 ++++++-
 haddock-library/test/Documentation/Haddock/ParserSpec.hs | 9 ++++-----
 html-test/ref/Nesting.html                               | 6 ++----
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/CHANGES b/CHANGES
index 6c13953..ee20ca1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@ Changes in version 2.15.0
 
  * Always read in prologue files as UTF8 (#286 and Cabal #1721)
 
+ * parser: don't wrap headers in DocParagraph (#307)
+
 Changes in version 2.14.3
 
  * Fix parsing of identifiers with ^ or ⋆ in them (#298)
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index f13cedc..1d98601 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 4bcbbec..6d05791 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"
diff --git a/html-test/ref/Nesting.html b/html-test/ref/Nesting.html
index 4abef7b..1a7f275 100644
--- a/html-test/ref/Nesting.html
+++ b/html-test/ref/Nesting.html
@@ -261,10 +261,8 @@ with more of the indented list content.<p
 			  ><dd
 			  >No newline separation even in indented lists.
         We can have any paragraph level element that we normally
-        can, like headers<p
-			    ><h3
-			      >Level 3 header</h3
-			      ></p
+        can, like headers<h3
+			    >Level 3 header</h3
 			    ><p
 			    >with some content…</p
 			    ><ul



More information about the ghc-commits mailing list