forked from diagrams/diagrams-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.hs
27 lines (25 loc) · 1.22 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
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)
main :: IO ()
main = defaultMainWithHooks simpleUserHooks
{ postHaddock = \args flags pkg lbi -> do
dias <- filter ("svg" `isSuffixOf`) `fmap` getDirectoryContents "diagrams"
copyFiles normal (haddockOutputDir flags pkg)
(map (\d -> ("", "diagrams" </> d)) dias)
postHaddock simpleUserHooks args flags pkg lbi
}