{-# LANGUAGE QuasiQuotes #-}
module Drasil.Generator.LessonPlan
( genJupyterLessonPlan,
)
where
import Control.Lens ((^.))
import Drasil.FileHandling (FileLayout, file, ps)
import Drasil.LessonPlan (LsnDesc, mkNb)
import Language.Drasil (Stage (Equational))
import Language.Drasil.Printers (Notation (Engineering), piSys)
import qualified Language.Drasil.Printers as P (genJupyterLessonPlan)
import Language.Drasil.Printing.Import (makeDocument)
import qualified Language.Drasil.Sentence.Combinators as S
import Drasil.System (LessonPlan, lsnPlanRefs, systemdb)
genJupyterLessonPlan :: LessonPlan -> LsnDesc -> String -> FileLayout
genJupyterLessonPlan :: LessonPlan -> LsnDesc -> String -> FileLayout
genJupyterLessonPlan LessonPlan
plan LsnDesc
nbDecl String
lsnFileName =
PathSegment -> Doc -> FileLayout
forall doc. Writeable doc => PathSegment -> doc -> FileLayout
file [ps|{lsnFileName}.ipynb|] (Doc -> FileLayout) -> Doc -> FileLayout
forall a b. (a -> b) -> a -> b
$ Document -> Doc
P.genJupyterLessonPlan Document
pd
where
nb :: Document
nb = LessonPlan -> LsnDesc -> (CI -> CI -> Sentence) -> Document
mkNb LessonPlan
plan LsnDesc
nbDecl CI -> CI -> Sentence
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> Sentence
S.forT
printSetting :: PrintingInformation
printSetting = ChunkDB
-> Map UID Reference -> Stage -> Notation -> PrintingInformation
piSys (LessonPlan
plan LessonPlan -> Getting ChunkDB LessonPlan ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB LessonPlan ChunkDB
forall c. HasSystemMeta c => Lens' c ChunkDB
Lens' LessonPlan ChunkDB
systemdb) (LessonPlan
plan LessonPlan
-> Getting (Map UID Reference) LessonPlan (Map UID Reference)
-> Map UID Reference
forall s a. s -> Getting a s a -> a
^. Getting (Map UID Reference) LessonPlan (Map UID Reference)
Lens' LessonPlan (Map UID Reference)
lsnPlanRefs) Stage
Equational Notation
Engineering
pd :: Document
pd = PrintingInformation -> Document -> Document
makeDocument PrintingInformation
printSetting Document
nb