packages feed

casa-reoc-0.1.0.0: src/ReOC/Render/TrainingManual.hs

{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wall #-}

{- | The RePL training manual of a 'ReOC' with RePL training, as Flat ODF text:
the documented practices and procedures of RePL training, the syllabus and
curriculum of each course, lesson plans and content, the examinations,
worksheets, flight test sheets and the handbooks (CASA Form 101-02, question
30, items 3 to 12).

The manual is the shell @template/repl-training-manual.fodt@ (the styles,
cover and master pages of the operations manual), with its body from the
marked-up text @template/repl-training-manual.md@ (see
"ReOC.Render.TrainingManual.Body"). Both are read when the package is
compiled.
-}
module ReOC.Render.TrainingManual (
  renderTrainingManual,
) where

import Data.Text (Text)
import qualified Data.Text as Text
import ReOC.Model
import ReOC.Render.Template (embedTemplate)
import ReOC.Render.Text (get)
import ReOC.Render.TrainingManual.Body (holeBody, holeContents)
import ReOC.Render.TrainingManual.Holes

shell :: [Either Text (ReOC -> Text)]
shell =
  $(embedTemplate "template/repl-training-manual.fodt")

-- | The RePL training manual, if RePL training is applied for.
renderTrainingManual :: ReOC -> Maybe Text
renderTrainingManual r =
  (\_ -> Text.concat (map (either id ($ r)) shell)) <$> get maybeTrainingMaterial r