Commit d792f8ef authored by Duncan Coutts's avatar Duncan Coutts

Make the documentation toggle determine if we make the haddock index

Previously the --haddock-index=template flag controled both the
template used and whether it's used at all. When no path was set
then it was not used. The problem with that is that since we are
not enabling this feature by default then the default is blank.
That is the default config file would look like:
-- haddock-index:
which doesn't help anyone discover what it means or what a
sensible setting would be. By having a separate toggle to     
enable/disable we can have a default for the index file which
makes it easy to discover in the config file:
-- documentation: False
-- doc-index-file: $datadir/doc/index.html
All the user has to do is uncomment the first line and use True.
parent 7d23ba27
......@@ -309,7 +309,7 @@ regenerateHaddockIndex :: Verbosity
-> IO ()
regenerateHaddockIndex verbosity packageDBs comp conf
configFlags installFlags installPlan
| haddockIndexFileIsSpecified && shouldRegenerateHaddockIndex = do
| haddockIndexFileIsRequested && shouldRegenerateHaddockIndex = do
defaultDirs <- InstallDirs.defaultInstallDirs
(compilerFlavor comp)
......@@ -329,8 +329,9 @@ regenerateHaddockIndex verbosity packageDBs comp conf
| otherwise = return ()
where
haddockIndexFileIsSpecified =
isJust (flagToMaybe (installHaddockIndex installFlags))
haddockIndexFileIsRequested =
fromFlag (installDocumentation installFlags)
&& isJust (flagToMaybe (installHaddockIndex installFlags))
-- We want to regenerate the index if some new documentation was actually
-- installed. Since the index is per-user, we don't do it for global
......
......@@ -462,7 +462,7 @@ data InstallFlags = InstallFlags {
defaultInstallFlags :: InstallFlags
defaultInstallFlags = InstallFlags {
installDocumentation= Flag False,
installHaddockIndex = Flag . toPathTemplate $ "$datadir" </> "doc" </> "index.html",
installHaddockIndex = Flag docIndexFile,
installDryRun = Flag False,
installReinstall = Flag False,
installOnly = Flag False,
......@@ -472,6 +472,8 @@ defaultInstallFlags = InstallFlags {
installBuildReports = Flag NoReports,
installSymlinkBinDir= mempty
}
where
docIndexFile = toPathTemplate ("$datadir" </> "doc" </> "index.html")
installCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags)
installCommand = CommandUI {
......@@ -510,11 +512,12 @@ installOptions showOrParseArgs =
installDocumentation (\v flags -> flags { installDocumentation = v })
(boolOpt [] [])
, option [] ["haddock-index"]
"Haddock html index file (name template shouldn't use $pkgid)"
, option [] ["doc-index-file"]
"A central index of haddock API documentation (template cannot use $pkgid)"
installHaddockIndex (\v flags -> flags { installHaddockIndex = v })
(reqArg' "TEMPLATE" (toFlag.toPathTemplate)
(flagToList . fmap fromPathTemplate))
, option [] ["dry-run"]
"Do not install anything, only print what would be installed."
installDryRun (\v flags -> flags { installDryRun = v })
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment