From d55d8bc017d185e3233a3e627d5398156926e723 Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Tue, 7 Jun 2016 10:31:30 +0100 Subject: [PATCH] Demand that all functions are documented --- src/Cabal.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Cabal.hs b/src/Cabal.hs index 510baab..b8c299e 100644 --- a/src/Cabal.hs +++ b/src/Cabal.hs @@ -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 @@ -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"