44b522c4d3b83cdc88f3348fbfe0351fbdb49408
[ghc.git] / hadrian / src / Hadrian / Builder / Sphinx.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module : Hadrian.Builder.Sphinx
4 -- Copyright : (c) Andrey Mokhov 2014-2017
5 -- License : MIT (see the file LICENSE)
6 -- Maintainer : andrey.mokhov@gmail.com
7 -- Stability : experimental
8 --
9 -- Support for invoking the documentation utility Sphinx.
10 -----------------------------------------------------------------------------
11 module Hadrian.Builder.Sphinx (SphinxMode (..), args) where
12
13 import Development.Shake
14 import Development.Shake.Classes
15 import GHC.Generics
16 import Hadrian.Expression
17 import Hadrian.Utilities
18
19 -- | Sphinx can be used in three different modes to convert reStructuredText
20 -- documents into HTML, LaTeX or Man pages.
21 data SphinxMode = Html | Latex | Man deriving (Eq, Generic, Show)
22
23 instance Binary SphinxMode
24 instance Hashable SphinxMode
25 instance NFData SphinxMode
26
27 -- | Default command line arguments for invoking the archiving utility @tar@.
28 args :: (ShakeValue c, ShakeValue b) => SphinxMode -> Args c b
29 args mode = do
30 outPath <- getOutput
31 mconcat [ arg "-b", arg modeString
32 , arg "-d", arg $ outPath -/- (".doctrees-" ++ modeString)
33 , arg =<< getInput
34 , arg outPath ]
35 where
36 modeString = case mode of
37 Html -> "html"
38 Latex -> "latex"
39 Man -> "man"