Skip to content

Commit

Permalink
Working table of contents generator as per #1018
Browse files Browse the repository at this point in the history
  • Loading branch information
Ant13731 committed Jul 13, 2021
1 parent dd504d8 commit 9711b73
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 395 deletions.
6 changes: 3 additions & 3 deletions code/drasil-data/Data/Drasil/Concepts/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ doccon = [abbAcc, abbreviation, acronym, analysis, appendix, aspect, body, charO
organization, output_, physical, physicalConstraint, physicalProperty, physicalSim,
physicalSystem, physics, plan, practice, priority, problem, problemDescription,
prodUCTable, productUC, product_, project, propOfCorSol, property, prpsOfDoc,
purpose, quantity, realtime, reference, refmat, reqInput, requirement_, response, result,
purpose, quantity, realtime, reference, refMat, reqInput, requirement_, response, result,
reviewer, safety, safetyReq, scenario, scope, scpOfReq, scpOfTheProjS, second_,
section_, simulation, software, softwareConstraint, softwareDoc, softwareReq,
softwareSys, softwareVAV, softwareVerif, solution, solutionCharSpec,
Expand Down Expand Up @@ -214,7 +214,7 @@ year = nc "year" (cn' "year" )
scpOfTheProjS = nc "scpOfTheProj" (cn' "scope of the project") -- temporary generated for test


abbAcc, charOfIR, consVals, corSol, orgOfDoc, propOfCorSol, prpsOfDoc, refmat,
abbAcc, charOfIR, consVals, corSol, orgOfDoc, propOfCorSol, prpsOfDoc, refMat,
reqInput, scpOfReq, tAuxConsts, tOfSymb, tOfUnit,
termAndDef, traceyMandG, vav, tOfCont :: NamedChunk

Expand All @@ -225,7 +225,7 @@ charOfIR = nc "charOfIR" (characteristic `of_PS` intReader)
orgOfDoc = nc "orgOfDoc" (organization `of_` document)
propOfCorSol = nc "propOfCorSol" (property `ofAPS` corSol)
prpsOfDoc = nc "prpsOfDoc" (purpose `of_` document)
refmat = nc "refmat" (cn' "reference material")
refMat = nc "refMat" (cn' "reference material")
reqInput = nc "ReqInputs" (cn' "required input")
scpOfReq = nc "scpOfReq" (scope `of_` requirement)
tAuxConsts = nc "TAuxConsts" (cn' "auxiliary constant")
Expand Down
9 changes: 5 additions & 4 deletions code/drasil-docLang/Drasil/DocLang/References.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Drasil.DocLang.References (secRefs) where
import Drasil.DocLang.SRS
import Drasil.DocumentLanguage.Core (getTraceConfigUID)

import Drasil.Sections.TableOfAbbAndAcronyms (tableAbbAccRef, tableAbbAccLabel)
import Drasil.Sections.TableOfAbbAndAcronyms (tableAbbAccRef)
import Drasil.Sections.TableOfSymbols (symbTableRef)
import Drasil.Sections.TableOfUnits (unitTableRef)
import Drasil.Sections.TraceabilityMandGs (traceMatAssumpAssump, traceMatAssumpOther, traceMatRefinement)
Expand All @@ -15,6 +15,7 @@ import Language.Drasil


secRefs :: [Reference]
secRefs = sectionReferences ++ [tableAbbAccRef, tableAbbAccLabel,
reqInputsRef, symbTableRef, unitTableRef, tableOfConstantsRef, tInDataCstRef, tOutDataCstRef]
++ map (ref.makeTabRef.getTraceConfigUID) [traceMatAssumpAssump, traceMatAssumpOther, traceMatRefinement]
secRefs = sectionReferences ++ [tableAbbAccRef, reqInputsRef, symbTableRef,
unitTableRef, tableOfConstantsRef, tInDataCstRef, tOutDataCstRef]
++ map (ref.makeTabRef.getTraceConfigUID) [traceMatAssumpAssump,
traceMatAssumpOther, traceMatRefinement]
190 changes: 104 additions & 86 deletions code/drasil-docLang/Drasil/DocLang/SRS.hs

Large diffs are not rendered by default.

29 changes: 14 additions & 15 deletions code/drasil-docLang/Drasil/DocumentLanguage.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# Language TupleSections #-}
---------------------------------------------------------------------------
-- | Start the process of moving away from Document as the main internal
-- representation of information, to something more informative.
Expand Down Expand Up @@ -28,13 +29,14 @@ import Database.Drasil(ChunkDB, SystemInformation(SI), _authors, _kind,
_quants, _sys, _sysinfodb, _usedinfodb, ccss, ccss', citeDB, collectUnits,
conceptinsTable, generateRefbyMap, idMap, refbyTable, termTable, traceTable)

import Drasil.Sections.TableOfAbbAndAcronyms (tableOfAbbAndAcronyms)
import Drasil.Sections.TableOfAbbAndAcronyms (tableAbbAccGen)
import Drasil.Sections.TableOfContents (toToC)
import Drasil.Sections.TableOfSymbols (table, symbTableRef)
import Drasil.Sections.TableOfUnits (tOfUnitDesc, tOfUnitSIName, unitTableRef)
import qualified Drasil.DocLang.SRS as SRS (appendix, dataDefn, genDefn,
genSysDes, inModel, likeChg, unlikeChg, probDesc, reference, solCharSpec,
stakeholder, thModel, tOfCont, tOfSymb, tOfUnit, userChar, offShelfSol)
stakeholder, thModel, tOfCont, tOfSymb, tOfUnit, userChar, offShelfSol, refMat,
tOfAbbAcc)
import qualified Drasil.Sections.AuxiliaryConstants as AC (valsOfAuxConstantsF)
import qualified Drasil.Sections.GeneralSystDesc as GSD (genSysIntro,
systCon, usrCharsF, sysContxt)
Expand All @@ -49,7 +51,7 @@ import qualified Drasil.Sections.Stakeholders as Stk (stakeholderIntro,
import qualified Drasil.DocumentLanguage.TraceabilityMatrix as TM (traceMGF,
generateTraceTableView)

import qualified Data.Drasil.Concepts.Documentation as Doc (likelyChg, refmat, section_,
import qualified Data.Drasil.Concepts.Documentation as Doc (likelyChg, section_,
software, unlikelyChg)


Expand Down Expand Up @@ -102,8 +104,6 @@ extractUnits dd cdb = collectUnits cdb $ ccss' (getDocDesc dd) (egetDocDesc dd)

----- Section creators -----

--- General Section creator ---

-- | Helper for creating the different document sections.
mkSections :: SystemInformation -> DocDesc -> [Section]
mkSections si dd = map doit dd
Expand All @@ -124,17 +124,16 @@ mkSections si dd = map doit dd
doit (AppndxSec a) = mkAppndxSec a
doit (OffShelfSolnsSec o) = mkOffShelfSolnSec o

--- Table of Contents ---

-- | Helper for making the Table of Contents section.
mkToC :: DocDesc -> Section
mkToC dd = SRS.tOfCont [intro, UlC $ ulcc $ Enumeration $ Bullet $ map (, Nothing) $ concatMap toToC dd] []
mkToC dd = SRS.tOfCont [intro, UlC $ ulcc $ Enumeration $ Bullet $ map ((, Nothing) . toToC) dd] []
where
intro = mkParagraph $ S "An outline of all sections included in this SRS is recorded here for easy reference."

--- Reference Materials section. Includes Table of Symbols, Units and Abbreviations and Acronyms. ---


-- | Helper for creating the reference section and subsections.
-- Includes Table of Symbols, Units and Abbreviations and Acronyms.
mkRefSec :: SystemInformation -> DocDesc -> RefSec -> Section
mkRefSec si dd (RefProg c l) = SRS.refMat [c] (map (mkSubRef si) l)
where
Expand All @@ -159,7 +158,7 @@ mkRefSec si dd (RefProg c l) = SRS.refMat [c] (map (mkSubRef si) l)
mkSubRef SI {_sysinfodb = cdb} (TSymb' f con) =
mkTSymb (ccss (getDocDesc dd) (egetDocDesc dd) cdb) f con
mkSubRef SI {_usedinfodb = db} TAandA =
tOfAbbAcc [LlC $ table $ nub $ map fst $ Map.elems $ termTable db] []
SRS.tOfAbbAcc [LlC $ tableAbbAccGen $ nub $ map fst $ Map.elems $ termTable db] []

-- | Table of units constructors.
tunit, tunit' :: [TUIntro] -> RefTab
Expand Down Expand Up @@ -355,16 +354,16 @@ mkReqrmntSec (ReqsProg l) = R.reqF $ map mkSubs l
-- | Helper for making the Likely Changes section.
mkLCsSec :: LCsSec -> Section
mkLCsSec (LCsProg c) = SRS.likeChg (intro : mkEnumSimpleD c) []
where intro = foldlSP [S "This", phrase section_, S "lists the",
plural likelyChg, S "to be made to the", phrase software]
where intro = foldlSP [S "This", phrase Doc.section_, S "lists the",
plural Doc.likelyChg, S "to be made to the", phrase Doc.software]

{--}

-- | Helper for making the Unikely Changes section.
mkUCsSec :: UCsSec -> Section
mkUCsSec (UCsProg c) = SRS.unlikeChg (intro : mkEnumSimpleD c) []
where intro = foldlSP [S "This", phrase section_, S "lists the",
plural unlikelyChg, S "to be made to the", phrase software]
where intro = foldlSP [S "This", phrase Doc.section_, S "lists the",
plural Doc.unlikelyChg, S "to be made to the", phrase Doc.software]

{--}

Expand Down Expand Up @@ -402,6 +401,6 @@ mkAppndxSec (AppndxProg cs) = SRS.appendix cs []

{--}

-- | Helper to get part of the system information as an 'IdeaDict'.
-- | Helper to get the program name as an 'IdeaDict'.
siSys :: SystemInformation -> IdeaDict
siSys SI {_sys = sys} = nw sys
8 changes: 4 additions & 4 deletions code/drasil-docLang/Drasil/Sections/TableOfAbbAndAcronyms.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- | Standard code to make a table of symbols.
module Drasil.Sections.TableOfAbbAndAcronyms
(tableOfAbbAndAcronyms, tableAbbAccRef, tableAbbAccLabel) where
(tableAbbAccGen, tableAbbAccRef) where

import Language.Drasil
import Data.Drasil.Concepts.Documentation (abbreviation, fullForm, abbAcc)
Expand All @@ -17,14 +17,14 @@ select (x:xs) = case getA x of
Just y -> (y, x) : select xs

-- | The actual table creation function.
table :: (Idea s) => [s] -> LabelledContent
table ls = let chunks = sortBy (compare `on` fst) $ select ls in
tableAbbAccGen :: (Idea s) => [s] -> LabelledContent
tableAbbAccGen ls = let chunks = sortBy (compare `on` fst) $ select ls in
llcc tableAbbAccRef $ Table
(map titleize [abbreviation, fullForm]) (mkTable
[\(a,_) -> S a,
\(_,b) -> titleize b]
chunks)
(titleize abbAcc) True
(titleize' abbAcc) True

-- | Table of abbreviations and acronyms reference.
tableAbbAccRef :: Reference
Expand Down
Loading

0 comments on commit 9711b73

Please sign in to comment.