aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Backends/Hoogle.hs
diff options
context:
space:
mode:
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Hoogle.hs')
-rw-r--r--haddock-api/src/Haddock/Backends/Hoogle.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs
index 257a8d6d..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
@@ -89,7 +91,7 @@ dropHsDocTy = f
outHsType :: (a ~ GhcPass p, OutputableBndrId a)
=> DynFlags -> HsType a -> String
-outHsType dflags = out dflags . dropHsDocTy
+outHsType dflags = out dflags . reparenType . dropHsDocTy
dropComment :: String -> String
@@ -123,7 +125,7 @@ ppExport dflags ExportDecl { expItemDecl = L _ decl
, expItemMbDoc = (dc, _)
, expItemSubDocs = subdocs
, expItemFixities = fixities
- } = ppDocumentation dflags dc ++ f decl
+ } = ppDocumentation dflags dc ++ f decl ++ ppFixities
where
f (TyClD _ d@DataDecl{}) = ppData dflags d subdocs
f (TyClD _ d@SynDecl{}) = ppSynonym dflags d
@@ -131,7 +133,7 @@ ppExport dflags ExportDecl { expItemDecl = L _ decl
f (TyClD _ (FamDecl _ d)) = ppFam dflags d
f (ForD _ (ForeignImport _ name typ _)) = [pp_sig dflags [name] (hsSigType typ)]
f (ForD _ (ForeignExport _ name typ _)) = [pp_sig dflags [name] (hsSigType typ)]
- f (SigD _ sig) = ppSig dflags sig ++ ppFixities
+ f (SigD _ sig) = ppSig dflags sig
f _ = []
ppFixities = concatMap (ppFixity dflags) fixities