HpcMarkup.hs 18.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
---------------------------------------------------------
-- The main program for the hpc-markup tool, part of HPC.
-- Andy Gill and Colin Runciman, June 2006
---------------------------------------------------------

module HpcMarkup (markup_plugin) where

import Trace.Hpc.Mix
import Trace.Hpc.Tix
import Trace.Hpc.Util

import HpcFlags
andy@galois.com's avatar
andy@galois.com committed
13
import HpcUtils
14

15
import System.Directory
16
import System.FilePath
17
import System.IO (localeEncoding)
18 19 20
import Data.List
import Data.Maybe(fromJust)
import Data.Array
21
import Control.Monad
22
import qualified Data.Set as Set
23 24 25

------------------------------------------------------------------------------

Ian Lynagh's avatar
Ian Lynagh committed
26
markup_options :: FlagOptSeq
Ian Lynagh's avatar
Ian Lynagh committed
27
markup_options
28 29 30 31
        = excludeOpt
        . includeOpt
        . srcDirOpt
        . hpcDirOpt
32
        . resetHpcDirsOpt
33 34 35
        . funTotalsOpt
        . altHighlightOpt
        . destDirOpt
36
        . verbosityOpt
Ian Lynagh's avatar
Ian Lynagh committed
37 38

markup_plugin :: Plugin
39
markup_plugin = Plugin { name = "markup"
Ian Lynagh's avatar
Ian Lynagh committed
40 41 42 43 44 45 46
                       , usage = "[OPTION] .. <TIX_FILE> [<MODULE> [<MODULE> ..]]"
                       , options = markup_options
                       , summary = "Markup Haskell source with program coverage"
                       , implementation = markup_main
                       , init_flags = default_flags
                       , final_flags = default_final_flags
                       }
47 48 49 50 51

------------------------------------------------------------------------------

markup_main :: Flags -> [String] -> IO ()
markup_main flags (prog:modNames) = do
Ian Lynagh's avatar
Ian Lynagh committed
52 53 54 55
  let hpcflags1 = flags
                { includeMods = Set.fromList modNames
                                   `Set.union`
                                includeMods flags }
56
  let Flags
57
       { funTotals = theFunTotals
58 59 60 61 62 63
       , altHighlight = invertOutput
       , destDir = dest_dir
       }  = hpcflags1

  mtix <- readTix (getTixFileName prog)
  Tix tixs <- case mtix of
64
    Nothing -> hpcError markup_plugin $ "unable to find tix file for: " ++ prog
65 66 67
    Just a -> return a

  mods <-
68
     sequence [ genHtmlFromMod dest_dir hpcflags1 tix theFunTotals invertOutput
Ian Lynagh's avatar
Ian Lynagh committed
69 70 71
              | tix <- tixs
              , allowModule hpcflags1 (tixModuleName tix)
              ]
72 73 74 75 76 77

  let index_name = "hpc_index"
      index_fun  = "hpc_index_fun"
      index_alt  = "hpc_index_alt"
      index_exp  = "hpc_index_exp"

Ian Lynagh's avatar
Ian Lynagh committed
78
  let writeSummary filename cmp = do
79
        let mods' = sortBy cmp mods
80

81
        unless (verbosity flags < Normal) $
82
            putStrLn $ "Writing: " ++ (filename <.> "html")
83

84
        writeFileUsing (dest_dir </> filename <.> "html") $
Ian Lynagh's avatar
Ian Lynagh committed
85
            "<html>" ++
86 87
            "<head>" ++
            charEncodingTag ++
Ian Lynagh's avatar
Ian Lynagh committed
88 89 90 91 92 93 94 95
            "<style type=\"text/css\">" ++
            "table.bar { background-color: #f25913; }\n" ++
            "td.bar { background-color: #60de51;  }\n" ++
            "td.invbar { background-color: #f25913;  }\n" ++
            "table.dashboard { border-collapse: collapse  ; border: solid 1px black }\n" ++
            ".dashboard td { border: solid 1px black }\n" ++
            ".dashboard th { border: solid 1px black }\n" ++
            "</style>\n" ++
96 97
            "</head>" ++
            "<body>" ++
Ian Lynagh's avatar
Ian Lynagh committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
            "<table class=\"dashboard\" width=\"100%\" border=1>\n" ++
            "<tr>" ++
            "<th rowspan=2><a href=\"" ++ index_name ++ ".html\">module</a></th>" ++
            "<th colspan=3><a href=\"" ++ index_fun ++ ".html\">Top Level Definitions</a></th>" ++
            "<th colspan=3><a href=\"" ++ index_alt ++ ".html\">Alternatives</a></th>" ++
            "<th colspan=3><a href=\"" ++ index_exp ++ ".html\">Expressions</a></th>" ++
            "</tr>" ++
            "<tr>" ++
            "<th>%</th>" ++
            "<th colspan=2>covered / total</th>" ++
            "<th>%</th>" ++
            "<th colspan=2>covered / total</th>" ++
            "<th>%</th>" ++
            "<th colspan=2>covered / total</th>" ++
            "</tr>" ++
            concat [ showModuleSummary (modName,fileName,modSummary)
                   | (modName,fileName,modSummary) <- mods'
                   ] ++
            "<tr></tr>" ++
            showTotalSummary (mconcat
                                 [ modSummary
                                 | (_,_,modSummary) <- mods'
                                 ])
121
                   ++ "</table></body></html>\n"
122 123

  writeSummary index_name  $ \ (n1,_,_) (n2,_,_) -> compare n1 n2
Ian Lynagh's avatar
Ian Lynagh committed
124 125

  writeSummary index_fun $ \ (_,_,s1) (_,_,s2) ->
126
        compare (percent (topFunTicked s2) (topFunTotal s2))
Ian Lynagh's avatar
Ian Lynagh committed
127
                (percent (topFunTicked s1) (topFunTotal s1))
128

Ian Lynagh's avatar
Ian Lynagh committed
129
  writeSummary index_alt $ \ (_,_,s1) (_,_,s2) ->
130
        compare (percent (altTicked s2) (altTotal s2))
Ian Lynagh's avatar
Ian Lynagh committed
131
                (percent (altTicked s1) (altTotal s1))
132

Ian Lynagh's avatar
Ian Lynagh committed
133
  writeSummary index_exp $ \ (_,_,s1) (_,_,s2) ->
134
        compare (percent (expTicked s2) (expTotal s2))
Ian Lynagh's avatar
Ian Lynagh committed
135
                (percent (expTicked s1) (expTotal s1))
136 137


Ian Lynagh's avatar
Ian Lynagh committed
138
markup_main _ []
Ian Lynagh's avatar
Ian Lynagh committed
139
    = hpcError markup_plugin $ "no .tix file or executable name specified"
140

141 142 143 144 145
charEncodingTag :: String
charEncodingTag =
    "<meta http-equiv=\"Content-Type\" " ++
          "content=\"text/html; " ++ "charset=" ++ show localeEncoding ++ "\">"

146 147 148 149 150 151 152 153 154 155
-- Add characters to the left of a string until it is at least as
-- large as requested.
padLeft :: Int -> Char -> String -> String
padLeft n c str = go n str
  where
    -- If the string is already long enough, stop traversing it.
    go 0 _       = str
    go k []      = replicate k c ++ str
    go k (_:xs)  = go (k-1) xs

156 157
genHtmlFromMod
  :: String
158
  -> Flags
159 160 161 162
  -> TixModule
  -> Bool
  -> Bool
  -> IO (String, [Char], ModuleSummary)
163 164
genHtmlFromMod dest_dir flags tix theFunTotals invertOutput = do
  let theHsPath = srcDirs flags
Ian Lynagh's avatar
Ian Lynagh committed
165
  let modName0 = tixModuleName tix
166

Ian Lynagh's avatar
Ian Lynagh committed
167
  (Mix origFile _ _ tabStop mix') <- readMixWithFlags flags (Right tix)
168 169 170

  let arr_tix :: Array Int Integer
      arr_tix = listArray (0,length (tixModuleTixs tix) - 1)
Ian Lynagh's avatar
Ian Lynagh committed
171
              $ tixModuleTixs tix
172 173

  let tickedWith :: Int -> Integer
Ian Lynagh's avatar
Ian Lynagh committed
174
      tickedWith n = arr_tix ! n
175 176 177 178

      isTicked n = tickedWith n /= 0

  let info = [ (pos,theMarkup)
Ian Lynagh's avatar
Ian Lynagh committed
179 180 181 182 183 184
             | (gid,(pos,boxLabel)) <- zip [0 ..] mix'
             , let binBox = case (isTicked gid,isTicked (gid+1)) of
                               (False,False) -> []
                               (True,False)  -> [TickedOnlyTrue]
                               (False,True)  -> [TickedOnlyFalse]
                               (True,True)   -> []
185
             , let tickBox = if isTicked gid
Ian Lynagh's avatar
Ian Lynagh committed
186 187 188 189 190 191 192 193 194
                             then [IsTicked]
                             else [NotTicked]
             , theMarkup <- case boxLabel of
                                  ExpBox {} -> tickBox
                                  TopLevelBox {}
                                            -> TopLevelDecl theFunTotals (tickedWith gid) : tickBox
                                  LocalBox {}   -> tickBox
                                  BinBox _ True -> binBox
                                  _             -> []
195 196 197
             ]


Ian Lynagh's avatar
Ian Lynagh committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
  let modSummary = foldr (.) id
             [ \ st ->
               case boxLabel of
                 ExpBox False
                        -> st { expTicked = ticked (expTicked st)
                              , expTotal = succ (expTotal st)
                              }
                 ExpBox True
                        -> st { expTicked = ticked (expTicked st)
                              , expTotal = succ (expTotal st)
                              , altTicked = ticked (altTicked st)
                              , altTotal = succ (altTotal st)
                              }
                 TopLevelBox _ ->
                           st { topFunTicked = ticked (topFunTicked st)
                              , topFunTotal = succ (topFunTotal st)
                              }
215
                 _ -> st
Ian Lynagh's avatar
Ian Lynagh committed
216
             | (gid,(_pos,boxLabel)) <- zip [0 ..] mix'
217
             , let ticked = if isTicked gid
Ian Lynagh's avatar
Ian Lynagh committed
218 219
                            then succ
                            else id
220
             ] $ mempty
221 222

  -- add prefix to modName argument
andy@galois.com's avatar
andy@galois.com committed
223
  content <- readFileFromPath (hpcError markup_plugin) origFile theHsPath
224 225

  let content' = markup tabStop info content
226
  let addLine n xs = "<span class=\"lineno\">" ++ padLeft 5 ' ' (show n) ++ " </span>" ++ xs
227
  let addLines = unlines . map (uncurry addLine) . zip [1 :: Int ..] . lines
228
  let fileName = modName0 <.> "hs" <.> "html"
229 230
  unless (verbosity flags < Normal) $
            putStrLn $ "Writing: " ++ fileName
231
  writeFileUsing (dest_dir </> fileName) $
232 233 234 235
            unlines ["<html>",
                     "<head>",
                     charEncodingTag,
                     "<style type=\"text/css\">",
Ian Lynagh's avatar
Ian Lynagh committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
                     "span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }",
                     if invertOutput
                     then "span.nottickedoff { color: #404040; background: white; font-style: oblique }"
                     else "span.nottickedoff { background: " ++ yellow ++ "}",
                     if invertOutput
                     then "span.istickedoff { color: black; background: #d0c0ff; font-style: normal; }"
                     else "span.istickedoff { background: white }",
                     "span.tickonlyfalse { margin: -1px; border: 1px solid " ++ red ++ "; background: " ++ red ++ " }",
                     "span.tickonlytrue  { margin: -1px; border: 1px solid " ++ green ++ "; background: " ++ green ++ " }",
                     "span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }",
                     if invertOutput
                     then "span.decl { font-weight: bold; background: #d0c0ff }"
                     else "span.decl { font-weight: bold }",
                     "span.spaces    { background: white }",
                     "</style>",
251 252 253 254
                     "</head>",
                     "<body>",
                     "<pre>"] ++ addLines content' ++ "\n</pre>\n</body>\n</html>\n";

255

Ian Lynagh's avatar
Ian Lynagh committed
256
  modSummary `seq` return (modName0,fileName,modSummary)
257 258

data Loc = Loc !Int !Int
Ian Lynagh's avatar
Ian Lynagh committed
259
         deriving (Eq,Ord,Show)
260

Ian Lynagh's avatar
Ian Lynagh committed
261 262 263 264
data Markup
     = NotTicked
     | TickedOnlyTrue
     | TickedOnlyFalse
265
     | IsTicked
Ian Lynagh's avatar
Ian Lynagh committed
266 267 268
     | TopLevelDecl
           Bool     -- display entry totals
           Integer
269 270
     deriving (Eq,Show)

Ian Lynagh's avatar
Ian Lynagh committed
271 272 273 274 275
markup    :: Int                -- ^tabStop
          -> [(HpcPos,Markup)]  -- random list of tick location pairs
          -> String             -- text to mark up
          -> String
markup tabStop mix str = addMarkup tabStop str (Loc 1 1) [] sortedTickLocs
276 277
  where
    tickLocs = [ (Loc ln1 c1,Loc ln2 c2,mark)
Ian Lynagh's avatar
Ian Lynagh committed
278 279 280
               | (pos,mark) <- mix
               , let (ln1,c1,ln2,c2) = fromHpcPos pos
               ]
281 282 283
    sortedTickLocs = sortBy (\(locA1,locZ1,_) (locA2,locZ2,_) ->
                              (locA1,locZ2) `compare` (locA2,locZ1)) tickLocs

Ian Lynagh's avatar
Ian Lynagh committed
284 285 286 287 288 289
addMarkup :: Int                -- tabStop
          -> String             -- text to mark up
          -> Loc                -- current location
          -> [(Loc,Markup)]     -- stack of open ticks, with closing location
          -> [(Loc,Loc,Markup)] -- sorted list of tick location pairs
          -> String
290 291

-- check the pre-condition.
Ian Lynagh's avatar
Ian Lynagh committed
292
--addMarkup tabStop cs loc os ticks
293 294
--   | not (isSorted (map fst os)) = error $ "addMarkup: bad closing ordering: " ++ show os

Ian Lynagh's avatar
Ian Lynagh committed
295
--addMarkup tabStop cs loc os@(_:_) ticks
296 297 298 299
--   | trace (show (loc,os,take 10 ticks)) False = undefined

-- close all open ticks, if we have reached the end
addMarkup _ [] _loc os [] =
Ian Lynagh's avatar
Ian Lynagh committed
300
  concatMap (const closeTick) os
301 302 303 304 305 306 307 308
addMarkup tabStop cs loc ((o,_):os) ticks | loc > o =
  closeTick ++ addMarkup tabStop cs loc os ticks

--addMarkup tabStop cs loc os ((t1,t2,tik@(TopLevelDecl {})):ticks) | loc == t1 =
--   openTick tik ++ closeTick ++ addMarkup tabStop cs loc os ticks

addMarkup tabStop cs loc os ((t1,t2,tik0):ticks) | loc == t1 =
  case os of
Ian Lynagh's avatar
Ian Lynagh committed
309 310
  ((_,tik'):_)
    | not (allowNesting tik0 tik')
311 312
    -> addMarkup tabStop cs loc os ticks -- already marked or bool within marked bool
  _ -> openTick tik0 ++ addMarkup tabStop cs loc (addTo (t2,tik0) os) ticks
313
 where
314 315

  addTo (t,tik) []             = [(t,tik)]
Ian Lynagh's avatar
Ian Lynagh committed
316
  addTo (t,tik) ((t',tik'):xs) | t <= t'   = (t,tik):(t',tik'):xs
Ian Lynagh's avatar
Ian Lynagh committed
317
                               | otherwise = (t',tik):(t',tik'):xs
318 319

addMarkup tabStop0 cs loc os ((t1,_t2,_tik):ticks) | loc > t1 =
Ian Lynagh's avatar
Ian Lynagh committed
320 321
          -- throw away this tick, because it is from a previous place ??
          addMarkup tabStop0 cs loc os ticks
322

Ian Lynagh's avatar
Ian Lynagh committed
323 324 325
addMarkup tabStop0 ('\n':cs) loc@(Loc ln col) os@((Loc ln2 col2,_):_) ticks
          | ln == ln2 && col < col2
          = addMarkup tabStop0 (' ':'\n':cs) loc os ticks
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
addMarkup tabStop0 (c0:cs) loc@(Loc _ p) os ticks =
  if c0=='\n' && os/=[] then
    concatMap (const closeTick) (downToTopLevel os) ++
    c0 : "<span class=\"spaces\">" ++ expand 1 w ++ "</span>" ++
    concatMap (openTick.snd) (reverse (downToTopLevel os)) ++
    addMarkup tabStop0 cs' loc' os ticks
  else if c0=='\t' then
    expand p "\t" ++ addMarkup tabStop0 cs (incBy c0 loc) os ticks
  else
    escape c0 ++ addMarkup tabStop0 cs (incBy c0 loc) os ticks
  where
  (w,cs') = span (`elem` " \t") cs
  loc' = foldl (flip incBy) loc (c0:w)
  escape '>' = "&gt;"
  escape '<' = "&lt;"
  escape '"' = "&quot;"
  escape '&' = "&amp;"
  escape c  = [c]

  expand :: Int -> String -> String
Ian Lynagh's avatar
Ian Lynagh committed
346
  expand _ ""       = ""
347 348 349 350 351
  expand c ('\t':s) = replicate (c' - c) ' ' ++ expand c' s
    where
    c' = tabStopAfter 8 c
  expand c (' ':s)  = ' ' : expand (c+1) s
  expand _ _        = error "bad character in string for expansion"
Ian Lynagh's avatar
Ian Lynagh committed
352

353 354 355 356
  incBy :: Char -> Loc -> Loc
  incBy '\n' (Loc ln _c) = Loc (succ ln) 1
  incBy '\t' (Loc ln c) = Loc ln (tabStopAfter tabStop0 c)
  incBy _    (Loc ln c) = Loc ln (succ c)
Ian Lynagh's avatar
Ian Lynagh committed
357

358 359 360
  tabStopAfter :: Int -> Int -> Int
  tabStopAfter tabStop c = fromJust (find (>c) [1,(tabStop + 1)..])

Ian Lynagh's avatar
Ian Lynagh committed
361

362 363 364
addMarkup tabStop cs loc os ticks = "ERROR: " ++ show (take 10 cs,tabStop,loc,take 10 os,take 10 ticks)

openTick :: Markup -> String
Ian Lynagh's avatar
Ian Lynagh committed
365 366 367 368
openTick NotTicked       = "<span class=\"nottickedoff\">"
openTick IsTicked        = "<span class=\"istickedoff\">"
openTick TickedOnlyTrue  = "<span class=\"tickonlytrue\">"
openTick TickedOnlyFalse = "<span class=\"tickonlyfalse\">"
369
openTick (TopLevelDecl False _) = openTopDecl
Ian Lynagh's avatar
Ian Lynagh committed
370 371 372 373 374 375 376 377
openTick (TopLevelDecl True 0)
         = "<span class=\"funcount\">-- never entered</span>" ++
           openTopDecl
openTick (TopLevelDecl True 1)
         = "<span class=\"funcount\">-- entered once</span>" ++
           openTopDecl
openTick (TopLevelDecl True n0)
         = "<span class=\"funcount\">-- entered " ++ showBigNum n0 ++ " times</span>" ++ openTopDecl
378
  where showBigNum n | n <= 9999 = show n
379 380
                     | otherwise = case n `quotRem` 1000 of
                                     (q, r) -> showBigNum' q ++ "," ++ showWith r
381
        showBigNum' n | n <= 999 = show n
382 383 384 385 386
                      | otherwise = case n `quotRem` 1000 of
                                      (q, r) -> showBigNum' q ++ "," ++ showWith r
        showWith n = padLeft 3 '0' $ show n


387 388 389 390 391 392 393 394 395 396 397 398 399 400 401

closeTick :: String
closeTick = "</span>"

openTopDecl :: String
openTopDecl = "<span class=\"decl\">"

downToTopLevel :: [(Loc,Markup)] -> [(Loc,Markup)]
downToTopLevel ((_,TopLevelDecl {}):_) = []
downToTopLevel (o : os)               = o : downToTopLevel os
downToTopLevel []                     = []


-- build in logic for nesting bin boxes

Ian Lynagh's avatar
Ian Lynagh committed
402 403 404 405
allowNesting :: Markup  -- innermost
            -> Markup   -- outermost
            -> Bool
allowNesting n m               | n == m = False -- no need to double nest
406 407
allowNesting IsTicked TickedOnlyFalse   = False
allowNesting IsTicked TickedOnlyTrue    = False
Ian Lynagh's avatar
Ian Lynagh committed
408
allowNesting _ _                        = True
409 410 411

------------------------------------------------------------------------------

Ian Lynagh's avatar
Ian Lynagh committed
412
data ModuleSummary = ModuleSummary
413 414 415 416 417 418 419 420 421 422 423
     { expTicked :: !Int
     , expTotal  :: !Int
     , topFunTicked :: !Int
     , topFunTotal  :: !Int
     , altTicked :: !Int
     , altTotal  :: !Int
     }
     deriving (Show)


showModuleSummary :: (String, String, ModuleSummary) -> String
Ian Lynagh's avatar
Ian Lynagh committed
424
showModuleSummary (modName,fileName,modSummary) =
Ian Lynagh's avatar
Ian Lynagh committed
425 426 427
  "<tr>\n" ++
  "<td>&nbsp;&nbsp;<tt>module <a href=\"" ++ fileName ++ "\">"
                              ++ modName ++ "</a></tt></td>\n" ++
Ian Lynagh's avatar
Ian Lynagh committed
428 429 430
   showSummary (topFunTicked modSummary) (topFunTotal modSummary) ++
   showSummary (altTicked modSummary) (altTotal modSummary) ++
   showSummary (expTicked modSummary) (expTotal modSummary) ++
431 432 433
  "</tr>\n"

showTotalSummary :: ModuleSummary -> String
Ian Lynagh's avatar
Ian Lynagh committed
434
showTotalSummary modSummary =
Ian Lynagh's avatar
Ian Lynagh committed
435
  "<tr style=\"background: #e0e0e0\">\n" ++
436
  "<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>\n" ++
Ian Lynagh's avatar
Ian Lynagh committed
437 438 439
   showSummary (topFunTicked modSummary) (topFunTotal modSummary) ++
   showSummary (altTicked modSummary) (altTotal modSummary) ++
   showSummary (expTicked modSummary) (expTotal modSummary) ++
440 441
  "</tr>\n"

442
showSummary :: (Integral t, Show t) => t -> t -> String
Ian Lynagh's avatar
Ian Lynagh committed
443 444 445 446 447 448 449 450
showSummary ticked total =
                "<td align=\"right\">" ++ showP (percent ticked total) ++ "</td>" ++
                "<td>" ++ show ticked ++ "/" ++ show total ++ "</td>" ++
                "<td width=100>" ++
                    (case percent ticked total of
                       Nothing -> "&nbsp;"
                       Just w -> bar w "bar"
                     )  ++ "</td>"
451 452 453
     where
        showP Nothing = "-&nbsp;"
        showP (Just x) = show x ++ "%"
Ian Lynagh's avatar
Ian Lynagh committed
454
        bar 0 _     = bar 100 "invbar"
455
        bar w inner = "<table cellpadding=0 cellspacing=0 width=\"100\" class=\"bar\">" ++
Ian Lynagh's avatar
Ian Lynagh committed
456 457 458
                         "<tr><td><table cellpadding=0 cellspacing=0 width=\"" ++ show w ++ "%\">" ++
                              "<tr><td height=12 class=" ++ show inner ++ "></td></tr>" ++
                              "</table></td></tr></table>"
459 460 461 462 463

percent :: (Integral a) => a -> a -> Maybe a
percent ticked total = if total == 0 then Nothing else Just (ticked * 100 `div` total)


464 465
instance Monoid ModuleSummary where
  mempty = ModuleSummary
Ian Lynagh's avatar
Ian Lynagh committed
466 467
                  { expTicked = 0
                  , expTotal  = 0
468 469 470 471 472 473
                  , topFunTicked = 0
                  , topFunTotal  = 0
                  , altTicked = 0
                  , altTotal  = 0
                  }
  mappend (ModuleSummary eTik1 eTot1 tTik1 tTot1 aTik1 aTot1)
Ian Lynagh's avatar
Ian Lynagh committed
474
          (ModuleSummary eTik2 eTot2 tTik2 tTot2 aTik2 aTot2)
475 476
     = ModuleSummary (eTik1 + eTik2) (eTot1 + eTot2) (tTik1 + tTik2) (tTot1 + tTot2) (aTik1 + aTik2) (aTot1 + aTot2)

477

478 479 480 481 482 483 484 485 486
------------------------------------------------------------------------------

writeFileUsing :: String -> String -> IO ()
writeFileUsing filename text = do
-- We need to check for the dest_dir each time, because we use sub-dirs for
-- packages, and a single .tix file might contain information about
-- many package.

  -- create the dest_dir if needed
487
  createDirectoryIfMissing True (takeDirectory filename)
488 489 490

  writeFile filename text

491 492 493 494 495 496 497 498
------------------------------------------------------------------------------
-- global color pallete

red,green,yellow :: String
red    = "#f20913"
green  = "#60de51"
yellow = "yellow"