Skip to content

Commit

Permalink
Merge pull request haskell#10393 from MercuryTechnologies/wiggles/had…
Browse files Browse the repository at this point in the history
…dock-project-parse-common-flags

`haddock-project`: add `CommonSetupFlags`
  • Loading branch information
mergify[bot] authored Oct 11, 2024
2 parents 6548697 + f84087a commit 32e3730
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 198 deletions.
273 changes: 138 additions & 135 deletions Cabal/src/Distribution/Simple/Setup/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ data Visibility = Visible | Hidden
deriving (Eq, Show)

data HaddockProjectFlags = HaddockProjectFlags
{ haddockProjectHackage :: Flag Bool
{ haddockProjectCommonFlags :: !CommonSetupFlags
, haddockProjectHackage :: Flag Bool
-- ^ a shortcut option which builds documentation linked to hackage. It implies:
-- * `--html-location='https://hackage.haskell.org/package/$prg-$version/docs'
-- * `--quickjump`
Expand Down Expand Up @@ -457,7 +458,8 @@ data HaddockProjectFlags = HaddockProjectFlags
defaultHaddockProjectFlags :: HaddockProjectFlags
defaultHaddockProjectFlags =
HaddockProjectFlags
{ haddockProjectHackage = Flag False
{ haddockProjectCommonFlags = defaultCommonSetupFlags
, haddockProjectHackage = Flag False
, haddockProjectDir = Flag "./haddocks"
, haddockProjectPrologue = NoFlag
, haddockProjectTestSuites = Flag False
Expand Down Expand Up @@ -517,140 +519,141 @@ haddockProjectCommand =
emptyProgramDb

haddockProjectOptions :: ShowOrParseArgs -> [OptionField HaddockProjectFlags]
haddockProjectOptions _showOrParseArgs =
[ option
""
["hackage"]
( concat
[ "A short-cut option to build documentation linked to hackage."
]
)
haddockProjectHackage
(\v flags -> flags{haddockProjectHackage = v})
trueArg
, option
""
["output"]
"Output directory"
haddockProjectDir
(\v flags -> flags{haddockProjectDir = v})
(optArg' "DIRECTORY" maybeToFlag (fmap Just . flagToList))
, option
""
["prologue"]
"File path to a prologue file in haddock format"
haddockProjectPrologue
(\v flags -> flags{haddockProjectPrologue = v})
(optArg' "PATH" maybeToFlag (fmap Just . flagToList))
, option
""
["hoogle"]
"Generate a hoogle database"
haddockProjectHoogle
(\v flags -> flags{haddockProjectHoogle = v})
trueArg
, option
""
["html-location"]
"Location of HTML documentation for pre-requisite packages"
haddockProjectHtmlLocation
(\v flags -> flags{haddockProjectHtmlLocation = v})
(reqArgFlag "URL")
, option
""
["executables"]
"Run haddock for Executables targets"
haddockProjectExecutables
(\v flags -> flags{haddockProjectExecutables = v})
trueArg
, option
""
["tests"]
"Run haddock for Test Suite targets"
haddockProjectTestSuites
(\v flags -> flags{haddockProjectTestSuites = v})
trueArg
, option
""
["benchmarks"]
"Run haddock for Benchmark targets"
haddockProjectBenchmarks
(\v flags -> flags{haddockProjectBenchmarks = v})
trueArg
, option
""
["foreign-libraries"]
"Run haddock for Foreign Library targets"
haddockProjectForeignLibs
(\v flags -> flags{haddockProjectForeignLibs = v})
trueArg
, option
""
["all", "haddock-all"]
"Run haddock for all targets"
( \f ->
allFlags
[ haddockProjectExecutables f
, haddockProjectTestSuites f
, haddockProjectBenchmarks f
, haddockProjectForeignLibs f
haddockProjectOptions showOrParseArgs =
withCommonSetupOptions
haddockProjectCommonFlags
(\c f -> f{haddockProjectCommonFlags = c})
showOrParseArgs
[ option
""
["hackage"]
( concat
[ "A short-cut option to build documentation linked to hackage."
]
)
( \v flags ->
flags
{ haddockProjectExecutables = v
, haddockProjectTestSuites = v
, haddockProjectBenchmarks = v
, haddockProjectForeignLibs = v
}
)
trueArg
, option
""
["internal"]
"Run haddock for internal modules and include all symbols"
haddockProjectInternal
(\v flags -> flags{haddockProjectInternal = v})
trueArg
, option
""
["css"]
"Use PATH as the haddock stylesheet"
haddockProjectCss
(\v flags -> flags{haddockProjectCss = v})
(reqArgFlag "PATH")
, option
""
["hscolour-css"]
"Use PATH as the HsColour stylesheet"
haddockProjectHscolourCss
(\v flags -> flags{haddockProjectHscolourCss = v})
(reqArgFlag "PATH")
, option
""
["keep-temp-files"]
"Keep temporary files"
haddockProjectKeepTempFiles
(\b flags -> flags{haddockProjectKeepTempFiles = b})
trueArg
, optionVerbosity
haddockProjectVerbosity
(\v flags -> flags{haddockProjectVerbosity = v})
, option
""
["resources-dir"]
"location of Haddocks static / auxiliary files"
haddockProjectResourcesDir
(\v flags -> flags{haddockProjectResourcesDir = v})
(reqArgFlag "DIR")
, option
""
["use-unicode"]
"Pass --use-unicode option to haddock"
haddockProjectUseUnicode
(\v flags -> flags{haddockProjectUseUnicode = v})
trueArg
]
)
haddockProjectHackage
(\v flags -> flags{haddockProjectHackage = v})
trueArg
, option
""
["output"]
"Output directory"
haddockProjectDir
(\v flags -> flags{haddockProjectDir = v})
(optArg' "DIRECTORY" maybeToFlag (fmap Just . flagToList))
, option
""
["prologue"]
"File path to a prologue file in haddock format"
haddockProjectPrologue
(\v flags -> flags{haddockProjectPrologue = v})
(optArg' "PATH" maybeToFlag (fmap Just . flagToList))
, option
""
["hoogle"]
"Generate a hoogle database"
haddockProjectHoogle
(\v flags -> flags{haddockProjectHoogle = v})
trueArg
, option
""
["html-location"]
"Location of HTML documentation for pre-requisite packages"
haddockProjectHtmlLocation
(\v flags -> flags{haddockProjectHtmlLocation = v})
(reqArgFlag "URL")
, option
""
["executables"]
"Run haddock for Executables targets"
haddockProjectExecutables
(\v flags -> flags{haddockProjectExecutables = v})
trueArg
, option
""
["tests"]
"Run haddock for Test Suite targets"
haddockProjectTestSuites
(\v flags -> flags{haddockProjectTestSuites = v})
trueArg
, option
""
["benchmarks"]
"Run haddock for Benchmark targets"
haddockProjectBenchmarks
(\v flags -> flags{haddockProjectBenchmarks = v})
trueArg
, option
""
["foreign-libraries"]
"Run haddock for Foreign Library targets"
haddockProjectForeignLibs
(\v flags -> flags{haddockProjectForeignLibs = v})
trueArg
, option
""
["all", "haddock-all"]
"Run haddock for all targets"
( \f ->
allFlags
[ haddockProjectExecutables f
, haddockProjectTestSuites f
, haddockProjectBenchmarks f
, haddockProjectForeignLibs f
]
)
( \v flags ->
flags
{ haddockProjectExecutables = v
, haddockProjectTestSuites = v
, haddockProjectBenchmarks = v
, haddockProjectForeignLibs = v
}
)
trueArg
, option
""
["internal"]
"Run haddock for internal modules and include all symbols"
haddockProjectInternal
(\v flags -> flags{haddockProjectInternal = v})
trueArg
, option
""
["css"]
"Use PATH as the haddock stylesheet"
haddockProjectCss
(\v flags -> flags{haddockProjectCss = v})
(reqArgFlag "PATH")
, option
""
["hscolour-css"]
"Use PATH as the HsColour stylesheet"
haddockProjectHscolourCss
(\v flags -> flags{haddockProjectHscolourCss = v})
(reqArgFlag "PATH")
, option
""
["keep-temp-files"]
"Keep temporary files"
haddockProjectKeepTempFiles
(\b flags -> flags{haddockProjectKeepTempFiles = b})
trueArg
, option
""
["resources-dir"]
"location of Haddocks static / auxiliary files"
haddockProjectResourcesDir
(\v flags -> flags{haddockProjectResourcesDir = v})
(reqArgFlag "DIR")
, option
""
["use-unicode"]
"Pass --use-unicode option to haddock"
haddockProjectUseUnicode
(\v flags -> flags{haddockProjectUseUnicode = v})
trueArg
]

emptyHaddockProjectFlags :: HaddockProjectFlags
emptyHaddockProjectFlags = mempty
Expand Down
Loading

0 comments on commit 32e3730

Please sign in to comment.