module Language.Drasil.Output.Formats where
import Data.Char (toLower)
import Build.Drasil ((+:+), Command, makeS, mkCheckedCommand, mkCommand, mkFreeVar,
mkFile, mkRule, RuleTransformer(makeRule))
import Language.Drasil.Printers (DocType(..), Format)
type Filename = String
data DocChoices = DC {
DocChoices -> DocType
doctype :: DocType,
DocChoices -> [Format]
format :: [Format]
}
data DocSpec = DocSpec DocChoices Filename
instance RuleTransformer DocSpec where
makeRule :: DocSpec -> [Rule]
makeRule (DocSpec (DC DocType
Website [Format]
_) Filename
_) = []
makeRule (DocSpec (DC DocType
dt [Format]
_) Filename
fn) = [
Annotation -> Target -> Dependencies -> [Command] -> Rule
mkRule [] (Filename -> Target
makeS forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> Filename
show DocType
dt) [Target
pdfName] [],
Annotation -> Target -> Dependencies -> [Command] -> Rule
mkFile [] Target
pdfName [Filename -> Target
makeS forall a b. (a -> b) -> a -> b
$ Filename
fn forall a. [a] -> [a] -> [a]
++ Filename
".tex"] forall a b. (a -> b) -> a -> b
$
forall a b. (a -> b) -> [a] -> [b]
map (forall a b. (a -> b) -> a -> b
$ Filename
fn) [Filename -> Command
lualatex, Filename -> Command
bibtex, Filename -> Command
lualatex, Filename -> Command
lualatex]] where
lualatex, bibtex :: String -> Command
lualatex :: Filename -> Command
lualatex = Target -> Command
mkCheckedCommand forall b c a. (b -> c) -> (a -> b) -> a -> c
. Target -> Target -> Target
(+:+) (Filename -> Target
makeS Filename
"lualatex" Target -> Target -> Target
+:+ Filename -> Target
mkFreeVar Filename
"TEXFLAGS") forall b c a. (b -> c) -> (a -> b) -> a -> c
. Filename -> Target
makeS
bibtex :: Filename -> Command
bibtex = Target -> Command
mkCommand forall b c a. (b -> c) -> (a -> b) -> a -> c
. Target -> Target -> Target
(+:+) (Filename -> Target
makeS Filename
"bibtex" Target -> Target -> Target
+:+ Filename -> Target
mkFreeVar Filename
"BIBTEXFLAGS") forall b c a. (b -> c) -> (a -> b) -> a -> c
. Filename -> Target
makeS
pdfName :: Target
pdfName = Filename -> Target
makeS forall a b. (a -> b) -> a -> b
$ Filename
fn forall a. [a] -> [a] -> [a]
++ Filename
".pdf"
data DocClass = DocClass (Maybe String) String
newtype UsePackages = UsePackages [String]
data ExDoc = ExDoc (Maybe String) String