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