blob: 7e2401d0d5cb082c67207f815e5e88bdb35fd7c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-----------------------------------------------------------------------------
-- |
-- 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 = Info | 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
Info -> "texinfo"
Html -> "html"
Latex -> "latex"
Man -> "man"
|