module Haddock.Options
( parseHaddockOpts
, Flag (..)
, Visibility (..)
, getUsage
, optTitle
, outputDir
, optContentsUrl
, optIndexUrl
, optCssFile
, optSourceCssFile
, sourceUrls
, wikiUrls
, baseUrl
, optParCount
, optDumpInterfaceFile
, optShowInterfaceFile
, optLaTeXStyle
, optMathjax
, optOneShot
, qualification
, sinceQualification
, verbosity
, ghcFlags
, reexportFlags
, readIfaceArgs
, optPackageName
, optPackageVersion
, modulePackageInfo
, ignoredSymbols
) where
import Control.Applicative
import qualified Data.Char as Char
import Data.List (dropWhileEnd)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Version
import GHC (Module, moduleUnit)
import GHC.Data.FastString
import GHC.Unit.State
import System.Console.GetOpt
import qualified Text.ParserCombinators.ReadP as RP
import Haddock.Types
import Haddock.Utils
data Flag
= Flag_BuiltInThemes
| Flag_CSS String
|
Flag_ReadInterface String
| Flag_DumpInterface String
| Flag_ShowInterface String
| Flag_Heading String
| Flag_Html
| Flag_Hoogle
| Flag_Lib String
| Flag_OutputDir FilePath
| Flag_Prologue FilePath
| Flag_SourceBaseURL String
| Flag_SourceModuleURL String
| Flag_SourceEntityURL String
| Flag_SourceLEntityURL String
| Flag_WikiBaseURL String
| Flag_BaseURL String
| Flag_WikiModuleURL String
| Flag_WikiEntityURL String
| Flag_LaTeX
| Flag_LaTeXStyle String
| Flag_QuickJumpIndex
| Flag_HyperlinkedSource
| Flag_SourceCss String
| Flag_Mathjax String
| Flag_Help
| Flag_Verbosity String
| Flag_Version
| Flag_CompatibleInterfaceVersions
| Flag_InterfaceVersion
| Flag_BypassInterfaceVersonCheck
| Flag_UseContents String
| Flag_GenContents
| Flag_UseIndex String
| Flag_GenIndex
| Flag_IgnoreAllExports
| Flag_HideModule String
| Flag_ShowModule String
| Flag_ShowAllModules
| Flag_ShowExtensions String
| Flag_OptGhc String
| Flag_GhcLibDir String
| Flag_GhcVersion
| Flag_PrintGhcPath
| Flag_PrintGhcLibDir
| Flag_NoWarnings
| Flag_UseUnicode
| Flag_NoTmpCompDir
| Flag_Qualification String
| Flag_PrettyHtml
| Flag_NoPrintMissingDocs
| Flag_PackageName String
| Flag_PackageVersion String
| Flag_Reexport String
| Flag_SinceQualification String
| Flag_IgnoreLinkSymbol String
| Flag_ParCount (Maybe Int)
| Flag_TraceArgs
| Flag_OneShot String
| Flag_NoCompilation
deriving (Flag -> Flag -> Bool
(Flag -> Flag -> Bool) -> (Flag -> Flag -> Bool) -> Eq Flag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Flag -> Flag -> Bool
== :: Flag -> Flag -> Bool
$c/= :: Flag -> Flag -> Bool
/= :: Flag -> Flag -> Bool
Eq, Int -> Flag -> ShowS
[Flag] -> ShowS
Flag -> [Char]
(Int -> Flag -> ShowS)
-> (Flag -> [Char]) -> ([Flag] -> ShowS) -> Show Flag
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Flag -> ShowS
showsPrec :: Int -> Flag -> ShowS
$cshow :: Flag -> [Char]
show :: Flag -> [Char]
$cshowList :: [Flag] -> ShowS
showList :: [Flag] -> ShowS
Show)
options :: Bool -> [OptDescr Flag]
options :: Bool -> [OptDescr Flag]
options Bool
backwardsCompat =
[ [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'B']
[]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_GhcLibDir [Char]
"DIR")
[Char]
"path to a GHC lib dir, to override the default path"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'o']
[[Char]
"odir"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_OutputDir [Char]
"DIR")
[Char]
"directory in which to put the output files"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'l']
[[Char]
"lib"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_Lib [Char]
"DIR")
[Char]
"location of Haddock's auxiliary files"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'i']
[[Char]
"read-interface"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_ReadInterface [Char]
"FILE")
[Char]
"read an interface from FILE"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'D']
[[Char]
"dump-interface"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_DumpInterface [Char]
"FILE")
[Char]
"write the resulting interface to FILE"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"show-interface"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_ShowInterface [Char]
"FILE")
[Char]
"print the interface in a human readable form"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"no-compilation"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_NoCompilation)
[Char]
"never compile the code, just read the .hi files"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"incremental"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_OneShot [Char]
"MODULE")
[Char]
"generate documentation for a single module only, given its module name"
,
[Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'h']
[[Char]
"html"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_Html)
[Char]
"output in HTML (XHTML 1.0)"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [] [[Char]
"latex"] (Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_LaTeX) [Char]
"use experimental LaTeX rendering"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [] [[Char]
"latex-style"] (([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_LaTeXStyle [Char]
"FILE") [Char]
"provide your own LaTeX style in FILE"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [] [[Char]
"mathjax"] (([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_Mathjax [Char]
"URL") [Char]
"URL FOR mathjax"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char
'U'] [[Char]
"use-unicode"] (Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_UseUnicode) [Char]
"use Unicode in HTML output"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"hoogle"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_Hoogle)
[Char]
"output for Hoogle; you may want --package-name and --package-version too"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"quickjump"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_QuickJumpIndex)
[Char]
"generate an index for interactive documentation navigation"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"hyperlinked-source"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_HyperlinkedSource)
[Char]
"generate highlighted and hyperlinked source code (for use with --html)"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"source-css"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_SourceCss [Char]
"FILE")
[Char]
"use custom CSS file instead of default one in hyperlinked source"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"source-base"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_SourceBaseURL [Char]
"URL")
[Char]
"URL for a source code link on the contents\nand index pages"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
's']
(if Bool
backwardsCompat then [[Char]
"source", [Char]
"source-module"] else [[Char]
"source-module"])
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_SourceModuleURL [Char]
"URL")
[Char]
"URL for a source code link for each module\n(using the %{FILE} or %{MODULE} vars)"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"source-entity"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_SourceEntityURL [Char]
"URL")
[Char]
"URL for a source code link for each entity\n(using the %{FILE}, %{MODULE}, %{NAME},\n%{KIND} or %{LINE} vars)"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"source-entity-line"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_SourceLEntityURL [Char]
"URL")
[Char]
"URL for a source code link for each entity.\nUsed if name links are unavailable, eg. for TH splices."
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"comments-base"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_WikiBaseURL [Char]
"URL")
[Char]
"URL for a comments link on the contents\nand index pages"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"base-url"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_BaseURL [Char]
"URL")
[Char]
"Base URL for static assets (eg. css, javascript, json files etc.).\nWhen given statis assets will not be copied."
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"comments-module"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_WikiModuleURL [Char]
"URL")
[Char]
"URL for a comments link for each module\n(using the %{MODULE} var)"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"comments-entity"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_WikiEntityURL [Char]
"URL")
[Char]
"URL for a comments link for each entity\n(using the %{FILE}, %{MODULE}, %{NAME},\n%{KIND} or %{LINE} vars)"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'c']
[[Char]
"css", [Char]
"theme"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_CSS [Char]
"PATH")
[Char]
"the CSS file or theme directory to use for HTML output"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"built-in-themes"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_BuiltInThemes)
[Char]
"include all the built-in haddock themes"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'p']
[[Char]
"prologue"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_Prologue [Char]
"FILE")
[Char]
"file containing prologue text"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
't']
[[Char]
"title"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_Heading [Char]
"TITLE")
[Char]
"page heading"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'q']
[[Char]
"qual"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_Qualification [Char]
"QUAL")
[Char]
"qualification of names, one of \n'none' (default), 'full', 'local'\n'relative' or 'aliased'"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'?']
[[Char]
"help"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_Help)
[Char]
"display this help and exit"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'V']
[[Char]
"version"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_Version)
[Char]
"output version information and exit"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"compatible-interface-versions"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_CompatibleInterfaceVersions)
[Char]
"output compatible interface file versions and exit"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"interface-version"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_InterfaceVersion)
[Char]
"output interface file version and exit"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"bypass-interface-version-check"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_BypassInterfaceVersonCheck)
[Char]
"bypass the interface file version check (dangerous)"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'v']
[[Char]
"verbosity"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_Verbosity [Char]
"VERBOSITY")
[Char]
"set verbosity level"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"use-contents"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_UseContents [Char]
"URL")
[Char]
"use a separately-generated HTML contents page"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"gen-contents"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_GenContents)
[Char]
"generate an HTML contents from specified\ninterfaces"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"use-index"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_UseIndex [Char]
"URL")
[Char]
"use a separately-generated HTML index"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"gen-index"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_GenIndex)
[Char]
"generate an HTML index from specified\ninterfaces"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"ignore-all-exports"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_IgnoreAllExports)
[Char]
"behave as if all modules have the\nignore-exports attribute"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"hide"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_HideModule [Char]
"MODULE")
[Char]
"behave as if MODULE has the hide attribute"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"show"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_ShowModule [Char]
"MODULE")
[Char]
"behave as if MODULE does not have the hide attribute"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"show-all"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_ShowAllModules)
[Char]
"behave as if not modules have the hide attribute"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"show-extensions"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_ShowExtensions [Char]
"MODULE")
[Char]
"behave as if MODULE has the show-extensions attribute"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"optghc"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_OptGhc [Char]
"OPTION")
[Char]
"option to be forwarded to GHC"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"ghc-version"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_GhcVersion)
[Char]
"output GHC version in numeric format"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"print-ghc-path"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_PrintGhcPath)
[Char]
"output path to GHC binary"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"print-ghc-libdir"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_PrintGhcLibDir)
[Char]
"output GHC lib dir"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char
'w'] [[Char]
"no-warnings"] (Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_NoWarnings) [Char]
"turn off all warnings"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"no-tmp-comp-dir"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_NoTmpCompDir)
[Char]
"do not re-direct compilation output to a temporary directory"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"pretty-html"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_PrettyHtml)
[Char]
"generate html with newlines and indenting (for use with --html)"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"no-print-missing-docs"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_NoPrintMissingDocs)
[Char]
"don't print information about any undocumented entities"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"reexport"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_Reexport [Char]
"MOD")
[Char]
"reexport the module MOD, adding it to the index"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"package-name"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_PackageName [Char]
"NAME")
[Char]
"name of the package being documented"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"package-version"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_PackageVersion [Char]
"VERSION")
[Char]
"version of the package being documented in usual x.y.z.w format"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"since-qual"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_SinceQualification [Char]
"QUAL")
[Char]
"package qualification of @since, one of\n'always' (default) or 'only-external'"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"ignore-link-symbol"]
(([Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> Flag
Flag_IgnoreLinkSymbol [Char]
"SYMBOL")
[Char]
"name of a symbol which does not trigger a warning in case of link issue"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[Char
'j']
[]
((Maybe [Char] -> Flag) -> [Char] -> ArgDescr Flag
forall a. (Maybe [Char] -> a) -> [Char] -> ArgDescr a
OptArg (\Maybe [Char]
count -> Maybe Int -> Flag
Flag_ParCount (([Char] -> Int) -> Maybe [Char] -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap [Char] -> Int
forall a. Read a => [Char] -> a
read Maybe [Char]
count)) [Char]
"n")
[Char]
"load modules in parallel"
, [Char] -> [[Char]] -> ArgDescr Flag -> [Char] -> OptDescr Flag
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option
[]
[[Char]
"trace-args"]
(Flag -> ArgDescr Flag
forall a. a -> ArgDescr a
NoArg Flag
Flag_TraceArgs)
[Char]
"print the arguments provided for this invocation to stdout"
]
getUsage :: IO String
getUsage :: IO [Char]
getUsage = do
prog <- IO [Char]
getProgramName
return $ usageInfo (usageHeader prog) (options False)
where
usageHeader :: String -> String
usageHeader :: ShowS
usageHeader [Char]
prog = [Char]
"Usage: " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
prog [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char]
" [OPTION...] file...\n"
parseHaddockOpts :: [String] -> IO ([Flag], [String])
parseHaddockOpts :: [[Char]] -> IO ([Flag], [[Char]])
parseHaddockOpts [[Char]]
params =
case ArgOrder Flag
-> [OptDescr Flag] -> [[Char]] -> ([Flag], [[Char]], [[Char]])
forall a.
ArgOrder a -> [OptDescr a] -> [[Char]] -> ([a], [[Char]], [[Char]])
getOpt ArgOrder Flag
forall a. ArgOrder a
Permute (Bool -> [OptDescr Flag]
options Bool
True) [[Char]]
params of
([Flag]
flags, [[Char]]
args, []) -> ([Flag], [[Char]]) -> IO ([Flag], [[Char]])
forall a. a -> IO a
forall (m :: Type -> Type) a. Monad m => a -> m a
return ([Flag]
flags, [[Char]]
args)
([Flag]
_, [[Char]]
_, [[Char]]
errors) -> do
usage <- IO [Char]
getUsage
throwE (concat errors ++ usage)
optPackageVersion :: [Flag] -> Maybe Data.Version.Version
optPackageVersion :: [Flag] -> Maybe Version
optPackageVersion [Flag]
flags =
let ver :: Maybe [Char]
ver = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
v | Flag_PackageVersion [Char]
v <- [Flag]
flags]
in Maybe [Char]
ver Maybe [Char] -> ([Char] -> Maybe Version) -> Maybe Version
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((Version, [Char]) -> Version)
-> Maybe (Version, [Char]) -> Maybe Version
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap (Version, [Char]) -> Version
forall a b. (a, b) -> a
fst (Maybe (Version, [Char]) -> Maybe Version)
-> ([Char] -> Maybe (Version, [Char])) -> [Char] -> Maybe Version
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Version, [Char])] -> Maybe (Version, [Char])
forall a. [a] -> Maybe a
optLast ([(Version, [Char])] -> Maybe (Version, [Char]))
-> ([Char] -> [(Version, [Char])])
-> [Char]
-> Maybe (Version, [Char])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReadP Version -> [Char] -> [(Version, [Char])]
forall a. ReadP a -> ReadS a
RP.readP_to_S ReadP Version
parseVersion
optPackageName :: [Flag] -> Maybe PackageName
optPackageName :: [Flag] -> Maybe PackageName
optPackageName [Flag]
flags =
[PackageName] -> Maybe PackageName
forall a. [a] -> Maybe a
optLast [FastString -> PackageName
PackageName (FastString -> PackageName) -> FastString -> PackageName
forall a b. (a -> b) -> a -> b
$ [Char] -> FastString
mkFastString [Char]
n | Flag_PackageName [Char]
n <- [Flag]
flags]
optTitle :: [Flag] -> Maybe String
optTitle :: [Flag] -> Maybe [Char]
optTitle [Flag]
flags =
case [[Char]
str | Flag_Heading [Char]
str <- [Flag]
flags] of
[] -> Maybe [Char]
forall a. Maybe a
Nothing
([Char]
t : [[Char]]
_) -> [Char] -> Maybe [Char]
forall a. a -> Maybe a
Just [Char]
t
outputDir :: [Flag] -> FilePath
outputDir :: [Flag] -> [Char]
outputDir [Flag]
flags =
case [[Char]
path | Flag_OutputDir [Char]
path <- [Flag]
flags] of
[] -> [Char]
"."
[[Char]]
paths -> [[Char]] -> [Char]
forall a. HasCallStack => [a] -> a
last [[Char]]
paths
optContentsUrl :: [Flag] -> Maybe String
optContentsUrl :: [Flag] -> Maybe [Char]
optContentsUrl [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
url | Flag_UseContents [Char]
url <- [Flag]
flags]
optIndexUrl :: [Flag] -> Maybe String
optIndexUrl :: [Flag] -> Maybe [Char]
optIndexUrl [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
url | Flag_UseIndex [Char]
url <- [Flag]
flags]
optCssFile :: [Flag] -> Maybe FilePath
optCssFile :: [Flag] -> Maybe [Char]
optCssFile [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_CSS [Char]
str <- [Flag]
flags]
optSourceCssFile :: [Flag] -> Maybe FilePath
optSourceCssFile :: [Flag] -> Maybe [Char]
optSourceCssFile [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_SourceCss [Char]
str <- [Flag]
flags]
sourceUrls :: [Flag] -> (Maybe String, Maybe String, Maybe String, Maybe String)
sourceUrls :: [Flag] -> (Maybe [Char], Maybe [Char], Maybe [Char], Maybe [Char])
sourceUrls [Flag]
flags =
( [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_SourceBaseURL [Char]
str <- [Flag]
flags]
, [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_SourceModuleURL [Char]
str <- [Flag]
flags]
, [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_SourceEntityURL [Char]
str <- [Flag]
flags]
, [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_SourceLEntityURL [Char]
str <- [Flag]
flags]
)
wikiUrls :: [Flag] -> (Maybe String, Maybe String, Maybe String)
wikiUrls :: [Flag] -> (Maybe [Char], Maybe [Char], Maybe [Char])
wikiUrls [Flag]
flags =
( [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_WikiBaseURL [Char]
str <- [Flag]
flags]
, [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_WikiModuleURL [Char]
str <- [Flag]
flags]
, [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_WikiEntityURL [Char]
str <- [Flag]
flags]
)
baseUrl :: [Flag] -> Maybe String
baseUrl :: [Flag] -> Maybe [Char]
baseUrl [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_BaseURL [Char]
str <- [Flag]
flags]
optDumpInterfaceFile :: [Flag] -> Maybe FilePath
optDumpInterfaceFile :: [Flag] -> Maybe [Char]
optDumpInterfaceFile [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_DumpInterface [Char]
str <- [Flag]
flags]
optShowInterfaceFile :: [Flag] -> Maybe FilePath
optShowInterfaceFile :: [Flag] -> Maybe [Char]
optShowInterfaceFile [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_ShowInterface [Char]
str <- [Flag]
flags]
optOneShot :: [Flag] -> Maybe String
optOneShot :: [Flag] -> Maybe [Char]
optOneShot [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_OneShot [Char]
str <- [Flag]
flags]
optLaTeXStyle :: [Flag] -> Maybe String
optLaTeXStyle :: [Flag] -> Maybe [Char]
optLaTeXStyle [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_LaTeXStyle [Char]
str <- [Flag]
flags]
optMathjax :: [Flag] -> Maybe String
optMathjax :: [Flag] -> Maybe [Char]
optMathjax [Flag]
flags = [[Char]] -> Maybe [Char]
forall a. [a] -> Maybe a
optLast [[Char]
str | Flag_Mathjax [Char]
str <- [Flag]
flags]
optParCount :: [Flag] -> Maybe (Maybe Int)
optParCount :: [Flag] -> Maybe (Maybe Int)
optParCount [Flag]
flags = [Maybe Int] -> Maybe (Maybe Int)
forall a. [a] -> Maybe a
optLast [Maybe Int
n | Flag_ParCount Maybe Int
n <- [Flag]
flags]
qualification :: [Flag] -> Either String QualOption
qualification :: [Flag] -> Either [Char] QualOption
qualification [Flag]
flags =
case ShowS -> [[Char]] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map ((Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
Char.toLower) [[Char]
str | Flag_Qualification [Char]
str <- [Flag]
flags] of
[] -> QualOption -> Either [Char] QualOption
forall a b. b -> Either a b
Right QualOption
OptNoQual
[[Char]
"none"] -> QualOption -> Either [Char] QualOption
forall a b. b -> Either a b
Right QualOption
OptNoQual
[[Char]
"full"] -> QualOption -> Either [Char] QualOption
forall a b. b -> Either a b
Right QualOption
OptFullQual
[[Char]
"local"] -> QualOption -> Either [Char] QualOption
forall a b. b -> Either a b
Right QualOption
OptLocalQual
[[Char]
"relative"] -> QualOption -> Either [Char] QualOption
forall a b. b -> Either a b
Right QualOption
OptRelativeQual
[[Char]
arg] -> [Char] -> Either [Char] QualOption
forall a b. a -> Either a b
Left ([Char] -> Either [Char] QualOption)
-> [Char] -> Either [Char] QualOption
forall a b. (a -> b) -> a -> b
$ [Char]
"unknown qualification type " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> [Char]
show [Char]
arg
[Char]
_ : [[Char]]
_ -> [Char] -> Either [Char] QualOption
forall a b. a -> Either a b
Left [Char]
"qualification option given multiple times"
sinceQualification :: [Flag] -> Either String SinceQual
sinceQualification :: [Flag] -> Either [Char] SinceQual
sinceQualification [Flag]
flags =
case ShowS -> [[Char]] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map ((Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
Char.toLower) [[Char]
str | Flag_SinceQualification [Char]
str <- [Flag]
flags] of
[] -> SinceQual -> Either [Char] SinceQual
forall a b. b -> Either a b
Right SinceQual
Always
[[Char]
"always"] -> SinceQual -> Either [Char] SinceQual
forall a b. b -> Either a b
Right SinceQual
Always
[[Char]
"external"] -> SinceQual -> Either [Char] SinceQual
forall a b. b -> Either a b
Right SinceQual
External
[[Char]
arg] -> [Char] -> Either [Char] SinceQual
forall a b. a -> Either a b
Left ([Char] -> Either [Char] SinceQual)
-> [Char] -> Either [Char] SinceQual
forall a b. (a -> b) -> a -> b
$ [Char]
"unknown since-qualification type " [Char] -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> [Char]
show [Char]
arg
[Char]
_ : [[Char]]
_ -> [Char] -> Either [Char] SinceQual
forall a b. a -> Either a b
Left [Char]
"since-qualification option given multiple times"
verbosity :: [Flag] -> Verbosity
verbosity :: [Flag] -> Verbosity
verbosity [Flag]
flags =
case [[Char]
str | Flag_Verbosity [Char]
str <- [Flag]
flags] of
[] -> Verbosity
Normal
[Char]
x : [[Char]]
_ -> case [Char] -> Either [Char] Verbosity
parseVerbosity [Char]
x of
Left [Char]
e -> [Char] -> Verbosity
forall a. [Char] -> a
throwE [Char]
e
Right Verbosity
v -> Verbosity
v
ignoredSymbols :: [Flag] -> Map (Maybe String) (Set String)
ignoredSymbols :: [Flag] -> Map (Maybe [Char]) (Set [Char])
ignoredSymbols [Flag]
flags =
((Maybe [Char], [Char])
-> Map (Maybe [Char]) (Set [Char])
-> Map (Maybe [Char]) (Set [Char]))
-> Map (Maybe [Char]) (Set [Char])
-> [(Maybe [Char], [Char])]
-> Map (Maybe [Char]) (Set [Char])
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: Type -> Type) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Maybe [Char], [Char])
-> Map (Maybe [Char]) (Set [Char])
-> Map (Maybe [Char]) (Set [Char])
addToMap Map (Maybe [Char]) (Set [Char])
forall k a. Map k a
Map.empty [[Char] -> (Maybe [Char], [Char])
splitSymbol [Char]
symbol | Flag_IgnoreLinkSymbol [Char]
symbol <- [Flag]
flags]
where
splitSymbol :: String -> (Maybe String, String)
splitSymbol :: [Char] -> (Maybe [Char], [Char])
splitSymbol [Char]
s =
case (Char -> Bool) -> ShowS
forall a. (a -> Bool) -> [a] -> [a]
dropWhileEnd (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
'.') [Char]
s of
[Char]
"" -> (Maybe [Char]
forall a. Maybe a
Nothing, [Char]
s)
[Char]
s' -> ([Char] -> Maybe [Char]
forall a. a -> Maybe a
Just ([Char] -> Maybe [Char]) -> [Char] -> Maybe [Char]
forall a b. (a -> b) -> a -> b
$ ShowS
forall a. HasCallStack => [a] -> [a]
init [Char]
s', Int -> ShowS
forall a. Int -> [a] -> [a]
drop ([Char] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [Char]
s') [Char]
s)
addToMap :: (Maybe String, String) -> Map (Maybe String) (Set String) -> Map (Maybe String) (Set String)
addToMap :: (Maybe [Char], [Char])
-> Map (Maybe [Char]) (Set [Char])
-> Map (Maybe [Char]) (Set [Char])
addToMap (Maybe [Char]
m, [Char]
name) Map (Maybe [Char]) (Set [Char])
symbs = (Set [Char] -> Set [Char] -> Set [Char])
-> Maybe [Char]
-> Set [Char]
-> Map (Maybe [Char]) (Set [Char])
-> Map (Maybe [Char]) (Set [Char])
forall k a. Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
Map.insertWith (Set [Char] -> Set [Char] -> Set [Char]
forall a. Ord a => Set a -> Set a -> Set a
Set.union) Maybe [Char]
m ([Char] -> Set [Char]
forall a. a -> Set a
Set.singleton [Char]
name) Map (Maybe [Char]) (Set [Char])
symbs
ghcFlags :: [Flag] -> [String]
ghcFlags :: [Flag] -> [[Char]]
ghcFlags [Flag]
flags = [[Char]
option | Flag_OptGhc [Char]
option <- [Flag]
flags]
reexportFlags :: [Flag] -> [String]
reexportFlags :: [Flag] -> [[Char]]
reexportFlags [Flag]
flags = [[Char]
option | Flag_Reexport [Char]
option <- [Flag]
flags]
data Visibility = Visible | Hidden
deriving (Visibility -> Visibility -> Bool
(Visibility -> Visibility -> Bool)
-> (Visibility -> Visibility -> Bool) -> Eq Visibility
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Visibility -> Visibility -> Bool
== :: Visibility -> Visibility -> Bool
$c/= :: Visibility -> Visibility -> Bool
/= :: Visibility -> Visibility -> Bool
Eq, Eq Visibility
Eq Visibility =>
(Visibility -> Visibility -> Ordering)
-> (Visibility -> Visibility -> Bool)
-> (Visibility -> Visibility -> Bool)
-> (Visibility -> Visibility -> Bool)
-> (Visibility -> Visibility -> Bool)
-> (Visibility -> Visibility -> Visibility)
-> (Visibility -> Visibility -> Visibility)
-> Ord Visibility
Visibility -> Visibility -> Bool
Visibility -> Visibility -> Ordering
Visibility -> Visibility -> Visibility
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Visibility -> Visibility -> Ordering
compare :: Visibility -> Visibility -> Ordering
$c< :: Visibility -> Visibility -> Bool
< :: Visibility -> Visibility -> Bool
$c<= :: Visibility -> Visibility -> Bool
<= :: Visibility -> Visibility -> Bool
$c> :: Visibility -> Visibility -> Bool
> :: Visibility -> Visibility -> Bool
$c>= :: Visibility -> Visibility -> Bool
>= :: Visibility -> Visibility -> Bool
$cmax :: Visibility -> Visibility -> Visibility
max :: Visibility -> Visibility -> Visibility
$cmin :: Visibility -> Visibility -> Visibility
min :: Visibility -> Visibility -> Visibility
Ord, Int -> Visibility -> ShowS
[Visibility] -> ShowS
Visibility -> [Char]
(Int -> Visibility -> ShowS)
-> (Visibility -> [Char])
-> ([Visibility] -> ShowS)
-> Show Visibility
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Visibility -> ShowS
showsPrec :: Int -> Visibility -> ShowS
$cshow :: Visibility -> [Char]
show :: Visibility -> [Char]
$cshowList :: [Visibility] -> ShowS
showList :: [Visibility] -> ShowS
Show)
readIfaceArgs :: [Flag] -> [(DocPaths, Visibility, FilePath)]
readIfaceArgs :: [Flag] -> [(DocPaths, Visibility, [Char])]
readIfaceArgs [Flag]
flags = [[Char] -> (DocPaths, Visibility, [Char])
parseIfaceOption [Char]
s | Flag_ReadInterface [Char]
s <- [Flag]
flags]
where
parseIfaceOption :: String -> (DocPaths, Visibility, FilePath)
parseIfaceOption :: [Char] -> (DocPaths, Visibility, [Char])
parseIfaceOption [Char]
str =
case (Char -> Bool) -> [Char] -> ([Char], [Char])
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
',') [Char]
str of
([Char]
fpath, Char
',' : [Char]
rest) ->
case (Char -> Bool) -> [Char] -> ([Char], [Char])
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
',') [Char]
rest of
([Char]
src, Char
',' : [Char]
rest') ->
let src' :: Maybe [Char]
src' = case [Char]
src of
[Char]
"" -> Maybe [Char]
forall a. Maybe a
Nothing
[Char]
_ -> [Char] -> Maybe [Char]
forall a. a -> Maybe a
Just [Char]
src
docPaths :: DocPaths
docPaths =
DocPaths
{ docPathsHtml :: [Char]
docPathsHtml = [Char]
fpath
, docPathsSources :: Maybe [Char]
docPathsSources = Maybe [Char]
src'
}
in case (Char -> Bool) -> [Char] -> ([Char], [Char])
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
',') [Char]
rest' of
([Char]
visibility, Char
',' : [Char]
file)
| [Char]
visibility [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
"hidden" ->
(DocPaths
docPaths, Visibility
Hidden, [Char]
file)
| Bool
otherwise ->
(DocPaths
docPaths, Visibility
Visible, [Char]
file)
([Char]
file, [Char]
_) ->
(DocPaths
docPaths, Visibility
Visible, [Char]
file)
([Char]
file, [Char]
_) -> ([Char] -> Maybe [Char] -> DocPaths
DocPaths [Char]
fpath Maybe [Char]
forall a. Maybe a
Nothing, Visibility
Visible, [Char]
file)
([Char]
file, [Char]
_) -> ([Char] -> Maybe [Char] -> DocPaths
DocPaths [Char]
"" Maybe [Char]
forall a. Maybe a
Nothing, Visibility
Visible, [Char]
file)
optLast :: [a] -> Maybe a
optLast :: forall a. [a] -> Maybe a
optLast [] = Maybe a
forall a. Maybe a
Nothing
optLast [a]
xs = a -> Maybe a
forall a. a -> Maybe a
Just ([a] -> a
forall a. HasCallStack => [a] -> a
last [a]
xs)
modulePackageInfo
:: UnitState
-> [Flag]
-> Maybe Module
-> (Maybe PackageName, Maybe Data.Version.Version)
modulePackageInfo :: UnitState
-> [Flag] -> Maybe Module -> (Maybe PackageName, Maybe Version)
modulePackageInfo UnitState
_unit_state [Flag]
_flags Maybe Module
Nothing = (Maybe PackageName
forall a. Maybe a
Nothing, Maybe Version
forall a. Maybe a
Nothing)
modulePackageInfo UnitState
unit_state [Flag]
flags (Just Module
modu) =
( [Flag] -> Maybe PackageName
optPackageName [Flag]
flags Maybe PackageName -> Maybe PackageName -> Maybe PackageName
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (GenericUnitInfo PackageId PackageName UnitId ModuleName Module
-> PackageName)
-> Maybe
(GenericUnitInfo PackageId PackageName UnitId ModuleName Module)
-> Maybe PackageName
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap GenericUnitInfo PackageId PackageName UnitId ModuleName Module
-> PackageName
forall srcpkgid srcpkgname uid modulename mod.
GenericUnitInfo srcpkgid srcpkgname uid modulename mod
-> srcpkgname
unitPackageName Maybe
(GenericUnitInfo PackageId PackageName UnitId ModuleName Module)
pkgDb
, [Flag] -> Maybe Version
optPackageVersion [Flag]
flags Maybe Version -> Maybe Version -> Maybe Version
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (GenericUnitInfo PackageId PackageName UnitId ModuleName Module
-> Version)
-> Maybe
(GenericUnitInfo PackageId PackageName UnitId ModuleName Module)
-> Maybe Version
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap GenericUnitInfo PackageId PackageName UnitId ModuleName Module
-> Version
forall srcpkgid srcpkgname uid modulename mod.
GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> Version
unitPackageVersion Maybe
(GenericUnitInfo PackageId PackageName UnitId ModuleName Module)
pkgDb
)
where
pkgDb :: Maybe
(GenericUnitInfo PackageId PackageName UnitId ModuleName Module)
pkgDb = UnitState
-> Unit
-> Maybe
(GenericUnitInfo PackageId PackageName UnitId ModuleName Module)
lookupUnit UnitState
unit_state (Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit Module
modu)