Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
haddock
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ryan Scott
haddock
Commits
ae2900cf
Commit
ae2900cf
authored
10 years ago
by
Simon Hengel
Browse files
Options
Downloads
Patches
Plain Diff
Minor refactoring
parent
09f97fd5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
haddock-library/src/Documentation/Haddock/Parser.hs
+28
-22
28 additions, 22 deletions
haddock-library/src/Documentation/Haddock/Parser.hs
with
28 additions
and
22 deletions
haddock-library/src/Documentation/Haddock/Parser.hs
+
28
−
22
View file @
ae2900cf
...
...
@@ -210,9 +210,16 @@ picture = DocPic . makeLabeled Picture . decodeUtf8
-- | Paragraph parser, called by 'parseParas'.
paragraph
::
Parser
(
DocH
mod
Identifier
)
paragraph
=
examples
<|>
skipSpace
*>
(
list
<|>
birdtracks
<|>
codeblock
<|>
property
<|>
header
<|>
textParagraph
)
paragraph
=
examples
<|>
skipSpace
*>
(
unorderedList
<|>
orderedList
<|>
definitionList
<|>
birdtracks
<|>
codeblock
<|>
property
<|>
header
<|>
textParagraph
)
-- | Headers inside the comment denoted with @=@ signs, up to 6 levels
-- deep.
...
...
@@ -233,20 +240,17 @@ header = do
textParagraph
::
Parser
(
DocH
mod
Identifier
)
textParagraph
=
docParagraph
.
parseString
.
intercalate
"
\n
"
<$>
many1
nonEmptyLine
-- | List parser, called by 'paragraph'.
list
::
Parser
(
DocH
mod
Identifier
)
list
=
DocUnorderedList
<$>
unorderedList
<|>
DocOrderedList
<$>
orderedList
<|>
DocDefList
<$>
definitionList
-- | Parses unordered (bullet) lists.
unorderedList
::
Parser
[
DocH
mod
Identifier
]
unorderedList
=
(
"*"
<|>
"-"
)
*>
innerList
unorderedList
unorderedList
::
Parser
(
DocH
mod
Identifier
)
unorderedList
=
DocUnorderedList
<$>
p
where
p
=
(
"*"
<|>
"-"
)
*>
innerList
p
-- | Parses ordered lists (numbered or dashed).
orderedList
::
Parser
[
DocH
mod
Identifier
]
orderedList
=
(
paren
<|>
dot
)
*>
innerList
o
rderedList
orderedList
::
Parser
(
DocH
mod
Identifier
)
orderedList
=
DocO
rderedList
<$>
p
where
p
=
(
paren
<|>
dot
)
*>
innerList
p
dot
=
(
decimal
::
Parser
Int
)
<*
"."
paren
=
"("
*>
decimal
<*
")"
...
...
@@ -265,15 +269,17 @@ innerList item = do
Right
i
->
contents
:
i
-- | Parses definition lists.
definitionList
::
Parser
[(
DocH
mod
Identifier
,
DocH
mod
Identifier
)]
definitionList
=
do
label
<-
"["
*>
(
parseStringBS
<$>
takeWhile1
(`
notElem
`
"]
\n
"
))
<*
"]"
c
<-
takeLine
(
cs
,
items
)
<-
more
definitionList
let
contents
=
parseString
.
dropNLs
.
unlines
$
c
:
cs
return
$
case
items
of
Left
p
->
[(
label
,
contents
`
docAppend
`
p
)]
Right
i
->
(
label
,
contents
)
:
i
definitionList
::
Parser
(
DocH
mod
Identifier
)
definitionList
=
DocDefList
<$>
p
where
p
=
do
label
<-
"["
*>
(
parseStringBS
<$>
takeWhile1
(`
notElem
`
"]
\n
"
))
<*
"]"
c
<-
takeLine
(
cs
,
items
)
<-
more
p
let
contents
=
parseString
.
dropNLs
.
unlines
$
c
:
cs
return
$
case
items
of
Left
x
->
[(
label
,
contents
`
docAppend
`
x
)]
Right
i
->
(
label
,
contents
)
:
i
-- | Drops all trailing newlines.
dropNLs
::
String
->
String
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment