-
Notifications
You must be signed in to change notification settings - Fork 62
/
Setup.hs
29 lines (26 loc) · 1.25 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Data.List (isSuffixOf)
import Distribution.Simple
import Distribution.Simple.Setup (Flag (..), HaddockFlags,
haddockDistPref)
import Distribution.Simple.Utils (copyFiles)
import Distribution.Text (display)
import Distribution.Verbosity (normal)
import System.Directory (getDirectoryContents)
import System.FilePath ((</>))
-- Ugly hack, logic copied from Distribution.Simple.Haddock
haddockOutputDir :: Package pkg => HaddockFlags -> pkg -> FilePath
haddockOutputDir flags pkg = destDir
where
baseDir = case haddockDistPref flags of
NoFlag -> "."
Flag x -> x
destDir = baseDir </> "doc" </> "html" </> display (packageName pkg)
diagramsDir = "diagrams"
main :: IO ()
main = defaultMainWithHooks simpleUserHooks
{ postHaddock = \args flags pkg lbi -> do
dias <- filter ("svg" `isSuffixOf`) `fmap` getDirectoryContents diagramsDir
copyFiles normal (haddockOutputDir flags pkg)
(map (\d -> ("", diagramsDir </> d)) dias)
postHaddock simpleUserHooks args flags pkg lbi
}