{-# Language TupleSections #-}
-- | Standard code to make a table of contents.
module Drasil.Sections.TableOfContents (toToC, findToC) where

import Language.Drasil
import Drasil.DocumentLanguage.Core
import Language.Drasil.Chunk.Concept.NamedCombinators
import qualified Drasil.DocLang.SRS as SRS
import qualified Data.Drasil.Concepts.Documentation as Doc
import qualified Data.Drasil.TheoryConcepts as Doc (dataDefn, genDefn, inModel, thModel)

{- Layout for Table of Contents in SRS documents:
Table of Contents
Reference Material
  Table of Units
  Table of Symbols
  Table of Abbreviations and Acronyms
Instroduction
  Purpose of Document
  Scope of Requirements
  Characteristics of Intended Reader
  Organization of Document
Stakeholders
  The Client
  The Customer
General System Description
  System Context
  User Characteristics
  System Constraints
Specific System Description
  Problem Description
    Termonology and definitions
    Physical System Description
    Goal Statements
  Solution Characteristics Specification
    Assumptions
    Theoretical Models
    General Definitions
    Data Definitions
    Instance Models
    Data Constraints
    Properties of a Correct Solution
Requirements
  Functional Requirements
  Non-Functional Requirements
Likely Changes
Unlikely Changes
Traceability Matrices and Graphs
Values of Auxiliary Constants
References
Appendix

Other refs not used but still defined:
product use case
scope of the project
use case table
off the shelf solutions
-}

-- TODO: Use DLPlate for this.
-- | Finds all possible sections and subsections to make a Table of Contents.
toToC :: DocSection -> ItemType
toToC :: DocSection -> ItemType
toToC DocSection
TableOfContents      = ItemType
mktToCSec
toToC (RefSec RefSec
rs)          = RefSec -> ItemType
mktRefSec RefSec
rs
toToC (IntroSec IntroSec
i)         = IntroSec -> ItemType
mktIntroSec IntroSec
i
toToC (StkhldrSec StkhldrSec
sts)     = StkhldrSec -> ItemType
mktStkhldrSec StkhldrSec
sts
toToC (GSDSec GSDSec
gs')         = GSDSec -> ItemType
mktGSDSec GSDSec
gs'
toToC (SSDSec SSDSec
ss)          = SSDSec -> ItemType
mktSSDSec SSDSec
ss
toToC (ReqrmntSec ReqrmntSec
r)       = ReqrmntSec -> ItemType
mktReqrmntSec ReqrmntSec
r
toToC (LCsSec LCsSec
lc)          = LCsSec -> ItemType
mktLCsSec LCsSec
lc
toToC (UCsSec UCsSec
ulcs)        = UCsSec -> ItemType
mktUCsSec UCsSec
ulcs
toToC (TraceabilitySec TraceabilitySec
t)  = TraceabilitySec -> ItemType
mktTraceabilitySec TraceabilitySec
t
toToC (AuxConstntSec AuxConstntSec
acs)  = AuxConstntSec -> ItemType
mktAuxConsSec AuxConstntSec
acs
toToC DocSection
Bibliography         = ItemType
mktBib
toToC (AppndxSec AppndxSec
a)        = AppndxSec -> ItemType
mktAppndxSec AppndxSec
a
toToC (OffShelfSolnsSec OffShelfSolnsSec
o) = OffShelfSolnsSec -> ItemType
mktOffShelfSolnSec OffShelfSolnsSec
o

mkHeaderItem :: Sentence -> [Sentence] -> ItemType
mkHeaderItem :: Sentence -> [Sentence] -> ItemType
mkHeaderItem Sentence
hdr [Sentence]
itm = Sentence -> ListType -> ItemType
Nested Sentence
hdr (ListType -> ItemType) -> ListType -> ItemType
forall a b. (a -> b) -> a -> b
$ [(ItemType, Maybe String)] -> ListType
Bullet ([(ItemType, Maybe String)] -> ListType)
-> [(ItemType, Maybe String)] -> ListType
forall a b. (a -> b) -> a -> b
$ (Sentence -> (ItemType, Maybe String))
-> [Sentence] -> [(ItemType, Maybe String)]
forall a b. (a -> b) -> [a] -> [b]
map (\Sentence
x -> (Sentence -> ItemType
Flat Sentence
x, Maybe String
forall a. Maybe a
Nothing)) [Sentence]
itm
mkHeaderItem' :: Sentence -> [ItemType] -> ItemType
mkHeaderItem' :: Sentence -> [ItemType] -> ItemType
mkHeaderItem' Sentence
hdr [ItemType]
itm = Sentence -> ListType -> ItemType
Nested Sentence
hdr (ListType -> ItemType) -> ListType -> ItemType
forall a b. (a -> b) -> a -> b
$ [(ItemType, Maybe String)] -> ListType
Bullet ([(ItemType, Maybe String)] -> ListType)
-> [(ItemType, Maybe String)] -> ListType
forall a b. (a -> b) -> a -> b
$ (ItemType -> (ItemType, Maybe String))
-> [ItemType] -> [(ItemType, Maybe String)]
forall a b. (a -> b) -> [a] -> [b]
map (, Maybe String
forall a. Maybe a
Nothing) [ItemType]
itm

-- | Helper for creating the 'Table of Contents' section ToC entry
mktToCSec :: ItemType
mktToCSec :: ItemType
mktToCSec = Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.tOfContLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.tOfCont

-- | Helper for creating the 'Reference Material' section ToC entry
mktRefSec :: RefSec -> ItemType
mktRefSec :: RefSec -> ItemType
mktRefSec (RefProg Contents
_ [RefTab]
l) =
  Sentence -> [Sentence] -> ItemType
mkHeaderItem (Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.refMatLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
Doc.refMat) ([Sentence] -> ItemType) -> [Sentence] -> ItemType
forall a b. (a -> b) -> a -> b
$ (RefTab -> Sentence) -> [RefTab] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map RefTab -> Sentence
mktSubRef [RefTab]
l
  where
    mktSubRef :: RefTab -> Sentence
    mktSubRef :: RefTab -> Sentence
mktSubRef RefTab
TUnits        = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.tOfUnitLabel   (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.tOfUnit
    mktSubRef (TUnits' [TUIntro]
_ [UnitDefn] -> LabelledContent
_) = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.tOfUnitLabel   (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.tOfUnit
    mktSubRef (TSymb [TSIntro]
_)     = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.tOfSymbLabel   (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.tOfSymb
    mktSubRef (TSymb' LFunc
_ [TSIntro]
_)  = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.tOfSymbLabel   (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.tOfSymb
    mktSubRef RefTab
TAandA        = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.tOfAbbAccLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.abbAcc

-- | Helper for creating the 'Introduction' section ToC entry
mktIntroSec :: IntroSec -> ItemType
mktIntroSec :: IntroSec -> ItemType
mktIntroSec (IntroProg Sentence
_ Sentence
_ [IntroSub]
l) =
  Sentence -> [Sentence] -> ItemType
mkHeaderItem (Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.introLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
Doc.introduction) ([Sentence] -> ItemType) -> [Sentence] -> ItemType
forall a b. (a -> b) -> a -> b
$ (IntroSub -> Sentence) -> [IntroSub] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map IntroSub -> Sentence
mktSubIntro [IntroSub]
l
  where
    mktSubIntro :: IntroSub -> Sentence
    mktSubIntro :: IntroSub -> Sentence
mktSubIntro (IPurpose [Sentence]
_) = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.docPurposeLabel  (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
Doc.prpsOfDoc
    mktSubIntro (IScope Sentence
_)   = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.reqsScopeLabel   (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.scpOfReq
    mktSubIntro IChar {}     = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.readerCharsLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.charOfIR
    mktSubIntro IOrgSec {}   = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.docOrgLabel      (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
Doc.orgOfDoc

-- | Helper for creating the 'Stakeholders' section ToC entry
mktStkhldrSec:: StkhldrSec -> ItemType
mktStkhldrSec :: StkhldrSec -> ItemType
mktStkhldrSec (StkhldrProg [StkhldrSub]
l) =
  Sentence -> [Sentence] -> ItemType
mkHeaderItem (Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.stakeholderLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.stakeholder) ([Sentence] -> ItemType) -> [Sentence] -> ItemType
forall a b. (a -> b) -> a -> b
$ (StkhldrSub -> Sentence) -> [StkhldrSub] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map StkhldrSub -> Sentence
mktSub [StkhldrSub]
l
  where
    mktSub :: StkhldrSub -> Sentence
    mktSub :: StkhldrSub -> Sentence
mktSub (Client CI
_ Sentence
_) = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.customerLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ NP -> Sentence
forall n. NounPhrase n => n -> Sentence
titleizeNP (NP -> Sentence) -> NP -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> NP
forall t. NamedIdea t => t -> NP
the IdeaDict
Doc.customer
    mktSub (Cstmr CI
_)    = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.clientLabel   (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ NP -> Sentence
forall n. NounPhrase n => n -> Sentence
titleizeNP (NP -> Sentence) -> NP -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> NP
forall t. NamedIdea t => t -> NP
the IdeaDict
Doc.client

-- | Helper for creating the 'General System Description' section ToC entry
mktGSDSec :: GSDSec -> ItemType
mktGSDSec :: GSDSec -> ItemType
mktGSDSec (GSDProg [GSDSub]
l) =
  Sentence -> [Sentence] -> ItemType
mkHeaderItem (Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.genSysDescLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
Doc.generalSystemDescription) ([Sentence] -> ItemType) -> [Sentence] -> ItemType
forall a b. (a -> b) -> a -> b
$ (GSDSub -> Sentence) -> [GSDSub] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map GSDSub -> Sentence
mktSub [GSDSub]
l
  where
    mktSub :: GSDSub -> Sentence
    mktSub :: GSDSub -> Sentence
mktSub (SysCntxt [Contents]
_)   = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.sysContextLabel     (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize  IdeaDict
Doc.sysCont
    mktSub (UsrChars [Contents]
_)   = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.userCharsLabel      (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.userCharacteristic
    mktSub (SystCons [Contents]
_ [Section]
_) = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.sysConstraintsLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.systemConstraint

-- | Helper for creating the 'Specific System Description' section ToC entry
mktSSDSec :: SSDSec -> ItemType
mktSSDSec :: SSDSec -> ItemType
mktSSDSec (SSDProg [SSDSub]
l) =
  Sentence -> [ItemType] -> ItemType
mkHeaderItem' (Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.specSystDescLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
Doc.specificsystemdescription) ([ItemType] -> ItemType) -> [ItemType] -> ItemType
forall a b. (a -> b) -> a -> b
$ (SSDSub -> ItemType) -> [SSDSub] -> [ItemType]
forall a b. (a -> b) -> [a] -> [b]
map SSDSub -> ItemType
mktSubSSD [SSDSub]
l
  where
    mktSubSSD :: SSDSub -> ItemType
    mktSubSSD :: SSDSub -> ItemType
mktSubSSD (SSDProblem (PDProg Sentence
_ [Section]
_ [PDSub]
sl1)) = Sentence -> [Sentence] -> ItemType
mkHeaderItem (Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.probDescLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
Doc.problemDescription) ([Sentence] -> ItemType) -> [Sentence] -> ItemType
forall a b. (a -> b) -> a -> b
$ (PDSub -> Sentence) -> [PDSub] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map PDSub -> Sentence
mktSubPD [PDSub]
sl1
    mktSubSSD (SSDSolChSpec (SCSProg [SCSSub]
sl2))  = Sentence -> [Sentence] -> ItemType
mkHeaderItem (Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.solCharSpecLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
Doc.solutionCharSpec) ([Sentence] -> ItemType) -> [Sentence] -> ItemType
forall a b. (a -> b) -> a -> b
$ (SCSSub -> Sentence) -> [SCSSub] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map SCSSub -> Sentence
mktSubSCS [SCSSub]
sl2

    mktSubPD :: PDSub -> Sentence
    mktSubPD :: PDSub -> Sentence
mktSubPD (TermsAndDefs Maybe Sentence
_ [c]
_) = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.termDefsLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.termAndDef
    mktSubPD PhySysDesc {}      = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.physSystLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize  CI
Doc.physSyst
    mktSubPD (Goals [Sentence]
_ [ConceptInstance]
_)        = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.goalStmtLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.goalStmt

    mktSubSCS :: SCSSub -> Sentence
    mktSubSCS :: SCSSub -> Sentence
mktSubSCS (Assumptions [ConceptInstance]
_)      = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.assumptLabel     (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.assumption
    mktSubSCS TMs {}               = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.thModelLabel     (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.thModel
    mktSubSCS GDs {}               = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.genDefnLabel     (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.genDefn
    mktSubSCS DDs {}               = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.dataDefnLabel    (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.dataDefn
    mktSubSCS IMs {}               = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.inModelLabel     (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.inModel
    mktSubSCS (Constraints Sentence
_ [c]
_)    = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.datConLabel      (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.datumConstraint
    mktSubSCS (CorrSolnPpties [c]
_ [Contents]
_) = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.corSolPropsLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.propOfCorSol

-- | Helper for creating the 'Requirements' section ToC entry
mktReqrmntSec :: ReqrmntSec -> ItemType
mktReqrmntSec :: ReqrmntSec -> ItemType
mktReqrmntSec (ReqsProg [ReqsSub]
l) =
  Sentence -> [Sentence] -> ItemType
mkHeaderItem (Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.requirementsLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.requirement) ([Sentence] -> ItemType) -> [Sentence] -> ItemType
forall a b. (a -> b) -> a -> b
$ (ReqsSub -> Sentence) -> [ReqsSub] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map ReqsSub -> Sentence
mktSubs [ReqsSub]
l
  where
    mktSubs :: ReqsSub -> Sentence
    mktSubs :: ReqsSub -> Sentence
mktSubs (FReqsSub' [ConceptInstance]
_ [LabelledContent]
_) = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.funcReqLabel    (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.functionalRequirement
    mktSubs (FReqsSub [ConceptInstance]
_ [LabelledContent]
_)  = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.funcReqLabel    (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.functionalRequirement
    mktSubs (NonFReqsSub [ConceptInstance]
_) = Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.nonfuncReqLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.nonfunctionalRequirement

-- | Helper for creating the 'Likely Changes' section ToC entry
mktLCsSec :: LCsSec -> ItemType
mktLCsSec :: LCsSec -> ItemType
mktLCsSec (LCsProg [ConceptInstance]
_) = Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.likeChgLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.likelyChg

-- | Helper for creating the 'Unlikely Changes' section ToC entry
mktUCsSec :: UCsSec -> ItemType
mktUCsSec :: UCsSec -> ItemType
mktUCsSec (UCsProg [ConceptInstance]
_) = Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.unlikeChgLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ CI -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' CI
Doc.unlikelyChg

-- | Helper for creating the 'Traceability Matrices and Graphs' section ToC entry
mktTraceabilitySec :: TraceabilitySec -> ItemType
mktTraceabilitySec :: TraceabilitySec -> ItemType
mktTraceabilitySec (TraceabilityProg [TraceConfig]
_) = Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.traceMatricesLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.traceyMandG

-- | Helper for creating the 'Values of Auxiliary Constants' section ToC entry
mktAuxConsSec :: AuxConstntSec -> ItemType
mktAuxConsSec :: AuxConstntSec -> ItemType
mktAuxConsSec (AuxConsProg CI
_ [ConstQDef]
_) = Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.valsOfAuxConsLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize  IdeaDict
Doc.consVals

-- | Helper for creating the 'References' section ToC entry
mktBib :: ItemType
mktBib :: ItemType
mktBib = Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.referenceLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.reference 

-- | Helper for creating the 'Appendix' section ToC entry
mktAppndxSec :: AppndxSec -> ItemType
mktAppndxSec :: AppndxSec -> ItemType
mktAppndxSec (AppndxProg [Contents]
_) = Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.appendixLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize  IdeaDict
Doc.appendix

-- | Helper for creating the 'Off-The-Shelf Solutions' section ToC entry
mktOffShelfSolnSec :: OffShelfSolnsSec -> ItemType
mktOffShelfSolnSec :: OffShelfSolnsSec -> ItemType
mktOffShelfSolnSec (OffShelfSolnsProg [Contents]
_) = Sentence -> ItemType
Flat (Sentence -> ItemType) -> Sentence -> ItemType
forall a b. (a -> b) -> a -> b
$ Reference -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef Reference
SRS.offShelfSolnsLabel (Sentence -> Sentence) -> Sentence -> Sentence
forall a b. (a -> b) -> a -> b
$ IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
Doc.offShelfSolution

-- Find more concise way to do this
-- | Finds whether the Table of Contents is in a SRSDecl.
findToC :: [DocSection] -> ShowTableOfContents
findToC :: [DocSection] -> ShowTableOfContents
findToC [] = ShowTableOfContents
NoToC
findToC (DocSection
TableOfContents:[DocSection]
_) = ShowTableOfContents
ToC
findToC (DocSection
_:[DocSection]
dds) = [DocSection] -> ShowTableOfContents
findToC [DocSection]
dds