-- | Defines helper functions for making the Table of Auxiliary Constants section.
module Drasil.Sections.AuxiliaryConstants 
  (valsOfAuxConstantsF, tableOfConstants, tableOfConstantsRef) where

import Language.Drasil
import qualified Drasil.DocLang.SRS as SRS (valsOfAuxCons)
import Drasil.DocumentLanguage.Units (toSentence)
import Data.Drasil.Concepts.Documentation (value, description, symbol_, tAuxConsts)
import qualified Data.Drasil.Concepts.Math as CM (unit_)
import Control.Lens ((^.))
import Drasil.Sections.ReferenceMaterial (emptySectSentPlu)

-- | Gets the auxiliary constant values given an introductory 'Idea' and a 'QDefinition'.
valsOfAuxConstantsF :: Idea a => a -> [ConstQDef] -> Section
valsOfAuxConstantsF :: forall a. Idea a => a -> [QDefinition Literal] -> Section
valsOfAuxConstantsF a
kWord [QDefinition Literal]
listOfConstants = [Contents] -> [Section] -> Section
SRS.valsOfAuxCons (forall a. Idea a => a -> [QDefinition Literal] -> [Contents]
contentGenerator a
kWord [QDefinition Literal]
listOfConstants)  []

-- | Gets a table of constants from a 'QDefinition'. Also uses an 'Idea' as the introduction.
contentGenerator :: Idea a => a -> [ConstQDef] -> [Contents]
contentGenerator :: forall a. Idea a => a -> [QDefinition Literal] -> [Contents]
contentGenerator a
_ [] = [Sentence -> Contents
mkParagraph forall a b. (a -> b) -> a -> b
$ forall n. NamedIdea n => [n] -> Sentence
emptySectSentPlu [IdeaDict
tAuxConsts]]
contentGenerator a
a [QDefinition Literal]
b  = [forall a. Idea a => a -> Contents
intro a
a, LabelledContent -> Contents
LlC forall a b. (a -> b) -> a -> b
$ [QDefinition Literal] -> LabelledContent
tableOfConstants [QDefinition Literal]
b]

--FIXME: general introduction?
-- | Helper that creates a general introduction using an 'Idea'.
intro :: (Idea a) => a -> Contents
intro :: forall a. Idea a => a -> Contents
intro a
kWord = [Sentence] -> Contents
foldlSP [String -> Sentence
S String
"This section contains the standard values that are used for calculations in" Sentence -> Sentence -> Sentence
+:+ forall c. Idea c => c -> Sentence
short a
kWord]

-- | Helper that gets a table of constants from a 'QDefinition'.
tableOfConstants :: [ConstQDef] -> LabelledContent
tableOfConstants :: [QDefinition Literal] -> LabelledContent
tableOfConstants [QDefinition Literal]
f = Reference -> RawContent -> LabelledContent
llcc Reference
tableOfConstantsRef forall a b. (a -> b) -> a -> b
$ [Sentence] -> [[Sentence]] -> Sentence -> Bool -> RawContent
Table
  [forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
symbol_, forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
description, forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
value, forall n. NamedIdea n => n -> Sentence
titleize ConceptChunk
CM.unit_]
  (forall a b. [a -> b] -> [a] -> [[b]]
mkTable [forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch, forall n. NamedIdea n => n -> Sentence
phrase, \QDefinition Literal
c -> ModelExpr -> Sentence
eS forall a b. (a -> b) -> a -> b
$ forall c. Express c => c -> ModelExpr
express forall a b. (a -> b) -> a -> b
$ QDefinition Literal
c forall s a. s -> Getting a s a -> a
^. forall (c :: * -> *) e. DefiningExpr c => Lens' (c e) e
defnExpr, forall u. MayHaveUnit u => u -> Sentence
toSentence] [QDefinition Literal]
f)
  (forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
tAuxConsts)
  Bool
True

-- | Table of constants reference label.
tableOfConstantsRef :: Reference
tableOfConstantsRef :: Reference
tableOfConstantsRef = UID -> Reference
makeTabRef' (IdeaDict
tAuxConsts forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid)