packageDoc for sandbox.
This commit is contained in:
parent
5f6adb53f2
commit
2dd7bab9b2
@ -23,6 +23,7 @@ module Language.Haskell.GhcMod (
|
|||||||
, listFlags
|
, listFlags
|
||||||
, debugInfo
|
, debugInfo
|
||||||
, rootInfo
|
, rootInfo
|
||||||
|
, packageDoc
|
||||||
-- * Converting the 'Ghc' monad to the 'IO' monad
|
-- * Converting the 'Ghc' monad to the 'IO' monad
|
||||||
, withGHC
|
, withGHC
|
||||||
, withGHCDummyFile
|
, withGHCDummyFile
|
||||||
@ -46,4 +47,5 @@ import Language.Haskell.GhcMod.Info
|
|||||||
import Language.Haskell.GhcMod.Lang
|
import Language.Haskell.GhcMod.Lang
|
||||||
import Language.Haskell.GhcMod.Lint
|
import Language.Haskell.GhcMod.Lint
|
||||||
import Language.Haskell.GhcMod.List
|
import Language.Haskell.GhcMod.List
|
||||||
|
import Language.Haskell.GhcMod.PkgDoc
|
||||||
import Language.Haskell.GhcMod.Types
|
import Language.Haskell.GhcMod.Types
|
||||||
|
23
Language/Haskell/GhcMod/PkgDoc.hs
Normal file
23
Language/Haskell/GhcMod/PkgDoc.hs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
module Language.Haskell.GhcMod.PkgDoc (packageDoc) where
|
||||||
|
|
||||||
|
import Control.Applicative ((<$>))
|
||||||
|
import Language.Haskell.GhcMod.Types
|
||||||
|
import System.Process (readProcess)
|
||||||
|
|
||||||
|
-- | Obtaining the package name and the doc path of a module.
|
||||||
|
packageDoc :: Options
|
||||||
|
-> Cradle
|
||||||
|
-> ModuleString
|
||||||
|
-> IO String
|
||||||
|
packageDoc _ cradle mdl = pkgDoc cradle mdl
|
||||||
|
|
||||||
|
pkgDoc :: Cradle -> String -> IO String
|
||||||
|
pkgDoc cradle mdl = do
|
||||||
|
pkg <- trim <$> readProcess "ghc-pkg" toModuleOpts []
|
||||||
|
htmlpath <- readProcess "ghc-pkg" ["field", pkg, "haddock-html"] []
|
||||||
|
let ret = pkg ++ " " ++ drop 14 htmlpath
|
||||||
|
return ret
|
||||||
|
where
|
||||||
|
toModuleOpts = ["find-module", "--simple-output"] ++ cradlePackageDbOpts cradle ++ [mdl]
|
||||||
|
trim = fst . break (== '\n')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user