aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Interface.hs
diff options
context:
space:
mode:
authorSimon Michael <simon@joyful.com>2010-09-22 17:58:06 +0000
committerSimon Michael <simon@joyful.com>2010-09-22 17:58:06 +0000
commit0f8e38017cbb981ea07e52d5a4a7f4736c30718b (patch)
treeb753d4d8317cf3f13323a8db6dbf2493fd460168 /src/Haddock/Interface.hs
parenta419044739b732030c6ba8ad7767a802e449026a (diff)
print haddock coverage info on stdout when generating docs
A module's haddockable items are its exports and the module itself. The output is lightly formatted so you can align the :'s and sort for readability.
Diffstat (limited to 'src/Haddock/Interface.hs')
-rw-r--r--src/Haddock/Interface.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Haddock/Interface.hs b/src/Haddock/Interface.hs
index 0c171cbc..81919aed 100644
--- a/src/Haddock/Interface.hs
+++ b/src/Haddock/Interface.hs
@@ -46,6 +46,7 @@ import qualified Data.Map as Map
import Distribution.Verbosity
import System.Directory
import System.FilePath
+import Text.Printf
import Digraph
import Exception
@@ -161,6 +162,13 @@ processModule verbosity modsum flags modMap instIfaceMap = do
out verbosity verbose "Creating interface..."
(interface, msg) <- runWriterGhc $ createInterface tm flags modMap instIfaceMap
liftIO $ mapM_ putStrLn msg
+ let (haddockable, haddocked) = ifaceHaddockCoverage interface
+ percentage = round (fromIntegral haddocked * 100 / fromIntegral haddockable :: Double) :: Int
+ coveragemsg = printf "haddock coverage for %s: %7s %3d%%"
+ (ifaceOrigFilename interface)
+ (printf "%d/%d" haddocked haddockable :: String)
+ percentage
+ out verbosity normal coveragemsg
interface' <- liftIO $ evaluate interface
return (Just interface')
else