Skip to content

Commit

Permalink
Demand that all functions are documented
Browse files Browse the repository at this point in the history
  • Loading branch information
ndmitchell committed Jun 7, 2016
1 parent d16f249 commit d55d8bc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ checkTravis = do
["Got:"] ++ got


-- | Check every function exported is also documented
checkHoogle :: IO ()
checkHoogle = whenM (doesDirectoryExist "dist/doc/html") $ do
src <- getDirectoryContents "dist/doc/html"
forM_ src $ \x -> do
contents <- readFileUTF8' $ "dist/doc/html" </> x </> x <.> "txt"
-- look for two lines in a row not separated by comments
let bad = concat $ map (drop 1) $ wordsBy ("--" `isPrefixOf`) $
filter (not . isPrefixOf "instance ") $
filter (not . isPrefixOf "@version ") $
filter (not . null) $ map trim $ lines contents
when (bad /= []) $
error $ unlines $ "Bad hoogle:" : bad


-- | Run some commands in a temporary directory with the unpacked cabal
withSDist :: IO a -> IO a
withSDist run = withTempDir $ \tdir -> do
Expand Down Expand Up @@ -113,6 +128,8 @@ run Test{..} = Just $ do
"--ghc-option=-fwarn-tabs " ++
(if no_warnings then "" else "--ghc-option=-Werror")
system_ "cabal build"
system_ "cabal haddock --hoogle"
checkHoogle
when runTest $ system_ "cabal test --show-details=streaming"
when install $ do
system_ "cabal copy"
Expand Down

0 comments on commit d55d8bc

Please sign in to comment.