[commit: haddock] ghc-7.8: Turn a source code comment into specs (240fb79)
git at git.haskell.org
git at git.haskell.org
Mon Feb 24 21:36:25 UTC 2014
Repository : ssh://git@git.haskell.org/haddock
On branch : ghc-7.8
Link : http://git.haskell.org/haddock.git/commitdiff/240fb794e36104b2c1412e36f63b7378f34d52ba
>---------------------------------------------------------------
commit 240fb794e36104b2c1412e36f63b7378f34d52ba
Author: Simon Hengel <sol at typeful.net>
Date: Sat Feb 22 21:55:35 2014 +0100
Turn a source code comment into specs
(cherry picked from commit dfc006ad2b8f5cb27570ac02c77aa63c5c027cd9)
>---------------------------------------------------------------
240fb794e36104b2c1412e36f63b7378f34d52ba
src/Haddock/Parser.hs | 2 --
test/Haddock/ParserSpec.hs | 17 ++++++++++-------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs
index a6ad817..095f385 100644
--- a/src/Haddock/Parser.hs
+++ b/src/Haddock/Parser.hs
@@ -306,8 +306,6 @@ birdtracks = DocCodeBlock . DocString . intercalate "\n" . stripSpace <$> many1
where
line = skipHorizontalSpace *> ">" *> takeLine
--- | Strip leading spaces, but ignore blank lines. If any of the lines don't
--- start with a ' ', however, we don't touch the block.
stripSpace :: [String] -> [String]
stripSpace = fromMaybe <*> mapM strip
where
diff --git a/test/Haddock/ParserSpec.hs b/test/Haddock/ParserSpec.hs
index ac57b64..db843cc 100644
--- a/test/Haddock/ParserSpec.hs
+++ b/test/Haddock/ParserSpec.hs
@@ -360,23 +360,26 @@ spec = before initStaticOpts $ do
]
`shouldParseTo` DocCodeBlock "foo\nbar\nbaz"
- it "ignores single leading spaces" $ do
+ it "strips one leading space from each line of the block" $ do
unlines [
"> foo"
- , "> bar"
+ , "> bar"
, "> baz"
- ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz"
+ ] `shouldParseTo` DocCodeBlock "foo\n bar\nbaz"
+ it "ignores empty lines when stripping spaces" $ do
unlines [
"> foo"
, ">"
, "> bar"
] `shouldParseTo` DocCodeBlock "foo\n\nbar"
- unlines [
- ">foo"
- , "> bar"
- ] `shouldParseTo` DocCodeBlock "foo\n bar"
+ context "when any non-empty line does not start with a space" $ do
+ it "does not strip any spaces" $ do
+ unlines [
+ ">foo"
+ , "> bar"
+ ] `shouldParseTo` DocCodeBlock "foo\n bar"
it "ignores nested markup" $ do
unlines [
More information about the ghc-commits
mailing list