module Drasil.DocumentLanguage.Notebook
(mkNb, LsnDesc, LsnChapter(..), LearnObj(..), Review(..), CaseProb(..), Example(..)
) where
import Control.Lens ((^.))
import Drasil.DocumentLanguage.Notebook.Core (LsnDesc, LsnChapter(..),
Intro(..), LearnObj(..), Review(..), CaseProb(..), Example(..), Smmry(..), Apndx(..))
import Language.Drasil (IdeaDict, Sentence(S), Section, CI, Document(Notebook), BibRef,
foldlList, SepType(Comma), FoldType(List), name, Contents(UlC), ulcc, RawContent(Bib))
import Drasil.System (System(SI), _authors, whatsTheBigIdea, sysName)
import Drasil.GetChunks (citeDB)
import qualified Drasil.DocLang.Notebook as Lsn (intro, learnObj, caseProb, example,
appendix, review, reference, summary)
mkNb :: LsnDesc -> (IdeaDict -> CI -> Sentence) -> System -> Document
mkNb :: LsnDesc -> (IdeaDict -> CI -> Sentence) -> System -> Document
mkNb LsnDesc
dd IdeaDict -> CI -> Sentence
comb si :: System
si@SI { _authors :: System -> People
_authors = People
authors } =
Sentence -> Sentence -> [Section] -> Document
Notebook (System -> IdeaDict
whatsTheBigIdea System
si IdeaDict -> CI -> Sentence
`comb` (System
si System -> Getting CI System CI -> CI
forall s a. s -> Getting a s a -> a
^. Getting CI System CI
forall c. HasSystem c => Lens' c CI
Lens' System CI
sysName)) (SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List ([Sentence] -> Sentence) -> [Sentence] -> Sentence
forall a b. (a -> b) -> a -> b
$ (Person -> Sentence) -> People -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Sentence
S (String -> Sentence) -> (Person -> String) -> Person -> Sentence
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Person -> String
forall n. HasName n => n -> String
name) People
authors) ([Section] -> Document) -> [Section] -> Document
forall a b. (a -> b) -> a -> b
$
System -> LsnDesc -> [Section]
mkSections System
si LsnDesc
dd
mkSections :: System -> LsnDesc -> [Section]
mkSections :: System -> LsnDesc -> [Section]
mkSections System
si = (LsnChapter -> Section) -> LsnDesc -> [Section]
forall a b. (a -> b) -> [a] -> [b]
map LsnChapter -> Section
doit
where
doit :: LsnChapter -> Section
doit :: LsnChapter -> Section
doit (Intro Intro
i) = Intro -> Section
mkIntro Intro
i
doit (LearnObj LearnObj
lo) = LearnObj -> Section
mkLearnObj LearnObj
lo
doit (Review Review
r) = Review -> Section
mkReview Review
r
doit (CaseProb CaseProb
cp) = CaseProb -> Section
mkCaseProb CaseProb
cp
doit (Example Example
e) = Example -> Section
mkExample Example
e
doit (Smmry Smmry
s) = Smmry -> Section
mkSmmry Smmry
s
doit LsnChapter
BibSec = BibRef -> Section
mkBib (System -> BibRef
citeDB System
si)
doit (Apndx Apndx
a) = Apndx -> Section
mkAppndx Apndx
a
mkIntro :: Intro -> Section
mkIntro :: Intro -> Section
mkIntro (IntrodProg [Contents]
i) = [Contents] -> [Section] -> Section
Lsn.intro [Contents]
i []
mkLearnObj :: LearnObj -> Section
mkLearnObj :: LearnObj -> Section
mkLearnObj (LrnObjProg [Contents]
cs) = [Contents] -> [Section] -> Section
Lsn.learnObj [Contents]
cs []
mkReview :: Review -> Section
mkReview :: Review -> Section
mkReview (ReviewProg [Contents]
r) = [Contents] -> [Section] -> Section
Lsn.review [Contents]
r []
mkCaseProb :: CaseProb -> Section
mkCaseProb :: CaseProb -> Section
mkCaseProb (CaseProbProg [Contents]
cp) = [Contents] -> [Section] -> Section
Lsn.caseProb [Contents]
cp []
mkExample:: Example -> Section
mkExample :: Example -> Section
mkExample (ExampleProg [Contents]
cs) = [Contents] -> [Section] -> Section
Lsn.example [Contents]
cs []
mkSmmry :: Smmry -> Section
mkSmmry :: Smmry -> Section
mkSmmry (SmmryProg [Contents]
cs) = [Contents] -> [Section] -> Section
Lsn.summary [Contents]
cs []
mkBib :: BibRef -> Section
mkBib :: BibRef -> Section
mkBib BibRef
bib = [Contents] -> [Section] -> Section
Lsn.reference [UnlabelledContent -> Contents
UlC (UnlabelledContent -> Contents) -> UnlabelledContent -> Contents
forall a b. (a -> b) -> a -> b
$ RawContent -> UnlabelledContent
ulcc (BibRef -> RawContent
Bib BibRef
bib)] []
mkAppndx :: Apndx -> Section
mkAppndx :: Apndx -> Section
mkAppndx (ApndxProg [Contents]
cs) = [Contents] -> [Section] -> Section
Lsn.appendix [Contents]
cs []