[commit: haddock] T6018-injective-type-families, adamse-D1033, ghc-head, master, metainfo, 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/T9840, wip/api-annot-tweaks-7.10, wip/api-annots-ghc-7.10-3, wip/orf-reboot: Fix parsing of identifiers written in infix way (0891c56)
git at git.haskell.org
git at git.haskell.org
Wed Jul 8 08:32:44 UTC 2015
- Previous message: [commit: haddock] T6018-injective-type-families, adamse-D1033, ghc-head, master, metainfo, 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/T9840, wip/api-annot-tweaks-7.10, wip/api-annots-ghc-7.10-3, wip/orf-reboot: Fix warnings (fc46251)
- Next message: [commit: haddock] T6018-injective-type-families, adamse-D1033, ghc-head, master, metainfo, 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/T9840, wip/api-annot-tweaks-7.10, wip/api-annots-ghc-7.10-3, wip/orf-reboot: Minor code simplification (86ee241)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Repository : ssh://git@git.haskell.org/haddock
On branches: T6018-injective-type-families,adamse-D1033,ghc-head,master,metainfo,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/T9840,wip/api-annot-tweaks-7.10,wip/api-annots-ghc-7.10-3,wip/orf-reboot
Link : http://git.haskell.org/haddock.git/commitdiff/0891c568f645edcac35442576757ab6fcaa7b6ec
>---------------------------------------------------------------
commit 0891c568f645edcac35442576757ab6fcaa7b6ec
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date: Tue Nov 4 21:04:07 2014 +0000
Fix parsing of identifiers written in infix way
>---------------------------------------------------------------
0891c568f645edcac35442576757ab6fcaa7b6ec
CHANGES | 2 ++
doc/haddock.xml | 4 +++-
.../src/Documentation/Haddock/Parser.hs | 23 +++++++++++-----------
.../test/Documentation/Haddock/ParserSpec.hs | 6 ++++++
4 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/CHANGES b/CHANGES
index 3a08424..79a7e65 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,8 @@ Changes in version 2.15.1
* Fix re-exports of built-in type families (#310)
+ * Fix parsing of infix identifiers such as ``elem``.
+
Changes in version 2.15.0
* Always read in prologue files as UTF8 (#286 and Cabal #1721)
diff --git a/doc/haddock.xml b/doc/haddock.xml
index 618e19f..3b58f82 100644
--- a/doc/haddock.xml
+++ b/doc/haddock.xml
@@ -1897,7 +1897,9 @@ module A where
<para>Nothing special is needed to hyperlink identifiers which
contain apostrophes themselves: to hyperlink
<literal>foo'</literal> one would simply type
- <literal>'foo''</literal>.</para>
+ <literal>'foo''</literal>. To hyperlink identifiers written in
+ infix form, simply put them in quotes as always:
+ <literal>'`elem`'</literal>.</para>
<para>For compatibility with other systems, the following
alternative form of markup is accepted<footnote><para>
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index 9901089..bea1803 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -507,25 +507,26 @@ autoUrl = mkLink <$> url
-- deems to be valid in an identifier. Note that it simply blindly consumes
-- characters and does no actual validation itself.
parseValid :: Parser String
-parseValid = do
- vs' <- many' $ utf8String "⋆" <|> return <$> idChar
- let vs = concat vs'
- c <- peekChar
- case c of
- Just '`' -> return vs
- Just '\'' -> (\x -> vs ++ "'" ++ x) <$> ("'" *> parseValid)
- <|> return vs
- _ -> fail "outofvalid"
+parseValid = p some
where
idChar = satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:^")
<|> digit <|> letter_ascii
+ p p' = do
+ vs' <- p' $ utf8String "⋆" <|> return <$> idChar
+ let vs = concat vs'
+ c <- peekChar
+ case c of
+ Just '`' -> return vs
+ Just '\'' -> (\x -> vs ++ "'" ++ x) <$> ("'" *> p many')
+ <|> return vs
+ _ -> fail "outofvalid"
-- | Parses UTF8 strings from ByteString streams.
utf8String :: String -> Parser String
utf8String x = decodeUtf8 <$> string (encodeUtf8 x)
--- | Parses identifiers with help of 'parseValid'. Asks GHC for 'String' from the
--- string it deems valid.
+-- | Parses identifiers with help of 'parseValid'. Asks GHC for
+-- 'String' from the string it deems valid.
identifier :: Parser (DocH mod Identifier)
identifier = do
o <- idDelim
diff --git a/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
index a228a95..5550e83 100644
--- a/haddock-library/test/Documentation/Haddock/ParserSpec.hs
+++ b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
@@ -85,6 +85,12 @@ spec = do
" don't use apostrophe's in the wrong place's" `shouldParseTo`
"don't use apostrophe's in the wrong place's"
+ it "doesn't parse empty identifiers" $ do
+ "``" `shouldParseTo` "``"
+
+ it "can parse infix identifiers" $ do
+ "``infix``" `shouldParseTo` "`" <> DocIdentifier "infix" <> "`"
+
context "when parsing URLs" $ do
it "parses a URL" $ do
"<http://example.com/>" `shouldParseTo` hyperlink "http://example.com/" Nothing
- Previous message: [commit: haddock] T6018-injective-type-families, adamse-D1033, ghc-head, master, metainfo, 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/T9840, wip/api-annot-tweaks-7.10, wip/api-annots-ghc-7.10-3, wip/orf-reboot: Fix warnings (fc46251)
- Next message: [commit: haddock] T6018-injective-type-families, adamse-D1033, ghc-head, master, metainfo, 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/T9840, wip/api-annot-tweaks-7.10, wip/api-annots-ghc-7.10-3, wip/orf-reboot: Minor code simplification (86ee241)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the ghc-commits
mailing list