Skip to content

Commit e36c1ec

Browse files
Merge pull request #4432 from JacquesCarette/mnmzDcDsc
Remove one (ab)use of mkDocDesc by minimizing its hack.
2 parents cd06383 + abebc93 commit e36c1ec

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

code/drasil-docLang/lib/Drasil/DocumentLanguage.hs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import qualified Drasil.Sections.Stakeholders as Stk (stakeholderIntro,
6363
import qualified Drasil.DocumentLanguage.TraceabilityMatrix as TM (
6464
generateTraceTableView, traceMHeader, layoutUIDs)
6565
import qualified Drasil.DocumentLanguage.TraceabilityGraph as TG (traceMGF)
66-
import Drasil.DocumentLanguage.TraceabilityGraph (traceyGraphGetRefs)
66+
import Drasil.DocumentLanguage.TraceabilityGraph (traceyGraphGetRefs, genTraceGraphLabCons)
6767
import Drasil.Sections.TraceabilityMandGs (traceMatStandard)
6868
import Drasil.Sections.ReferenceMaterial (emptySectSentPlu)
6969

@@ -91,43 +91,35 @@ mkDoc srs comb (si@SI {_sys = sys, _authors = docauthors}, dd) =
9191
-- traceability matrix information and 'IdeaDict's.
9292
fillcdbSRS :: SRSDecl -> System -> (System , DocDesc)
9393
fillcdbSRS srsDec si =
94-
(fillSecAndLC dd $ fillReferences sections $ fillTraceSI dd si , dd)
94+
(fillLC dd $ fillReferences sections $ fillTraceSI dd si , dd)
9595
where
9696
dd :: DocDesc
9797
dd = mkDocDesc si srsDec
9898
sections :: [Section]
9999
sections = mkSections si dd
100100

101101
-- | Fill in the 'Section's and 'LabelledContent' maps of the 'ChunkDB' from the 'SRSDecl'.
102-
fillSecAndLC :: DocDesc -> System -> System
103-
fillSecAndLC dd si = si2
102+
fillLC :: DocDesc -> System -> System
103+
fillLC sd si@SI{ _sys = sn }
104+
| containsTraceSec sd = si2
105+
| otherwise = si
104106
where
105-
-- Get current contents of si
106107
chkdb = si ^. systemdb
107-
-- extract sections and labelledcontent
108-
allSections = concatMap findAllSec $ mkSections si dd -- FIXME: `mkSections` on something particularly large that is immediately discarded is a sign that we're doing something wrong.
109-
allLC = concatMap findAllLC allSections
108+
-- Pre-generate a copy of all required LabelledContents (i.e., traceability
109+
-- graphs) for insertion in the ChunkDB.
110+
createdLCs = genTraceGraphLabCons $ programName sn
111+
-- FIXME: This is a semi-hack. This is only strictly necessary for the
112+
-- traceability graphs. Those are all chunks that should exist but not be
113+
-- handled like this. They should be created and included in the
114+
-- meta-ChunkDB of `drasil-docLang`.
110115
existingLC = map (fst . snd) $ Map.assocs $ labelledcontentTable chkdb
111-
-- fill in the appropriate chunkdb fields
112-
chkdb2 = chkdb { labelledcontentTable = idMap $ nub $ existingLC ++ allLC }
113-
-- return the filled in system information
116+
chkdb2 = chkdb { labelledcontentTable = idMap $ nub $ existingLC ++ createdLCs }
114117
si2 = set systemdb chkdb2 si
115118

116-
-- Helper and finder functions
117-
findAllSec :: Section -> [Section]
118-
findAllSec s@(Section _ cs _) = s : concatMap findAllSubSec cs
119-
120-
findAllSubSec :: SecCons -> [Section]
121-
findAllSubSec (Sub s) = findAllSec s
122-
findAllSubSec _ = []
123-
124-
findAllLC :: Section -> [LabelledContent]
125-
findAllLC (Section _ cs _) = concatMap findLCSecCons cs
126-
127-
findLCSecCons :: SecCons -> [LabelledContent]
128-
findLCSecCons (Sub s) = findAllLC s
129-
findLCSecCons (Con (LlC lblcons@(LblC {_ctype = Figure {}}))) = [lblcons]
130-
findLCSecCons _ = []
119+
containsTraceSec :: DocDesc -> Bool
120+
containsTraceSec ((TraceabilitySec _):_) = True
121+
containsTraceSec (_:ss) = containsTraceSec ss
122+
containsTraceSec [] = False
131123

132124
-- | Takes in existing information from the Chunk database to construct a database of references.
133125
fillReferences :: [Section] -> System -> System

code/drasil-docLang/lib/Drasil/DocumentLanguage/TraceabilityGraph.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,15 @@ traceGLst = UlC $ ulcc $ Enumeration $ Bullet $ map (, Nothing) folderList'
162162

163163
-- | The Traceability Graph contents.
164164
traceGCon :: String -> [Contents] -- FIXME: HACK: We're generating "LlC"s of the traceability graphs multiple times... See DocumentLanguage.hs' mkTraceabilitySec for the other spot.
165-
traceGCon ex = map LlC (zipWith (traceGraphLC ex) traceGFiles traceGUIDs)
165+
traceGCon ex = map LlC (genTraceGraphLabCons ex)
166166
++ [mkParagraph $ S "For convenience, the following graphs can be\
167167
\ found at the links below:", traceGLst]
168168

169+
-- | Generate the `LabelledContent` chunks, specialized to a specific example
170+
-- (and its path).
171+
genTraceGraphLabCons :: String -> [LabelledContent]
172+
genTraceGraphLabCons ex = zipWith (traceGraphLC ex) traceGFiles traceGUIDs
173+
169174
-- | Generates traceability graphs as figures on an SRS document.
170175
traceGraphLC :: String -> FilePath -> UID -> LabelledContent
171176
traceGraphLC ex fp u = llcc (makeFigRef' u) $ fig (S $ show u) (traceyGraphPath ex fp)

code/stable/template/SRS/mdBook/.drasil-requirements.csv

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)