Commit e6e95fc2 authored by Andrey Mokhov's avatar Andrey Mokhov

Move Sphinx builder into the library

See #347
parent e04d2072
......@@ -28,6 +28,7 @@ executable hadrian
, GHC
, Hadrian.Builder
, Hadrian.Builder.Ar
, Hadrian.Builder.Sphinx
, Hadrian.Builder.Tar
, Hadrian.Expression
, Hadrian.Haskell.Cabal
......@@ -77,7 +78,6 @@ executable hadrian
, Settings.Builders.HsCpp
, Settings.Builders.Ld
, Settings.Builders.Make
, Settings.Builders.Sphinx
, Settings.Builders.Xelatex
, Settings.Default
, Settings.Flavours.Development
......
......@@ -19,6 +19,7 @@ import GHC.Generics
import qualified Hadrian.Builder as H
import Hadrian.Builder hiding (Builder)
import Hadrian.Builder.Ar
import Hadrian.Builder.Sphinx
import Hadrian.Builder.Tar
import Hadrian.Oracles.Path
import Hadrian.Oracles.TextFile
......@@ -68,16 +69,6 @@ instance Binary HaddockMode
instance Hashable HaddockMode
instance NFData HaddockMode
-- | Sphinx can be used in three different modes:
-- * Convert RST to HTML
-- * Convert RST to LaTeX
-- * Convert RST to Man pages
data SphinxMode = Html | Latex | Man deriving (Eq, Generic, Show)
instance Binary SphinxMode
instance Hashable SphinxMode
instance NFData SphinxMode
-- | A 'Builder' is an external command invoked in a separate process via 'cmd'.
-- @Ghc Stage0@ is the bootstrapping compiler.
-- @Ghc StageN@, N > 0, is the one built in stage (N - 1).
......
-----------------------------------------------------------------------------
-- |
-- Module : Hadrian.Builder.Sphinx
-- Copyright : (c) Andrey Mokhov 2014-2017
-- License : MIT (see the file LICENSE)
-- Maintainer : andrey.mokhov@gmail.com
-- Stability : experimental
--
-- Support for invoking the documentation utility Sphinx.
-----------------------------------------------------------------------------
module Hadrian.Builder.Sphinx (SphinxMode (..), args) where
import Development.Shake
import Development.Shake.Classes
import GHC.Generics
import Hadrian.Expression
import Hadrian.Utilities
-- | Sphinx can be used in three different modes to convert reStructuredText
-- documents into HTML, LaTeX or Man pages.
data SphinxMode = Html | Latex | Man deriving (Eq, Generic, Show)
instance Binary SphinxMode
instance Hashable SphinxMode
instance NFData SphinxMode
-- | Default command line arguments for invoking the archiving utility @tar@.
args :: (ShakeValue c, ShakeValue b) => SphinxMode -> Args c b
args mode = do
outPath <- getOutput
mconcat [ arg "-b", arg modeString
, arg "-d", arg $ outPath -/- (".doctrees-" ++ modeString)
, arg =<< getInput
, arg outPath ]
where
modeString = case mode of
Html -> "html"
Latex -> "latex"
Man -> "man"
module Settings.Builders.Sphinx (sphinxBuilderArgs) where
import Settings.Builders.Common
sphinxBuilderArgs :: Args
sphinxBuilderArgs = do
outPath <- getOutput
mconcat [ builder (Sphinx Html) ? mconcat
[ arg "-b", arg "html"
, arg "-d", arg $ outPath -/- ".doctrees-html"
, arg =<< getInput
, arg outPath ]
, builder (Sphinx Latex) ? mconcat
[ arg "-b", arg "latex"
, arg "-d", arg $ outPath -/- ".doctrees-latex"
, arg =<< getInput
, arg outPath ]
, builder (Sphinx Man) ? mconcat
[ arg "-b", arg "man"
, arg "-d", arg $ outPath -/- ".doctrees-man"
, arg =<< getInput
, arg outPath ] ]
......@@ -6,6 +6,7 @@ module Settings.Default (
import qualified Hadrian.Builder.Ar
import qualified Hadrian.Builder.Tar
import qualified Hadrian.Builder.Sphinx
import CommandLine
import Expression
......@@ -28,7 +29,6 @@ import Settings.Builders.Hsc2Hs
import Settings.Builders.HsCpp
import Settings.Builders.Ld
import Settings.Builders.Make
import Settings.Builders.Sphinx
import Settings.Builders.Xelatex
import Settings.Packages.Base
import Settings.Packages.Cabal
......@@ -39,7 +39,7 @@ import Settings.Packages.Ghci
import Settings.Packages.GhcPkg
import Settings.Packages.GhcPrim
import Settings.Packages.Haddock
import Settings.Packages.Haskeline (haskelinePackageArgs)
import Settings.Packages.Haskeline
import Settings.Packages.IntegerGmp
import Settings.Packages.Rts
import Settings.Packages.RunGhc
......@@ -140,9 +140,8 @@ defaultSplitObjects = do
-- | All 'Builder'-dependent command line arguments.
defaultBuilderArgs :: Args
defaultBuilderArgs = mconcat
-- GHC-specific builders:
[ alexBuilderArgs
, builder (Ar Pack ) ? Hadrian.Builder.Ar.args Pack
, builder (Ar Unpack) ? Hadrian.Builder.Ar.args Unpack
, ccBuilderArgs
, configureBuilderArgs
, deriveConstantsBuilderArgs
......@@ -158,10 +157,15 @@ defaultBuilderArgs = mconcat
, hsCppBuilderArgs
, ldBuilderArgs
, makeBuilderArgs
, sphinxBuilderArgs
, builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
, builder (Tar Extract) ? Hadrian.Builder.Tar.args Extract
, xelatexBuilderArgs ]
, xelatexBuilderArgs
-- Generic builders from the Hadrian library:
, builder (Ar Pack ) ? Hadrian.Builder.Ar.args Pack
, builder (Ar Unpack ) ? Hadrian.Builder.Ar.args Unpack
, builder (Sphinx Html ) ? Hadrian.Builder.Sphinx.args Html
, builder (Sphinx Latex) ? Hadrian.Builder.Sphinx.args Latex
, builder (Sphinx Man ) ? Hadrian.Builder.Sphinx.args Man
, builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
, builder (Tar Extract ) ? Hadrian.Builder.Tar.args Extract ]
-- TODO: Disable warnings for Windows specifics.
-- TODO: Move this elsewhere?
......
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