1 -----------------------------------------------------------------------------
3 -----------------------------------------------------------------------------
6 -- Module : Distribution.Client.Haddock
7 -- Copyright : (c) Andrea Vezzosi 2009
10 -- Maintainer : cabal-devel@haskell.org
11 -- Portability : portable
13 -- Interfacing with Haddock
14 module Distribution
.Client
.Haddock
15 ( regenerateHaddockIndex
19 import Distribution
.Client
.Compat
.Prelude
22 import Data
.List
(maximumBy)
23 import Distribution
.InstalledPackageInfo
as InstalledPackageInfo
24 ( InstalledPackageInfo
(exposed
)
26 import Distribution
.Package
29 import Distribution
.Simple
.Haddock
(haddockPackagePaths
)
30 import Distribution
.Simple
.PackageIndex
31 ( InstalledPackageIndex
34 import Distribution
.Simple
.Program
37 , requireProgramVersion
40 import Distribution
.Simple
.Utils
42 , installDirectoryContents
45 import Distribution
.Version
(mkVersion
, orLaterVersion
)
46 import System
.Directory
(createDirectoryIfMissing
, renameFile)
47 import System
.FilePath (splitFileName
, (</>))
49 regenerateHaddockIndex
51 -> InstalledPackageIndex
55 regenerateHaddockIndex verbosity pkgs progdb
index = do
56 (paths
, warns
) <- haddockPackagePaths pkgs
' Nothing
57 let paths
' = [(interface
, html
) |
(interface
, Just html
, _
, _
) <- paths
]
58 for_ warns
(debug verbosity
)
60 (confHaddock
, _
, _
) <-
64 (orLaterVersion
(mkVersion
[0, 6]))
67 createDirectoryIfMissing
True destDir
69 withTempDirectory verbosity destDir
"tmphaddock" $ \tempDir
-> do
73 , "--odir=" ++ tempDir
74 , "--title=Haskell modules on this system"
76 ++ [ "--read-interface=" ++ html
++ "," ++ interface
77 |
(interface
, html
) <- paths
'
79 runProgram verbosity confHaddock flags
80 renameFile (tempDir
</> "index.html") (tempDir
</> destFile
)
81 installDirectoryContents verbosity tempDir destDir
83 (destDir
, destFile
) = splitFileName
index
84 pkgs
' :: [InstalledPackageInfo
]
86 [ maximumBy (comparing packageVersion
) pkgvers
'
87 |
(_pname
, pkgvers
) <- allPackagesByName pkgs
88 , let pkgvers
' = filter exposed pkgvers