diff options
-rw-r--r-- | doc/markup.rst | 13 | ||||
-rw-r--r-- | haddock-library/test/Documentation/Haddock/ParserSpec.hs | 48 |
2 files changed, 51 insertions, 10 deletions
diff --git a/doc/markup.rst b/doc/markup.rst index acabaa28..590bee00 100644 --- a/doc/markup.rst +++ b/doc/markup.rst @@ -845,10 +845,13 @@ Hyperlinked Identifiers ~~~~~~~~~~~~~~~~~~~~~~~ Referring to a Haskell identifier, whether it be a type, class, -constructor, or function, is done by surrounding it with single quotes: :: +constructor, or function, is done by surrounding it with a combination +of single quotes and backticks. For example: :: -- | This module defines the type 'T'. +```T``` is also ok. ``'T``` and ```T'`` are accepted but less common. + If there is an entity ``T`` in scope in the current module, then the documentation will hyperlink the reference in the text to the definition of ``T`` (if the output format supports hyperlinking, of course; in a @@ -876,14 +879,6 @@ apostrophes themselves: to hyperlink ``foo'`` one would simply type ``'foo''``. To hyperlink identifiers written in infix form, simply put them in quotes as always: ``'`elem`'``. -For compatibility with other systems, the following alternative form of -markup is accepted [3]_: ```T'``. - -.. [3] - We chose not to use this as the primary markup for identifiers - because strictly speaking the ````` character should not be used as a - left quote, it is a grave accent. - Emphasis, Bold and Monospaced Text ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/haddock-library/test/Documentation/Haddock/ParserSpec.hs index 86ed3b35..0449c917 100644 --- a/haddock-library/test/Documentation/Haddock/ParserSpec.hs +++ b/haddock-library/test/Documentation/Haddock/ParserSpec.hs @@ -86,6 +86,18 @@ spec = do it "parses identifiers enclosed within backticks" $ do "`foo`" `shouldParseTo` DocIdentifier "foo" + it "parses identifiers preceded by a backtick and followed by a single quote" $ do + "`foo'" `shouldParseTo` DocIdentifier "foo" + + it "parses identifiers preceded by a single quote and followed by a backtick" $ do + "'foo`" `shouldParseTo` DocIdentifier "foo" + + it "can parse a constructor identifier" $ do + "'Foo'" `shouldParseTo` DocIdentifier "Foo" + + it "can parse a qualified identifier" $ do + "'Foo.bar'" `shouldParseTo` DocIdentifier "Foo.bar" + it "parses a word with an one of the delimiters in it as DocString" $ do "don't" `shouldParseTo` "don't" @@ -99,9 +111,43 @@ spec = do it "doesn't parse empty identifiers" $ do "``" `shouldParseTo` "``" - it "can parse infix identifiers" $ do + it "can parse an identifier in infix notation enclosed within backticks" $ do "``infix``" `shouldParseTo` "`" <> DocIdentifier "infix" <> "`" + it "can parse identifiers containing a single quote" $ do + "'don't'" `shouldParseTo` DocIdentifier "don't" + + it "can parse identifiers ending with a single quote" $ do + "'foo''" `shouldParseTo` DocIdentifier "foo'" + + it "can parse an identifier containing a digit" $ do + "'f0'" `shouldParseTo` DocIdentifier "f0" + + it "can parse an identifier containing unicode characters" $ do + "'λ'" `shouldParseTo` DocIdentifier "λ" + + it "can parse a single quote followed by an identifier" $ do + "''foo'" `shouldParseTo` "'" <> DocIdentifier "foo" + + it "can parse an identifier that starts with an underscore" $ do + "'_x'" `shouldParseTo` DocIdentifier "_x" + + context "when parsing operators" $ do + it "can parse an operator enclosed within single quotes" $ do + "'.='" `shouldParseTo` DocIdentifier ".=" + + it "can parse a qualified operator" $ do + "'F..'" `shouldParseTo` DocIdentifier "F.." + + it "can parse a constructor operator" $ do + "':='" `shouldParseTo` DocIdentifier ":=" + + it "can parse a qualified constructor operator" $ do + "'F.:='" `shouldParseTo` DocIdentifier "F.:=" + + it "can parse a unicode operator" $ do + "'∧'" `shouldParseTo` DocIdentifier "∧" + context "when parsing URLs" $ do it "parses a URL" $ do "<http://example.com/>" `shouldParseTo` hyperlink "http://example.com/" Nothing |