diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2018-07-06 10:06:32 -0400 |
---|---|---|
committer | Simon Jakobi <simon.jakobi@gmail.com> | 2018-07-20 13:39:29 +0200 |
commit | 97829713e19399970c80b80c8bd05f437e5fe842 (patch) | |
tree | be45c0f4e1d475e485bd046c59b705c249d6e765 | |
parent | 7e92026477248c077c0f47a1d5995513fa76e2b4 (diff) |
Avoid line breaks due to line length in Hoogle (#868)
* Avoid line breaks due to line length in Hoogle
Hoogle operates in a line-oriented fashion, so we should avoid ever
breaking due to long lines.
One way of doing this non-intrusively is to modify the 'DynFlags' that
are threaded through the 'Hoogle' module (note this is anyways only
passed through for use in the various 'showSDoc' functions).
* Amend test case
(cherry picked from commit 657b1b3d519545f8d4ca048c06210d6cbf0f0da0)
-rw-r--r-- | haddock-api/src/Haddock/Backends/Hoogle.hs | 8 | ||||
-rw-r--r-- | hoogle-test/ref/Bug806/test.txt | 1 | ||||
-rw-r--r-- | hoogle-test/src/Bug806/Bug806.hs | 1 |
3 files changed, 7 insertions, 3 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs index e23e8cc6..885c608b 100644 --- a/haddock-api/src/Haddock/Backends/Hoogle.hs +++ b/haddock-api/src/Haddock/Backends/Hoogle.hs @@ -46,13 +46,15 @@ prefix = ["-- Hoogle documentation, generated by Haddock" ppHoogle :: DynFlags -> String -> Version -> String -> Maybe (Doc RdrName) -> [Interface] -> FilePath -> IO () ppHoogle dflags package version synopsis prologue ifaces odir = do - let filename = package ++ ".txt" + let -- Since Hoogle is line based, we want to avoid breaking long lines. + dflags' = dflags{ pprCols = maxBound } + filename = package ++ ".txt" contents = prefix ++ - docWith dflags (drop 2 $ dropWhile (/= ':') synopsis) prologue ++ + docWith dflags' (drop 2 $ dropWhile (/= ':') synopsis) prologue ++ ["@package " ++ package] ++ ["@version " ++ showVersion version | not (null (versionBranch version)) ] ++ - concat [ppModule dflags i | i <- ifaces, OptHide `notElem` ifaceOptions i] + concat [ppModule dflags' i | i <- ifaces, OptHide `notElem` ifaceOptions i] createDirectoryIfMissing True odir h <- openFile (odir </> filename) WriteMode hSetEncoding h utf8 diff --git a/hoogle-test/ref/Bug806/test.txt b/hoogle-test/ref/Bug806/test.txt index d9a908b3..67e9fd61 100644 --- a/hoogle-test/ref/Bug806/test.txt +++ b/hoogle-test/ref/Bug806/test.txt @@ -21,4 +21,5 @@ class C a where { -- | <a>AT</a> docs type family AT a; + type AT a = Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy))))))))); } diff --git a/hoogle-test/src/Bug806/Bug806.hs b/hoogle-test/src/Bug806/Bug806.hs index 6efcb5cf..45efda77 100644 --- a/hoogle-test/src/Bug806/Bug806.hs +++ b/hoogle-test/src/Bug806/Bug806.hs @@ -21,3 +21,4 @@ v = 42 class C a where -- | 'AT' docs type AT a + type AT a = Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy (Proxy))))))))) |