haddockAction :: HaddockFlags -> [String] -> Action
haddockAction haddockFlags extraArgs globalFlags = do
  let verbosity = fromFlag (haddockVerbosity haddockFlags)
  (_useSandbox, config, distPref) <-
    reconfigure verbosity (haddockDistPref haddockFlags)
                mempty [] globalFlags DontSkipAddSourceDepsCheck
                NoFlag (const Nothing)
  let haddockFlags' = defaultHaddockFlags      `mappend`
                      savedHaddockFlags config `mappend`
                      haddockFlags { haddockDistPref = toFlag distPref }
      setupScriptOptions = defaultSetupScriptOptions { useDistPref = distPref }
  setupWrapper verbosity setupScriptOptions Nothing
    haddockCommand (const haddockFlags') extraArgs
  when (fromFlagOrDefault False $ haddockForHackage haddockFlags) $ do
    pkg <- fmap LBI.localPkgDescr (getPersistBuildConfig distPref)
    let dest = distPref </> name <.> "tar.gz"
        name = display (packageId pkg) ++ "-docs"
        docDir = distPref </> "doc" </> "html"
    createTarGzFile dest docDir name
    notice verbosity $ "Documentation tarball created: " ++ dest
haddockAction :: HaddockFlags -> [String] -> Action
haddockAction haddockFlags extraArgs globalFlags = do
  let verbosity = fromFlag (haddockVerbosity haddockFlags)
  (_useSandbox, config, distPref) <-
    reconfigure verbosity (haddockDistPref haddockFlags)
                mempty [] globalFlags DontSkipAddSourceDepsCheck
                NoFlag (const Nothing)
  let haddockFlags' = defaultHaddockFlags      `mappend`
                      savedHaddockFlags config `mappend`
                      haddockFlags { haddockDistPref = toFlag distPref }
      setupScriptOptions = defaultSetupScriptOptions { useDistPref = distPref }
  setupWrapper verbosity setupScriptOptions Nothing
    haddockCommand (const haddockFlags') extraArgs
  when (fromFlagOrDefault False $ haddockForHackage haddockFlags) $ do
    pkg <- fmap LBI.localPkgDescr (getPersistBuildConfig distPref)
    let dest = distPref </> name <.> "tar.gz"
        name = display (packageId pkg) ++ "-docs"
        docDir = distPref </> "doc" </> "html"
    createTarGzFile dest docDir name
    notice verbosity $ "Documentation tarball created: " ++ dest
haddockAction haddockFlags extraArgs globalFlags = do
  let verbosity = fromFlag (haddockVerbosity haddockFlags)
  (_useSandbox, config, distPref) <-
    reconfigure verbosity (haddockDistPref haddockFlags)
                mempty [] globalFlags DontSkipAddSourceDepsCheck
                NoFlag (const Nothing)
  let haddockFlags' = defaultHaddockFlags      `mappend`
                      savedHaddockFlags config `mappend`
                      haddockFlags { haddockDistPref = toFlag distPref }
      setupScriptOptions = defaultSetupScriptOptions { useDistPref = distPref }
  setupWrapper verbosity setupScriptOptions Nothing
    haddockCommand (const haddockFlags') extraArgs
  when (fromFlagOrDefault False $ haddockForHackage haddockFlags) $ do
    pkg <- fmap LBI.localPkgDescr (getPersistBuildConfig distPref)
    let dest = distPref </> name <.> "tar.gz"
        name = display (packageId pkg) ++ "-docs"
        docDir = distPref </> "doc" </> "html"
    createTarGzFile dest docDir name
    notice verbosity $ "Documentation tarball created: " ++ dest