-- | Defines Drasil generator functions.
module Language.Drasil.Generate (
  -- * Debugging
  dumpTo, dumpEverything,
  -- * Type checking
  typeCheckSI,
  -- * Generator Functions
  gen, genDot, genCode,
  -- * Types (Printing Options)
  DocType(..), DocSpec(DocSpec), DocChoices(DC),
  Format(TeX, HTML, Jupyter, MDBook),
  -- * Constructor
  docChoices) where

import System.IO (hClose, hPutStrLn, openFile, IOMode(WriteMode))
import Text.PrettyPrint.HughesPJ (Doc, render)
import Prelude hiding (id)
import System.Directory (createDirectoryIfMissing, getCurrentDirectory,
  setCurrentDirectory)
import Data.Time.Clock (getCurrentTime, utctDay)
import Data.Time.Calendar (showGregorian)

import Build.Drasil (genMake)
import Language.Drasil
import Drasil.DocLang (mkGraphInfo)
import SysInfo.Drasil (SystemInformation)
import Language.Drasil.Printers (DocType(SRS, Website, Lesson), makeCSS, genHTML, 
  genTeX, Format(TeX, HTML, Jupyter, MDBook), genJupyter, genMDBook, 
  PrintingInformation, outputDot, makeBook, makeRequirements)
import Language.Drasil.Code (generator, generateCode, generateCodeProc,
  Choices(..), CodeSpec(..), HasOldCodeSpec(..), Lang(..), 
  getSampleData, readWithDataDesc, sampleInputDD, unPP, unJP, unCSP, unCPPP, unSP, unJLP)
import Language.Drasil.Output.Formats(Filename, DocSpec(DocSpec), DocChoices(DC))

import Language.Drasil.TypeCheck
import Language.Drasil.Dump

import Drasil.GOOL (unJC, unPC, unCSC, unCPPC, unSC)
import Drasil.GProc (unJLC)
import Control.Lens ((^.))

-- | Generate a number of artifacts based on a list of recipes.
gen :: DocSpec -> Document -> PrintingInformation -> IO ()
gen :: DocSpec -> Document -> PrintingInformation -> IO ()
gen DocSpec
ds Document
fn PrintingInformation
sm = PrintingInformation -> DocSpec -> Document -> IO ()
prnt PrintingInformation
sm DocSpec
ds Document
fn -- FIXME: 'prnt' is just 'gen' with the arguments reordered

-- TODO: Include Jupyter into the SRS setup.
-- | Generate the output artifacts (TeX+Makefile, HTML or Notebook).
prnt :: PrintingInformation -> DocSpec -> Document -> IO ()
prnt :: PrintingInformation -> DocSpec -> Document -> IO ()
prnt PrintingInformation
sm (DocSpec (DC DocType
Lesson [Format]
_) Filename
fn) Document
body =
  do Document
-> PrintingInformation -> Filename -> DocType -> Format -> IO ()
prntDoc Document
body PrintingInformation
sm Filename
fn DocType
Lesson Format
Jupyter
prnt PrintingInformation
sm (DocSpec (DC DocType
dtype [Format]
fmts) Filename
fn) Document
body =
  do (Format -> IO ()) -> [Format] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Document
-> PrintingInformation -> Filename -> DocType -> Format -> IO ()
prntDoc Document
body PrintingInformation
sm Filename
fn DocType
dtype) [Format]
fmts

-- | Helper for writing the documents (TeX / HTML / Jupyter) to file.
prntDoc :: Document -> PrintingInformation -> String -> DocType -> Format -> IO ()
prntDoc :: Document
-> PrintingInformation -> Filename -> DocType -> Format -> IO ()
prntDoc Document
d PrintingInformation
pinfo Filename
fn DocType
Lesson Format
_ = DocType
-> Filename
-> Filename
-> Format
-> Document
-> PrintingInformation
-> IO ()
prntDoc' DocType
Lesson Filename
"Lesson" Filename
fn Format
Jupyter Document
d PrintingInformation
pinfo
prntDoc Document
d PrintingInformation
pinfo Filename
fn DocType
dtype Format
fmt =
  case Format
fmt of
    Format
HTML              -> do DocType
-> Filename
-> Filename
-> Format
-> Document
-> PrintingInformation
-> IO ()
prntDoc' DocType
dtype (DocType -> Filename
forall a. Show a => a -> Filename
show DocType
dtype Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/HTML") Filename
fn Format
HTML Document
d PrintingInformation
pinfo
                            DocType -> Filename -> Document -> IO ()
prntCSS DocType
dtype Filename
fn Document
d
    Format
TeX               -> do DocType
-> Filename
-> Filename
-> Format
-> Document
-> PrintingInformation
-> IO ()
prntDoc' DocType
dtype (DocType -> Filename
forall a. Show a => a -> Filename
show DocType
dtype Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/PDF") Filename
fn Format
TeX Document
d PrintingInformation
pinfo
                            DocSpec -> IO ()
prntMake (DocSpec -> IO ()) -> DocSpec -> IO ()
forall a b. (a -> b) -> a -> b
$ DocChoices -> Filename -> DocSpec
DocSpec (DocType -> [Format] -> DocChoices
DC DocType
dtype [Format
TeX]) Filename
fn
    Format
Jupyter           -> do DocType
-> Filename
-> Filename
-> Format
-> Document
-> PrintingInformation
-> IO ()
prntDoc' DocType
dtype (DocType -> Filename
forall a. Show a => a -> Filename
show DocType
dtype Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/Jupyter") Filename
fn Format
Jupyter Document
d PrintingInformation
pinfo
    Format
MDBook            -> do DocType
-> Filename
-> Filename
-> Format
-> Document
-> PrintingInformation
-> IO ()
prntDoc' DocType
dtype (DocType -> Filename
forall a. Show a => a -> Filename
show DocType
dtype Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/mdBook") Filename
fn Format
MDBook Document
d PrintingInformation
pinfo
                            DocSpec -> IO ()
prntMake (DocSpec -> IO ()) -> DocSpec -> IO ()
forall a b. (a -> b) -> a -> b
$ DocChoices -> Filename -> DocSpec
DocSpec (DocType -> [Format] -> DocChoices
DC DocType
dtype [Format
MDBook]) Filename
fn
                            DocType -> Document -> PrintingInformation -> IO ()
prntBook DocType
dtype Document
d PrintingInformation
pinfo
                            DocType -> PrintingInformation -> IO ()
prntCSV  DocType
dtype PrintingInformation
pinfo
    Format
_                 -> IO ()
forall a. Monoid a => a
mempty

-- | Helper function to produce an error when an incorrect SRS format is used. 
srsFormatError :: a
srsFormatError :: forall a. a
srsFormatError = Filename -> a
forall a. HasCallStack => Filename -> a
error Filename
"We can only write TeX/HTML/JSON/MDBook (for now)."

-- | Helper that takes the document type, directory name, document name, format of documents,
-- document information and printing information. Then generates the document file.
prntDoc' :: DocType -> String -> String -> Format -> Document -> PrintingInformation -> IO ()
prntDoc' :: DocType
-> Filename
-> Filename
-> Format
-> Document
-> PrintingInformation
-> IO ()
prntDoc' DocType
_ Filename
dt' Filename
_ Format
MDBook Document
body' PrintingInformation
sm = do
  Bool -> Filename -> IO ()
createDirectoryIfMissing Bool
True Filename
dir
  ((Filename, Doc) -> IO ()) -> [(Filename, Doc)] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Filename, Doc) -> IO ()
writeDocToFile [(Filename, Doc)]
con
  where 
    con :: [(Filename, Doc)]
con = PrintingInformation -> Format -> Document -> [(Filename, Doc)]
writeDoc' PrintingInformation
sm Format
MDBook Document
body'
    dir :: Filename
dir = Filename
dt' Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/src"
    writeDocToFile :: (Filename, Doc) -> IO ()
writeDocToFile (Filename
fp, Doc
d) = do
      Handle
outh <- Filename -> IOMode -> IO Handle
openFile (Filename
dir Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/" Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
fp Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
".md") IOMode
WriteMode
      Handle -> Filename -> IO ()
hPutStrLn Handle
outh (Filename -> IO ()) -> Filename -> IO ()
forall a b. (a -> b) -> a -> b
$ Doc -> Filename
render Doc
d
      Handle -> IO ()
hClose Handle
outh
prntDoc' DocType
dt Filename
dt' Filename
fn Format
format Document
body' PrintingInformation
sm = do
  Bool -> Filename -> IO ()
createDirectoryIfMissing Bool
True Filename
dt'
  Handle
outh <- Filename -> IOMode -> IO Handle
openFile (Filename
dt' Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/" Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
fn Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Format -> Filename
getExt Format
format) IOMode
WriteMode
  Handle -> Filename -> IO ()
hPutStrLn Handle
outh (Filename -> IO ()) -> Filename -> IO ()
forall a b. (a -> b) -> a -> b
$ Doc -> Filename
render (Doc -> Filename) -> Doc -> Filename
forall a b. (a -> b) -> a -> b
$ PrintingInformation
-> DocType -> Format -> Filename -> Document -> Doc
writeDoc PrintingInformation
sm DocType
dt Format
format Filename
fn Document
body'
  Handle -> IO ()
hClose Handle
outh
  where 
    -- | Gets extension for a particular format.
    -- MDBook case is handled above.
    getExt :: Format -> Filename
getExt  Format
TeX         = Filename
".tex"
    getExt  Format
HTML        = Filename
".html"
    getExt  Format
Jupyter     = Filename
".ipynb"
    getExt Format
_            = Filename
forall a. a
srsFormatError

-- | Helper for writing the Makefile(s).
prntMake :: DocSpec -> IO ()
prntMake :: DocSpec -> IO ()
prntMake ds :: DocSpec
ds@(DocSpec (DC DocType
dt [Format]
f) Filename
_) =
  do Handle
outh <- Filename -> IOMode -> IO Handle
openFile (DocType -> Filename
forall a. Show a => a -> Filename
show DocType
dt Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ [Format] -> Filename
dir [Format]
f Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/Makefile") IOMode
WriteMode
     Handle -> Filename -> IO ()
hPutStrLn Handle
outh (Filename -> IO ()) -> Filename -> IO ()
forall a b. (a -> b) -> a -> b
$ Doc -> Filename
render (Doc -> Filename) -> Doc -> Filename
forall a b. (a -> b) -> a -> b
$ [DocSpec] -> Doc
forall c. RuleTransformer c => [c] -> Doc
genMake [DocSpec
ds]
     Handle -> IO ()
hClose Handle
outh
  where
    dir :: [Format] -> Filename
dir [Format
TeX]    = Filename
"/PDF"
    dir [Format
MDBook] = Filename
"/mdBook"
    dir [Format]
_        = Filename -> Filename
forall a. HasCallStack => Filename -> a
error Filename
"Makefile(s) only supported for TeX/MDBook."

-- | Helper that creates a CSS file to accompany an HTML file.
-- Takes in the folder name, generated file name, and the document.
prntCSS :: DocType -> String -> Document -> IO ()
prntCSS :: DocType -> Filename -> Document -> IO ()
prntCSS DocType
docType Filename
fn Document
body = do
  Handle
outh2 <- Filename -> IOMode -> IO Handle
openFile (DocType -> Filename
forall a. Show a => a -> Filename
getFD DocType
docType Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
fn Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
".css") IOMode
WriteMode
  Handle -> Filename -> IO ()
hPutStrLn Handle
outh2 (Filename -> IO ()) -> Filename -> IO ()
forall a b. (a -> b) -> a -> b
$ Doc -> Filename
render (Document -> Doc
makeCSS Document
body)
  Handle -> IO ()
hClose Handle
outh2
  where
    getFD :: a -> Filename
getFD a
dtype = a -> Filename
forall a. Show a => a -> Filename
show a
dtype Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/HTML/"

-- | Helper for generating the .toml config file for mdBook.
prntBook :: DocType -> Document -> PrintingInformation -> IO()
prntBook :: DocType -> Document -> PrintingInformation -> IO ()
prntBook DocType
dt Document
doc PrintingInformation
sm = do
  Handle
outh <- Filename -> IOMode -> IO Handle
openFile Filename
fp IOMode
WriteMode
  Handle -> Filename -> IO ()
hPutStrLn Handle
outh (Filename -> IO ()) -> Filename -> IO ()
forall a b. (a -> b) -> a -> b
$ Doc -> Filename
render (Document -> PrintingInformation -> Doc
makeBook Document
doc PrintingInformation
sm)
  Handle -> IO ()
hClose Handle
outh
  where
    fp :: Filename
fp = DocType -> Filename
forall a. Show a => a -> Filename
show DocType
dt Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/mdBook/book.toml"

prntCSV :: DocType -> PrintingInformation -> IO()
prntCSV :: DocType -> PrintingInformation -> IO ()
prntCSV DocType
dt PrintingInformation
sm = do
  Handle
outh <- Filename -> IOMode -> IO Handle
openFile Filename
fp IOMode
WriteMode
  Handle -> Filename -> IO ()
hPutStrLn Handle
outh (Filename -> IO ()) -> Filename -> IO ()
forall a b. (a -> b) -> a -> b
$ Doc -> Filename
render (PrintingInformation -> Doc
makeRequirements PrintingInformation
sm)
  Handle -> IO ()
hClose Handle
outh
  where
    fp :: Filename
fp = DocType -> Filename
forall a. Show a => a -> Filename
show DocType
dt Filename -> Filename -> Filename
forall a. [a] -> [a] -> [a]
++ Filename
"/mdBook/.drasil-requirements.csv"

-- | Renders single-page documents.
writeDoc :: PrintingInformation -> DocType -> Format -> Filename -> Document -> Doc
writeDoc :: PrintingInformation
-> DocType -> Format -> Filename -> Document -> Doc
writeDoc PrintingInformation
s DocType
_  Format
TeX               Filename
_  Document
doc = Document -> PrintingInformation -> Doc
genTeX Document
doc PrintingInformation
s
writeDoc PrintingInformation
s DocType
_  Format
HTML              Filename
fn Document
doc = PrintingInformation -> Filename -> Document -> Doc
genHTML PrintingInformation
s Filename
fn Document
doc
writeDoc PrintingInformation
s DocType
dt Format
Jupyter           Filename
_  Document
doc = PrintingInformation -> DocType -> Document -> Doc
genJupyter PrintingInformation
s DocType
dt Document
doc
writeDoc PrintingInformation
_ DocType
_  Format
_                 Filename
_  Document
_   = Doc
forall a. a
srsFormatError

-- | Renders multi-page documents.
writeDoc' :: PrintingInformation -> Format -> Document -> [(Filename, Doc)]
writeDoc' :: PrintingInformation -> Format -> Document -> [(Filename, Doc)]
writeDoc' PrintingInformation
s Format
MDBook Document
doc = PrintingInformation -> Document -> [(Filename, Doc)]
genMDBook PrintingInformation
s Document
doc
writeDoc' PrintingInformation
_ Format
_      Document
_   = [(Filename, Doc)]
forall a. a
srsFormatError

-- | Generates traceability graphs as .dot files.
genDot :: SystemInformation -> IO ()
genDot :: SystemInformation -> IO ()
genDot SystemInformation
si = do
    Filename
workingDir <- IO Filename
getCurrentDirectory
    let gi :: GraphInfo
gi = SystemInformation -> GraphInfo
mkGraphInfo SystemInformation
si
    Filename -> GraphInfo -> IO ()
outputDot Filename
"TraceyGraph" GraphInfo
gi
    Filename -> IO ()
setCurrentDirectory Filename
workingDir

-- | Calls the code generator.
genCode :: Choices -> CodeSpec -> IO ()
genCode :: Choices -> CodeSpec -> IO ()
genCode Choices
chs CodeSpec
spec = do
  Filename
workingDir <- IO Filename
getCurrentDirectory
  UTCTime
time <- IO UTCTime
getCurrentTime
  [Expr]
sampData <- IO [Expr] -> (Filename -> IO [Expr]) -> Maybe Filename -> IO [Expr]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([Expr] -> IO [Expr]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return []) (\Filename
sd -> Filename -> DataDesc' -> IO [Expr]
readWithDataDesc Filename
sd (DataDesc' -> IO [Expr]) -> DataDesc' -> IO [Expr]
forall a b. (a -> b) -> a -> b
$ [CodeVarChunk] -> DataDesc'
sampleInputDD
    (CodeSpec
spec CodeSpec
-> Getting [CodeVarChunk] CodeSpec [CodeVarChunk] -> [CodeVarChunk]
forall s a. s -> Getting a s a -> a
^. Getting [CodeVarChunk] CodeSpec [CodeVarChunk]
forall c. HasOldCodeSpec c => Lens' c [CodeVarChunk]
Lens' CodeSpec [CodeVarChunk]
extInputsO)) (Choices -> Maybe Filename
getSampleData Choices
chs)
  Bool -> Filename -> IO ()
createDirectoryIfMissing Bool
False Filename
"src"
  Filename -> IO ()
setCurrentDirectory Filename
"src"
  let genLangCode :: Lang -> IO ()
genLangCode Lang
Java = Lang
-> (JavaCode (Program JavaCode) -> ProgData)
-> (JavaProject (Package JavaProject) -> PackData)
-> IO ()
forall {progRepr :: * -> *} {packRepr :: * -> *}.
(OOProg progRepr, PackageSym packRepr) =>
Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> IO ()
genCall Lang
Java JavaCode ProgData -> ProgData
JavaCode (Program JavaCode) -> ProgData
forall a. JavaCode a -> a
unJC JavaProject PackData -> PackData
JavaProject (Package JavaProject) -> PackData
forall a. JavaProject a -> a
unJP
      genLangCode Lang
Python = Lang
-> (PythonCode (Program PythonCode) -> ProgData)
-> (PythonProject (Package PythonProject) -> PackData)
-> IO ()
forall {progRepr :: * -> *} {packRepr :: * -> *}.
(OOProg progRepr, PackageSym packRepr) =>
Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> IO ()
genCall Lang
Python PythonCode ProgData -> ProgData
PythonCode (Program PythonCode) -> ProgData
forall a. PythonCode a -> a
unPC PythonProject PackData -> PackData
PythonProject (Package PythonProject) -> PackData
forall a. PythonProject a -> a
unPP
      genLangCode Lang
CSharp = Lang
-> (CSharpCode (Program CSharpCode) -> ProgData)
-> (CSharpProject (Package CSharpProject) -> PackData)
-> IO ()
forall {progRepr :: * -> *} {packRepr :: * -> *}.
(OOProg progRepr, PackageSym packRepr) =>
Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> IO ()
genCall Lang
CSharp CSharpCode ProgData -> ProgData
CSharpCode (Program CSharpCode) -> ProgData
forall a. CSharpCode a -> a
unCSC CSharpProject PackData -> PackData
CSharpProject (Package CSharpProject) -> PackData
forall a. CSharpProject a -> a
unCSP
      genLangCode Lang
Cpp = Lang
-> (CppCode
      CppSrcCode CppHdrCode (Program (CppCode CppSrcCode CppHdrCode))
    -> ProgData)
-> (CppProject (Package CppProject) -> PackData)
-> IO ()
forall {progRepr :: * -> *} {packRepr :: * -> *}.
(OOProg progRepr, PackageSym packRepr) =>
Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> IO ()
genCall Lang
Cpp CppCode CppSrcCode CppHdrCode ProgData -> ProgData
CppCode
  CppSrcCode CppHdrCode (Program (CppCode CppSrcCode CppHdrCode))
-> ProgData
forall a. CppCode CppSrcCode CppHdrCode a -> a
unCPPC CppProject PackData -> PackData
CppProject (Package CppProject) -> PackData
forall a. CppProject a -> a
unCPPP
      genLangCode Lang
Swift = Lang
-> (SwiftCode (Program SwiftCode) -> ProgData)
-> (SwiftProject (Package SwiftProject) -> PackData)
-> IO ()
forall {progRepr :: * -> *} {packRepr :: * -> *}.
(OOProg progRepr, PackageSym packRepr) =>
Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> IO ()
genCall Lang
Swift SwiftCode ProgData -> ProgData
SwiftCode (Program SwiftCode) -> ProgData
forall a. SwiftCode a -> a
unSC SwiftProject PackData -> PackData
SwiftProject (Package SwiftProject) -> PackData
forall a. SwiftProject a -> a
unSP
      genLangCode Lang
Julia = Lang
-> (JuliaCode (Program JuliaCode) -> ProgData)
-> (JuliaProject (Package JuliaProject) -> PackData)
-> IO ()
forall {progRepr :: * -> *} {packRepr :: * -> *}.
(ProcProg progRepr, PackageSym packRepr) =>
Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> IO ()
genCallProc Lang
Julia JuliaCode ProgData -> ProgData
JuliaCode (Program JuliaCode) -> ProgData
forall a. JuliaCode a -> a
unJLC JuliaProject PackData -> PackData
JuliaProject (Package JuliaProject) -> PackData
forall a. JuliaProject a -> a
unJLP
      genCall :: Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> IO ()
genCall Lang
lng progRepr (Program progRepr) -> ProgData
unProgRepr packRepr (Package packRepr) -> PackData
unPackRepr = Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> DrasilState
-> IO ()
forall (progRepr :: * -> *) (packRepr :: * -> *).
(OOProg progRepr, PackageSym packRepr) =>
Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> DrasilState
-> IO ()
generateCode Lang
lng progRepr (Program progRepr) -> ProgData
unProgRepr
        packRepr (Package packRepr) -> PackData
unPackRepr (DrasilState -> IO ()) -> DrasilState -> IO ()
forall a b. (a -> b) -> a -> b
$ Lang -> Filename -> [Expr] -> Choices -> CodeSpec -> DrasilState
generator Lang
lng (Day -> Filename
showGregorian (Day -> Filename) -> Day -> Filename
forall a b. (a -> b) -> a -> b
$ UTCTime -> Day
utctDay UTCTime
time) [Expr]
sampData Choices
chs CodeSpec
spec
      genCallProc :: Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> IO ()
genCallProc Lang
lng progRepr (Program progRepr) -> ProgData
unProgRepr packRepr (Package packRepr) -> PackData
unPackRepr = Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> DrasilState
-> IO ()
forall (progRepr :: * -> *) (packRepr :: * -> *).
(ProcProg progRepr, PackageSym packRepr) =>
Lang
-> (progRepr (Program progRepr) -> ProgData)
-> (packRepr (Package packRepr) -> PackData)
-> DrasilState
-> IO ()
generateCodeProc Lang
lng progRepr (Program progRepr) -> ProgData
unProgRepr
        packRepr (Package packRepr) -> PackData
unPackRepr (DrasilState -> IO ()) -> DrasilState -> IO ()
forall a b. (a -> b) -> a -> b
$ Lang -> Filename -> [Expr] -> Choices -> CodeSpec -> DrasilState
generator Lang
lng (Day -> Filename
showGregorian (Day -> Filename) -> Day -> Filename
forall a b. (a -> b) -> a -> b
$ UTCTime -> Day
utctDay UTCTime
time) [Expr]
sampData Choices
chs CodeSpec
spec
  (Lang -> IO ()) -> [Lang] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Lang -> IO ()
genLangCode (Choices -> [Lang]
lang Choices
chs)
  Filename -> IO ()
setCurrentDirectory Filename
workingDir

-- | Constructor for users to choose their document options
docChoices :: DocType -> [Format] -> DocChoices
docChoices :: DocType -> [Format] -> DocChoices
docChoices = DocType -> [Format] -> DocChoices
DC