hdocs 0.4.3.0 → 0.4.4.0
raw patch · 2 files changed
+17/−4 lines, 2 filesdep +CabalPVP ok
version bump matches the API change (PVP)
Dependencies added: Cabal
API changes (from Hackage documentation)
+ HDocs.Haddock: data Ghc a :: * -> *
+ HDocs.Haddock: readSourcesGhc :: [String] -> [FilePath] -> ExceptT String Ghc [(String, ModuleDocMap)]
Files
- hdocs.cabal +2/−1
- src/HDocs/Haddock.hs +15/−3
hdocs.cabal view
@@ -1,5 +1,5 @@ name: hdocs -version: 0.4.3.0 +version: 0.4.4.0 synopsis: Haskell docs tool description: Tool and library to get docs for installed packages and source files. @@ -35,6 +35,7 @@ base >= 4.7 && < 5, aeson >= 0.7.0, bytestring >= 0.10.0, + Cabal >= 1.22.2, filepath >= 1.3.0, ghc >= 7.8.1, ghc-paths >= 0.1.0,
src/HDocs/Haddock.hs view
@@ -2,7 +2,7 @@ -- * Documentation functions readInstalledDocs, readHaddock, - readSources, readSources_, readSource, + readSources, readSources_, readSource, readSourcesGhc, -- * Extract docs installedInterfaceDocs, installedInterfacesDocs, @@ -13,7 +13,10 @@ readInstalledInterfaces, readPackageInterfaces, lookupDoc, lookupNameDoc, - module HDocs.Base + module HDocs.Base, + + Ghc, + module Control.Monad.Except ) where import Control.Applicative @@ -24,9 +27,12 @@ import qualified Data.Map as M import Data.Maybe (listToMaybe) +import Distribution.Verbosity (silent) import Documentation.Haddock import Documentation.Haddock.Types (_doc) +import Exception (gtry) +import GHC (Ghc) import DynFlags import Module import Name @@ -51,12 +57,18 @@ -- | Read docs for haskell modules readSources_ :: [String] -> [FilePath] -> ExceptT String IO [(String, ModuleDocMap)] readSources_ opts fs = do - ifaces <- liftError $ liftIO $ createInterfaces ([Flag_Verbosity "0", Flag_NoWarnings] ++ map Flag_OptGhc opts) fs + ifaces <- liftError $ liftIO $ createInterfaces ([Flag_Verbosity "0", Flag_NoWarnings, Flag_UseUnicode] ++ map Flag_OptGhc opts) fs return $ map interfaceDocs ifaces -- | Read docs for haskell module readSource :: [String] -> FilePath -> ExceptT String IO (String, ModuleDocMap) readSource opts f = liftM listToMaybe (readSources_ opts [f]) >>= maybe (throwError $ "Failed to load docs for " ++ f) return + +-- | Read docs for source in Ghc monad +readSourcesGhc :: [String] -> [FilePath] -> ExceptT String Ghc [(String, ModuleDocMap)] +readSourcesGhc opts fs = ExceptT $ liftM (left (show :: SomeException -> String)) $ gtry $ do + ifaces <- liftM fst $ processModules silent fs ([Flag_Verbosity "0", Flag_NoWarnings, Flag_UseUnicode] ++ map Flag_OptGhc opts) [] + return $ map interfaceDocs ifaces -- | Get docs for 'InstalledInterface' installedInterfaceDocs :: InstalledInterface -> (String, ModuleDocMap)