aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Interface
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-02-11 03:31:44 -0800
committerAlexander Biehl <alexbiehl@gmail.com>2018-02-11 12:31:44 +0100
commit5141e4b76af8462e49abdf48e44bb9cddb183383 (patch)
treecf30907acc18b379a2ccb4a4d40cf55a18215c2e /haddock-api/src/Haddock/Interface
parent0bffd8bd1105331a6fcf0b7e592358c131de9300 (diff)
Add 'show' option to complement 'hide' (#752)
* Add 'show' option to complement 'hide' The behaviour is for flags passed in the command line to override flags in file headers. In the command line, later flags override earlier ones. Fixes #751 and #266. * Add a '--show-all' option
Diffstat (limited to 'haddock-api/src/Haddock/Interface')
-rw-r--r--haddock-api/src/Haddock/Interface/Create.hs21
1 files changed, 11 insertions, 10 deletions
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index 75e7e9a1..f218853b 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -312,16 +312,17 @@ mkDocOpts mbOpts flags mdl = do
[] -> tell ["No option supplied to DOC_OPTION/doc_option"] >> return []
xs -> liftM catMaybes (mapM parseOption xs)
Nothing -> return []
- hm <- if Flag_HideModule (moduleString mdl) `elem` flags
- then return $ OptHide : opts
- else return opts
- ie <- if Flag_IgnoreAllExports `elem` flags
- then return $ OptIgnoreExports : hm
- else return hm
- se <- if Flag_ShowExtensions (moduleString mdl) `elem` flags
- then return $ OptShowExtensions : ie
- else return ie
- return se
+ pure (foldl go opts flags)
+ where
+ mdlStr = moduleString mdl
+
+ -- Later flags override earlier ones
+ go os m | m == Flag_HideModule mdlStr = OptHide : os
+ | m == Flag_ShowModule mdlStr = filter (/= OptHide) os
+ | m == Flag_ShowAllModules = filter (/= OptHide) os
+ | m == Flag_IgnoreAllExports = OptIgnoreExports : os
+ | m == Flag_ShowExtensions mdlStr = OptIgnoreExports : os
+ | otherwise = os
parseOption :: String -> ErrMsgM (Maybe DocOption)
parseOption "hide" = return (Just OptHide)