From 41fbe99fb430b4de1ec7aac30a67e8023821f449 Mon Sep 17 00:00:00 2001 From: David Waern Date: Sat, 15 Nov 2008 22:59:33 +0000 Subject: Store hidden modules in .haddock files We store documentation for an entity in the 'InstalledInterface' of the definition site module, and never in the same structure for a module which re-exports the entity. So when a client of the Haddock library wants to look up some documentation, he/she might need to access a hidden module. But we currently don't store hidden modules in the .haddock files. So we add the hidden modules and the Haddock options to the .haddock files. The options will be used to filter the module list to obtain the visible modules only, which is necessary for generating the contents and index for installed packages. --- src/Haddock/InterfaceFile.hs | 12 +++++++----- src/Haddock/Types.hs | 6 ++++-- src/Main.hs | 25 ++++++++++++------------- 3 files changed, 23 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Haddock/InterfaceFile.hs b/src/Haddock/InterfaceFile.hs index 62f19275..e04e5b3e 100644 --- a/src/Haddock/InterfaceFile.hs +++ b/src/Haddock/InterfaceFile.hs @@ -60,13 +60,13 @@ binaryInterfaceMagic = 0xD0Cface -- when one of our own (stored) datatypes is changed. binaryInterfaceVersion :: Word16 #if __GLASGOW_HASKELL__ == 608 && __GHC_PATCHLEVEL__ == 2 -binaryInterfaceVersion = 2 +binaryInterfaceVersion = 5 #endif #if __GLASGOW_HASKELL__ == 608 && __GHC_PATCHLEVEL__ == 3 -binaryInterfaceVersion = 3 +binaryInterfaceVersion = 6 #endif #if __GLASGOW_HASKELL__ >= 609 -binaryInterfaceVersion = 4 +binaryInterfaceVersion = 7 #endif @@ -353,12 +353,13 @@ instance Binary InterfaceFile where instance Binary InstalledInterface where - put_ bh (InstalledInterface modu info docMap exps visExps) = do + put_ bh (InstalledInterface modu info docMap exps visExps opts) = do put_ bh modu put_ bh info put_ bh (Map.toList docMap) put_ bh exps put_ bh visExps + put_ bh opts get bh = do modu <- get bh @@ -366,7 +367,8 @@ instance Binary InstalledInterface where docMap <- get bh exps <- get bh visExps <- get bh - return (InstalledInterface modu info (Map.fromList docMap) exps visExps) + opts <- get bh + return (InstalledInterface modu info (Map.fromList docMap) exps visExps opts) instance Binary DocOption where diff --git a/src/Haddock/Types.hs b/src/Haddock/Types.hs index 88b6f87a..44cc9161 100644 --- a/src/Haddock/Types.hs +++ b/src/Haddock/Types.hs @@ -167,7 +167,8 @@ data InstalledInterface = InstalledInterface { instInfo :: HaddockModInfo Name, instDocMap :: Map Name (HsDoc DocName), instExports :: [Name], - instVisibleExports :: [Name] + instVisibleExports :: [Name], + instOptions :: [DocOption] } @@ -178,7 +179,8 @@ toInstalledIface interface = InstalledInterface { instInfo = ifaceInfo interface, instDocMap = ifaceRnDocMap interface, instExports = ifaceExports interface, - instVisibleExports = ifaceVisibleExports interface + instVisibleExports = ifaceVisibleExports interface, + instOptions = ifaceOptions interface } diff --git a/src/Main.hs b/src/Main.hs index 902faed6..8f3895bd 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -172,14 +172,12 @@ main = handleTopExceptions $ do -- create the interfaces -- this is the core part of Haddock (interfaces, homeLinks) <- createInterfaces fileArgs extLinks flags - let visibleIfaces = [ i | i <- interfaces, OptHide `notElem` ifaceOptions i ] - liftIO $ do -- render the interfaces - renderStep packages visibleIfaces + renderStep packages interfaces -- last but not least, dump the interface file - dumpInterfaceFile (map toInstalledIface visibleIfaces) homeLinks flags + dumpInterfaceFile (map toInstalledIface interfaces) homeLinks flags #else -- initialize GHC (session, dynflags) <- startGhc libDir (ghcFlags flags) @@ -193,13 +191,11 @@ main = handleTopExceptions $ do -- create the interfaces -- this is the core part of Haddock (interfaces, homeLinks) <- createInterfaces session fileArgs extLinks flags - let visibleIfaces = [ i | i <- interfaces, OptHide `notElem` ifaceOptions i ] - -- render the interfaces - renderStep packages visibleIfaces + renderStep packages interfaces -- last but not least, dump the interface file - dumpInterfaceFile (map toInstalledIface visibleIfaces) homeLinks flags + dumpInterfaceFile (map toInstalledIface interfaces) homeLinks flags #endif else do -- get packages supplied with --read-interface @@ -216,7 +212,7 @@ main = handleTopExceptions $ do -- | Render the interfaces with whatever backend is specified in the flags render :: [Flag] -> [Interface] -> [InstalledInterface] -> IO () -render flags visibleIfaces installedIfaces = do +render flags ifaces installedIfaces = do let title = case [str | Flag_Heading str <- flags] of [] -> "" @@ -271,11 +267,13 @@ render flags visibleIfaces installedIfaces = do prologue <- getPrologue flags let + visibleIfaces = [ i | i <- ifaces, OptHide `notElem` ifaceOptions i ] + -- *all* visible interfaces including external package modules - allVisibleIfaces = map toInstalledIface visibleIfaces - ++ installedIfaces - - packageMod = ifaceMod (head visibleIfaces) + allIfaces = map toInstalledIface ifaces ++ installedIfaces + allVisibleIfaces = [ i | i <- allIfaces, OptHide `notElem` instOptions i ] + + packageMod = ifaceMod (head ifaces) packageStr = Just (modulePackageString packageMod) (pkgName,pkgVer) = modulePackageInfo packageMod @@ -305,6 +303,7 @@ render flags visibleIfaces installedIfaces = do when (Flag_Hoogle `elem` flags) $ do ppHoogle pkgName pkgVer title prologue visibleIfaces odir + ------------------------------------------------------------------------------- -- Reading and dumping interface files ------------------------------------------------------------------------------- -- cgit v1.2.3