aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock
diff options
context:
space:
mode:
authorMarcin Szamotulski <coot@coot.me>2022-05-21 23:32:31 +0200
committerGitHub <noreply@github.com>2022-05-21 23:32:31 +0200
commitc0f06d55bd64d2777588860917be3dcdaede3479 (patch)
treeb9868542f50ced56ec522bec3921f9dc497da948 /haddock-api/src/Haddock
parent2c27d150f777f08165d3c8c60c8aa2a0fa164fdd (diff)
Allow to hide interfaces when rendering multiple components (#1487)
This is useful when one wishes to `--gen-contents` when rendering multiple components, but one does not want to render all modules. This is in particular useful when adding base package.
Diffstat (limited to 'haddock-api/src/Haddock')
-rw-r--r--haddock-api/src/Haddock/Options.hs24
1 files changed, 19 insertions, 5 deletions
diff --git a/haddock-api/src/Haddock/Options.hs b/haddock-api/src/Haddock/Options.hs
index aa10b5b3..78bfe1a1 100644
--- a/haddock-api/src/Haddock/Options.hs
+++ b/haddock-api/src/Haddock/Options.hs
@@ -15,6 +15,7 @@
module Haddock.Options (
parseHaddockOpts,
Flag(..),
+ Visibility(..),
getUsage,
optTitle,
outputDir,
@@ -361,18 +362,31 @@ ghcFlags flags = [ option | Flag_OptGhc option <- flags ]
reexportFlags :: [Flag] -> [String]
reexportFlags flags = [ option | Flag_Reexport option <- flags ]
+data Visibility = Visible | Hidden
+ deriving (Eq, Show)
-readIfaceArgs :: [Flag] -> [(DocPaths, FilePath)]
+readIfaceArgs :: [Flag] -> [(DocPaths, Visibility, FilePath)]
readIfaceArgs flags = [ parseIfaceOption s | Flag_ReadInterface s <- flags ]
where
- parseIfaceOption :: String -> (DocPaths, FilePath)
+ parseIfaceOption :: String -> (DocPaths, Visibility, FilePath)
parseIfaceOption str =
case break (==',') str of
(fpath, ',':rest) ->
case break (==',') rest of
- (src, ',':file) -> ((fpath, Just src), file)
- (file, _) -> ((fpath, Nothing), file)
- (file, _) -> (("", Nothing), file)
+ (src, ',':rest') ->
+ let src' = case src of
+ "" -> Nothing
+ _ -> Just src
+ in
+ case break (==',') rest' of
+ (visibility, ',':file) | visibility == "hidden" ->
+ ((fpath, src'), Hidden, file)
+ | otherwise ->
+ ((fpath, src'), Visible, file)
+ (file, _) ->
+ ((fpath, src'), Visible, file)
+ (file, _) -> ((fpath, Nothing), Visible, file)
+ (file, _) -> (("", Nothing), Visible, file)
-- | Like 'listToMaybe' but returns the last element instead of the first.