Skip to content

Commit a913f47

Browse files
author
Kobayashi
authored
support haddock-library 1.11 (#3303)
* support haddock-library 1.11 * add test case
1 parent 94cd24d commit a913f47

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

ghcide/ghcide.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ library
6262
focus,
6363
ghc-trace-events,
6464
Glob,
65-
haddock-library >= 1.8 && < 1.11,
65+
haddock-library >= 1.8 && < 1.12,
6666
hashable,
6767
hie-compat ^>= 0.3.0.0,
6868
hls-plugin-api ^>= 1.5,

ghcide/src/Development/IDE/Spans/Common.hs

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import GHC.Generics
2323

2424
import GHC
2525

26+
import Data.Bifunctor (second)
2627
import Development.IDE.GHC.Compat
2728
import Development.IDE.GHC.Orphans ()
2829
import Development.IDE.GHC.Util
@@ -179,8 +180,12 @@ haddockToMarkdown (H.DocHeader (H.Header level title))
179180

180181
haddockToMarkdown (H.DocUnorderedList things)
181182
= '\n' : (unlines $ map (("+ " ++) . trimStart . splitForList . haddockToMarkdown) things)
182-
haddockToMarkdown (H.DocOrderedList things)
183-
= '\n' : (unlines $ map (("1. " ++) . trimStart . splitForList . haddockToMarkdown) things)
183+
haddockToMarkdown (H.DocOrderedList things) =
184+
#if MIN_VERSION_haddock_library(1,11,0)
185+
'\n' : (unlines $ map ((\(num, str) -> show num ++ ". " ++ str) . second (trimStart . splitForList . haddockToMarkdown)) things)
186+
#else
187+
'\n' : (unlines $ map (("1. " ++) . trimStart . splitForList . haddockToMarkdown) things)
188+
#endif
184189
haddockToMarkdown (H.DocDefList things)
185190
= '\n' : (unlines $ map (\(term, defn) -> "+ **" ++ haddockToMarkdown term ++ "**: " ++ haddockToMarkdown defn) things)
186191

ghcide/test/exe/Main.hs

+28
Original file line numberDiff line numberDiff line change
@@ -2393,6 +2393,34 @@ haddockTests
23932393
, ""
23942394
]
23952395
)
2396+
, testCase "ordered list" $ checkHaddock
2397+
(unlines
2398+
[ "may require"
2399+
, "different precautions:"
2400+
, ""
2401+
, " 1. Use @{\\-\\# NOINLINE foo \\#-\\}@ as a pragma on any function @foo@"
2402+
, " that calls 'unsafePerformIO'. If the call is inlined,"
2403+
, " the I\\/O may be performed more than once."
2404+
, ""
2405+
, " 2. Use the compiler flag @-fno-cse@ to prevent common sub-expression"
2406+
, " elimination being performed on the module."
2407+
, ""
2408+
]
2409+
)
2410+
(unlines
2411+
[ ""
2412+
, ""
2413+
, "may require"
2414+
, "different precautions: "
2415+
, "1. Use `{-# NOINLINE foo #-}` as a pragma on any function `foo` "
2416+
, " that calls `unsafePerformIO` . If the call is inlined,"
2417+
, " the I/O may be performed more than once."
2418+
, ""
2419+
, "2. Use the compiler flag `-fno-cse` to prevent common sub-expression"
2420+
, " elimination being performed on the module."
2421+
, ""
2422+
]
2423+
)
23962424
]
23972425
where
23982426
checkHaddock s txt = spanDocToMarkdownForTest s @?= txt

0 commit comments

Comments
 (0)