Haddock reader: add tests.
This commit is contained in:
parent
67b38fac64
commit
2c9ea89ff7
2 changed files with 95 additions and 1 deletions
|
@ -0,0 +1,65 @@
|
|||
This file tests the Pandoc reader for Haddock.
|
||||
We've borrowed examples from Haddock's documentation: <http://www.haskell.org/haddock/doc/html/ch03s08.html>.
|
||||
|
||||
The following characters have special meanings in Haddock, \/, \', \`, \", \@, \<, so they must be escaped.
|
||||
|
||||
\* This is a paragraph, not a list item.
|
||||
\> This sentence is not code.
|
||||
\>\>\> This is not an example.
|
||||
|
||||
The references λ, λ and λ all represent the lower-case letter lambda.
|
||||
|
||||
This is a code block:
|
||||
|
||||
> map :: (a -> b) -> [a] -> [b]
|
||||
> map _ [] = []
|
||||
> map f (x:xs) = f x : map f xs
|
||||
|
||||
This is another code block:
|
||||
|
||||
@
|
||||
f x = x + x.
|
||||
The \@...\@ code block /interprets markup normally/.
|
||||
"Module.Foo"
|
||||
\"Hello World\"
|
||||
@
|
||||
|
||||
Haddock supports REPL examples:
|
||||
|
||||
>>> fib 10
|
||||
55
|
||||
>>> putStrLn "foo\nbar"
|
||||
foo
|
||||
bar
|
||||
|
||||
That was /really cool/!
|
||||
I had no idea @fib 10 = 55@.
|
||||
|
||||
This module defines the type 'T'.
|
||||
The identifier 'M.T' is not in scope
|
||||
I don't have to escape my apostrophes; great, isn't it?
|
||||
This is a reference to the "Foo" module.
|
||||
|
||||
This is a bulleted list:
|
||||
|
||||
* first item
|
||||
|
||||
* second item
|
||||
|
||||
This is an enumerated list:
|
||||
|
||||
(1) first item
|
||||
|
||||
2. second item
|
||||
|
||||
This is a definition list:
|
||||
|
||||
[@foo@] The description of @foo@.
|
||||
|
||||
[@bar@] The description of @bar@.
|
||||
|
||||
Here is a link: <http://haskell.org>
|
||||
|
||||
<http://haskell.org Haskell> is a fun language!
|
||||
|
||||
<http://example.com Click Here!>
|
|
@ -1,2 +1,31 @@
|
|||
Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
|
||||
[]
|
||||
[Para [Str "This",Space,Str "file",Space,Str "tests",Space,Str "the",Space,Str "Pandoc",Space,Str "reader",Space,Str "for",Space,Str "Haddock.",Space,Str "We've",Space,Str "borrowed",Space,Str "examples",Space,Str "from",Space,Str "Haddock's",Space,Str "documentation:",Space,Link [Str "http://www.haskell.org/haddock/doc/html/ch03s08.html"] ("http://www.haskell.org/haddock/doc/html/ch03s08.html","http://www.haskell.org/haddock/doc/html/ch03s08.html"),Str "."]
|
||||
,Para [Str "The",Space,Str "following",Space,Str "characters",Space,Str "have",Space,Str "special",Space,Str "meanings",Space,Str "in",Space,Str "Haddock,",Space,Str "/,",Space,Str "',",Space,Str "`,",Space,Str "\",",Space,Str "@,",Space,Str "<,",Space,Str "so",Space,Str "they",Space,Str "must",Space,Str "be",Space,Str "escaped."]
|
||||
,Para [Str "*",Space,Str "This",Space,Str "is",Space,Str "a",Space,Str "paragraph,",Space,Str "not",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str ">",Space,Str "This",Space,Str "sentence",Space,Str "is",Space,Str "not",Space,Str "code.",Space,Str ">>>",Space,Str "This",Space,Str "is",Space,Str "not",Space,Str "an",Space,Str "example."]
|
||||
,Para [Str "The",Space,Str "references",Space,Str "\955,",Space,Str "\955",Space,Str "and",Space,Str "\955",Space,Str "all",Space,Str "represent",Space,Str "the",Space,Str "lower-case",Space,Str "letter",Space,Str "lambda."]
|
||||
,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "code",Space,Str "block:"]
|
||||
,CodeBlock ("",["haskell"],[]) " map :: (a -> b) -> [a] -> [b]\n map _ [] = []\n map f (x:xs) = f x : map f xs\n"
|
||||
,Para [Str "This",Space,Str "is",Space,Str "another",Space,Str "code",Space,Str "block:"]
|
||||
,Para [Space,Code ("",[],[]) "f",Space,Code ("",[],[]) "x",Space,Code ("",[],[]) "=",Space,Code ("",[],[]) "x",Space,Code ("",[],[]) "+",Space,Code ("",[],[]) "x.",Space,Code ("",[],[]) "The",Space,Code ("",[],[]) "@...@",Space,Code ("",[],[]) "code",Space,Code ("",[],[]) "block",Space,Emph [Code ("",[],[]) "interprets markup normally"],Code ("",[],[]) ".",Space,Code ("",["haskell"],[]) "Module.Foo",Space,Code ("",[],[]) "\"Hello",Space,Code ("",[],[]) "World\""]
|
||||
,Para [Str "Haddock",Space,Str "supports",Space,Str "REPL",Space,Str "examples:"]
|
||||
,Para [Code ("",["haskell","expr"],[]) "fib 10\n",Code ("",["result"],[]) "55\n"]
|
||||
,Para [Code ("",["haskell","expr"],[]) "putStrLn \"foo\\nbar\"\n",Code ("",["result"],[]) "foo\nbar \n"]
|
||||
,Para [Str "That",Space,Str "was",Space,Emph [Str "really cool"],Str "!",Space,Str "I",Space,Str "had",Space,Str "no",Space,Str "idea",Space,Code ("",[],[]) "fib",Space,Code ("",[],[]) "10",Space,Code ("",[],[]) "=",Space,Code ("",[],[]) "55",Str "."]
|
||||
,Para [Str "This",Space,Str "module",Space,Str "defines",Space,Str "the",Space,Str "type",Space,Code ("",["haskell"],[]) "T",Str ".",Space,Str "The",Space,Str "identifier",Space,Code ("",["haskell"],[]) "M.T",Space,Str "is",Space,Str "not",Space,Str "in",Space,Str "scope",Space,Str "I",Space,Str "don't",Space,Str "have",Space,Str "to",Space,Str "escape",Space,Str "my",Space,Str "apostrophes;",Space,Str "great,",Space,Str "isn't",Space,Str "it?",Space,Str "This",Space,Str "is",Space,Str "a",Space,Str "reference",Space,Str "to",Space,Str "the",Space,Code ("",["haskell"],[]) "Foo",Space,Str "module."]
|
||||
,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "bulleted",Space,Str "list:"]
|
||||
,BulletList
|
||||
[[Para [Space,Str "first",Space,Str "item"]]
|
||||
,[Para [Space,Str "second",Space,Str "item"]]]
|
||||
,Para [Str "This",Space,Str "is",Space,Str "an",Space,Str "enumerated",Space,Str "list:"]
|
||||
,OrderedList (1,DefaultStyle,DefaultDelim)
|
||||
[[Para [Space,Str "first",Space,Str "item"]]
|
||||
,[Para [Space,Str "second",Space,Str "item"]]]
|
||||
,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "definition",Space,Str "list:"]
|
||||
,DefinitionList
|
||||
[([Code ("",[],[]) "foo"],
|
||||
[[Plain [Space,Str "The",Space,Str "description",Space,Str "of",Space,Code ("",[],[]) "foo",Str ".",Space]]])
|
||||
,([Code ("",[],[]) "bar"],
|
||||
[[Plain [Space,Str "The",Space,Str "description",Space,Str "of",Space,Code ("",[],[]) "bar",Str ".",Space]]])]
|
||||
,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "link:",Space,Link [Str "http://haskell.org"] ("http://haskell.org","http://haskell.org")]
|
||||
,Para [Link [Str "Haskell"] ("http://haskell.org","http://haskell.org"),Space,Str "is",Space,Str "a",Space,Str "fun",Space,Str "language!"]
|
||||
,Para [Link [Str "Click Here!"] ("http://example.com","http://example.com")]]
|
||||
|
|
Loading…
Reference in a new issue