Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
952a528
clean auto abbrv extraction code
Sep 7, 2025
6de9dc5
stable
Sep 7, 2025
04fd9af
deleted abbreviationsList
Sep 7, 2025
a3d111d
fixed code errors
Sep 7, 2025
d49a098
deleted acronyms def
Sep 7, 2025
d45194d
fixed unused imports errors
Sep 7, 2025
30d057a
capitalize long abbreviation forms in the TAandA
Sep 8, 2025
d07b293
added missing abbrvs with an additional paragraph in the Org of Docum…
Sep 8, 2025
41f6823
missing abrv displayed
Sep 8, 2025
4ae1045
removed all occurences of collectDocAbbrv from examples body.hs
Sep 8, 2025
c072676
removed unecessary modules exposure
Sep 8, 2025
0d78660
line up fix
Sep 9, 2025
f08e6e8
restored deleted comments
Sep 9, 2025
0a8ece9
moved select to SearchTools file
Sep 9, 2025
dc1f995
stable
Sep 9, 2025
621dd63
mkSRS declaration fixed
Sep 9, 2025
63be539
Merge branch 'main' into tableAccAbbS
balacij Sep 10, 2025
9671d48
move extra paragraph in dblpend (for adding abbreviation declarations…
balacij Sep 10, 2025
fb244cc
remove 'select' function and adjust comment on 'tableAbbAccGen'
balacij Sep 10, 2025
4af33a2
dig deeper when looking for abbreviations
balacij Sep 10, 2025
0ec56d8
dig even deeper when looking for abbreviations
balacij Sep 11, 2025
b61d696
force more usage of refBy (CI)
balacij Sep 11, 2025
3239231
must dig even deeper when looking for abbreviations
balacij Sep 11, 2025
2ac256d
comment on getDocDesc
balacij Sep 11, 2025
ee80178
space removal, a minor code touch-up, and commentary
balacij Sep 11, 2025
f90609d
Remove grabbing too many UIDs when looking only for UIDs for chunks w…
balacij Sep 12, 2025
cecbd9d
Move to 2 layer document section rendering
balacij Sep 13, 2025
6a1e11f
closing in on what's going awry
balacij Sep 15, 2025
344298a
debugging getUIDshort
balacij Sep 15, 2025
3c8b565
remove 'trace'-based debugging code
balacij Sep 16, 2025
8d80f11
remove unrelated code changes
balacij Sep 16, 2025
2f77800
introduce (un)likely changes abbreviation
balacij Sep 16, 2025
1c23862
remove double periods in abbreviation/acronym intruction paragraph
balacij Sep 16, 2025
a6c3611
Use introduceAbbPlrl to introduce abbreviations
balacij Sep 16, 2025
d517a94
glassbr: use load duration factor short form
balacij Sep 16, 2025
3268f3d
pdcontroller: fix a few missing short form uses
balacij Sep 16, 2025
79d6863
Remove table of abbreviations abb/abb filtration based on abb/acc equ…
balacij Sep 19, 2025
e040350
Merge branch 'main' into tableAccAbbS
balacij Sep 22, 2025
77b87ea
Merge branch 'main' into rmPDConDervCI
balacij Sep 22, 2025
7639a88
Merge branch 'rmPDConDervCI' into tableAccAbbS
balacij Sep 22, 2025
7e22c99
Merge branch 'main' into tableAccAbbS
balacij Sep 23, 2025
b4c4c73
Merge branch 'main' of github.com:JacquesCarette/Drasil into tableAcc…
balacij Oct 27, 2025
e8defbd
Merge branch 'main' of github.com:JacquesCarette/Drasil into tableAcc…
balacij Oct 27, 2025
dda29d9
Merge branch 'main' of github.com:JacquesCarette/Drasil into tableAcc…
balacij Oct 27, 2025
f73fb86
Add a cheap hack for injecting Refname in the Tab. of A. and A.s
balacij Oct 28, 2025
951208d
Avoid pattern matching on `EmptyS`.
balacij Oct 28, 2025
2c0c928
Merge branch 'main' of github.com:JacquesCarette/Drasil into tableAcc…
balacij Nov 3, 2025
e249f93
Fix 'typical uncertainties' plural form capture and clean up Sentence…
balacij Nov 3, 2025
d2ed561
Fix ambiguous imports in Projectile
balacij Nov 3, 2025
a6dccc7
Merge branch 'main' of github.com:JacquesCarette/Drasil into tableAcc…
balacij Nov 4, 2025
4b811fa
Remove ununecessary no-unused-top-binds pragma
balacij Nov 5, 2025
17f6cd0
Merge branch 'main' of github.com:JacquesCarette/Drasil into tableAcc…
balacij Nov 5, 2025
b362518
Add labelledContent back to SWHSNoPCM's ChunkDB.
balacij Nov 5, 2025
78a9845
Add comments to new utils and avoid ++ in splitAtAll
balacij Nov 5, 2025
f5b45e7
Remove duplicated comment
balacij Nov 5, 2025
9c40fb2
Remove trailing whitespace again...
balacij Nov 5, 2025
248e342
Remove commented out code
balacij Nov 5, 2025
d022a3c
Minimize diff to load duration factor
balacij Nov 5, 2025
c6b93fb
Merge branch 'main' of github.com:JacquesCarette/Drasil into tableAcc…
balacij Jan 28, 2026
f0a0bb5
Clean up leftover code in merge.
balacij Jan 28, 2026
c832dc2
Add RefBy to rnHACK to get 'Referenced by' acronym in TabAccAbb
balacij Jan 28, 2026
8f2b731
Hopefully fix build by removing duplicate export.
balacij Jan 28, 2026
7d7aa62
Remove paragraph used to force in acronym gathering for TabAbbAcc
balacij Jan 28, 2026
ea0ecb4
Only titleize nouns on abbreviation/acronym introduction for proper
balacij Jan 28, 2026
e21e16f
Merge branch 'introduceAbb' of github.com:JacquesCarette/Drasil into …
balacij Jan 28, 2026
b76a720
Fix introduceAbbPlrl + stabilize
balacij Jan 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ doccon = [abbAcc, abbreviation, acronym, analysis, appendix, aspect, body,
-- | Collects all documentation-related common ideas (like a concept, but with no definition).
doccon' :: [CI]
doccon' = [assumption, dataConst, dataDefn, desSpec, genDefn, goalStmt, inModel,
likelyChg, learnObj, mg, mis, notApp, physSyst, requirement, srs, thModel, typUnc, unlikelyChg, notebook]
likelyChg, learnObj, mg, mis, notApp, physSyst, requirement, srs, thModel, typUnc,
unlikelyChg, notebook, refBy, refName]

assumption, desSpec, goalStmt, dataConst, likelyChg, learnObj, unlikelyChg, physSyst, requirement,
mg, mis, notApp, srs, typUnc, sec, notebook, refBy, refName :: CI
Expand Down
22 changes: 17 additions & 5 deletions code/drasil-docLang/lib/Drasil/DocumentLanguage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module Drasil.DocumentLanguage where

import Control.Lens ((^.), set)
import Data.Function (on)
import Data.List (nub, sortBy)
import Data.Maybe (maybeToList, mapMaybe)
import Data.List (nub, sortBy, nubBy)
import Data.Maybe (maybeToList, mapMaybe, isJust)
import qualified Data.Map as Map (elems, assocs, keys)

import Utils.Drasil (invert)
Expand All @@ -33,7 +33,7 @@ import Language.Drasil.Display (compsy)

import Database.Drasil (findOrErr, idMap, insertAll, ChunkDB(..))
import Drasil.Database.SearchTools (findAllDataDefns, findAllGenDefns,
findAllInstMods, findAllTheoryMods, findAllConcInsts)
findAllInstMods, findAllTheoryMods, findAllConcInsts, TermAbbr, shortForm, termResolve')

import Drasil.System
import Drasil.GetChunks (ccss, ccss', citeDB)
Expand Down Expand Up @@ -69,6 +69,8 @@ import Drasil.Sections.ReferenceMaterial (emptySectSentPlu)
import qualified Data.Drasil.Concepts.Documentation as Doc (likelyChg, section_,
software, unlikelyChg)

import Language.Drasil.Development (shortdep)

-- * Main Function
-- | Creates a document from a document description, a title combinator function, and system information.
mkDoc :: SRSDecl -> (IdeaDict -> IdeaDict -> Sentence) -> System -> Document
Expand Down Expand Up @@ -264,12 +266,22 @@ mkRefSec si dd (RefProg c l) = SRS.refMat [c] (map (mkSubRef si) l)
mkSubRef SI {_systemdb = cdb} (TSymb' f con) =
mkTSymb (ccss (getDocDesc dd) (egetDocDesc dd) cdb) f con

mkSubRef _ (TAandA ideas) =
mkSubRef SI {_systemdb = cdb} TAandA =
SRS.tOfAbbAcc
[LlC $ tableAbbAccGen $ nub ideas]
[LlC $ tableAbbAccGen $ nubBy (\a b -> shortForm a == shortForm b) (collectDocumentAbbreviations dd cdb)]
[]

-- | Extracts abbreviations/acronyms found in the document
getAllChunksFromDoc :: DocDesc -> ChunkDB -> [TermAbbr]
getAllChunksFromDoc dd cdb =
map (termResolve' cdb) $ nub $ concatMap shortdep (getDocDesc dd)

getChunksWithAbbreviations :: [TermAbbr] -> [TermAbbr]
getChunksWithAbbreviations = filter (isJust . shortForm)

collectDocumentAbbreviations :: DocDesc -> ChunkDB -> [TermAbbr]
collectDocumentAbbreviations dd cdb =
getChunksWithAbbreviations $ getAllChunksFromDoc dd cdb

-- | Helper for creating the table of symbols.
mkTSymb :: (Quantity e, Concept e, Eq e, MayHaveUnit e) =>
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-docLang/lib/Drasil/DocumentLanguage/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ data RefTab where
-- | Allows Lens functions in addition to an introduction for a table of symbols.
TSymb' :: LFunc -> [TSIntro] -> RefTab
-- | Default.
TAandA :: [IdeaDict] -> RefTab
TAandA :: RefTab
-- add more here

-- | For creating a table of symbols introduction
Expand Down
46 changes: 35 additions & 11 deletions code/drasil-docLang/lib/Drasil/ExtractDocDesc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,20 @@ egetCon _ = []
sentencePlate :: Monoid a => ([Sentence] -> a) -> DLPlate (Constant a)
sentencePlate f = appendPlate (secConPlate (f . concatMap getCon') $ f . concatMap getSec) $
preorderFold $ purePlate {
introSec = Constant . f <$> \(IntroProg s1 s2 _) -> [s1, s2],
introSec = Constant . f <$> \(IntroProg s1 s2 s3) -> [s1, s2] ++ concatMap getIntroSub s3,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sentencePlate collects "all" sentences that a renderer would project from a DocDesc (a document description). What sentencePlate is really here for, is for us to check that for all Sentences in a document, we can scan them for the references chunks (notably, symbols, units, and abbreviations) to make sure that they're all either registered already and unique (i.e., the symbols and units) or just to plainly query for them (i.e., this PR, the abbreviations). The problem with this approach is that some Sentence production happens 'too late' -- i.e., it happens in the renderer code. Any of the _s that I've left in the pattern matches of sentencePlate indicate something that contains things that would go into Sentences that we cannot look into. The majority of them are CIs (i.e., things known to have abbreviations!), but I will comment when this is not the case.

introSub = Constant . f <$> \case
(IPurpose s) -> s
(IScope s) -> [s]
(IChar s1 s2 s3) -> concat [s1, s2, s3]
(IOrgSec _ _ s1) -> [s1],
(IOrgSec _ s1 s2) -> s2 : getSec s1,
stkSub = Constant . f <$> \case
(Client _ s) -> [s]
(Cstmr _) -> [],
pdSec = Constant . f <$> \(PDProg s _ _) -> [s],
pdSec = Constant . f <$> \(PDProg s secs pds) -> s : concatMap getSec secs ++ concatMap getPDSub pds,
pdSub = Constant . f <$> \case
(TermsAndDefs Nothing cs) -> def cs
(TermsAndDefs (Just s) cs) -> s : def cs
(PhySysDesc _ s _ _) -> s
(PhySysDesc _ s lc cs) -> s ++ getLC lc ++ getC cs
(Goals s c) -> s ++ def c,
scsSub = Constant . f <$> \case
(Assumptions c) -> def c
Expand All @@ -126,10 +126,10 @@ sentencePlate f = appendPlate (secConPlate (f . concatMap getCon') $ f . concatM
(GDs s _ d _) -> def d ++ s ++ der d ++ notes d
(IMs s _ d _) -> s ++ der d ++ notes d
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lines 122 - 127, the first _ indicates Field:

-- | Fields that should be displayed in definitions.
data Field = Label
| Symbol
| Units
| DefiningEquation
| Description Verbosity InclUnits
| Input
| Output
| InConstraints
| OutConstraints
| Notes
| Source -- I think using attribute makes most sense, as sources can and
-- will be modified across applications; the underlying knowledge won't.
| RefBy --TODO: Fill in the field.

The problem with Field is that they're not tied to a CI or IdeaDict. They're rendered through a Show instance:

mkTMField t m l@RefBy fs = (show l, [mkParagraph $ helperRefs t m]) : fs --FIXME: fill this in

-- | Defines 'Field's as 'String's.
instance Show Field where
show Label = "Label"
show Symbol = "Symbol"
show Units = "Units"
show RefBy = "RefBy"
show Source = "Source"
show Input = "Input"
show Output = "Output"
show InConstraints = "Input Constraints"
show OutConstraints = "Output Constraints"
show DefiningEquation = "Equation"
show (Description _ _) = "Description"
show Notes = "Notes"

So, even if we wanted to scan the generated tables for sentences or UIDs of chunks we input into sentences, we wouldn't have a UID to scan for. This results in at least Refname being impossible to scan for (because it is not related to a chunk we scan for):

Scanning for "Refname" in the codebase shows we just use the string raw, mostly, except for the one CI:

 ~/Programming/Drasil/code/ tableAccAbbS rg "Refname" -ths
drasil-data/lib/Data/Drasil/Concepts/Documentation.hs
87:refName     = commonIdeaWithDict "refName"     (cn' "reference name")                                "Refname" [documentc]

drasil-printers/lib/Language/Drasil/JSON/Print.hs
253:  (tr (nbformat (th (text "Refname")) $$ td (nbformat(bold l))) $$ makeDRows ps)

drasil-printers/lib/Language/Drasil/HTML/Print.hs
299:  (tr (th (text "Refname") $$ td (bold l)) $$ makeDRows ps)

drasil-printers/lib/Language/Drasil/TeX/Print.hs
344:  command0 "toprule " <> bold (pure $ text "Refname") <> pure (text " & ") <> bold l, --shortname instead of refname?

drasil-printers/lib/Language/Drasil/Markdown/Print.hs
224:  makeHeaderCols [text "Refname", l] size $$ 

Scanning for the CI shows we just add it to our ChunkDBs without using it really.

λ ~/Programming/Drasil/code/ tableAccAbbS rg "refName" -ths
drasil-data/lib/Data/Drasil/Concepts/Documentation.hs
57:  unlikelyChg, notebook, refBy, refName]
60:  mg, mis, notApp, srs, typUnc, sec, notebook, refBy, refName :: CI
87:refName     = commonIdeaWithDict "refName"     (cn' "reference name")                                "Refname" [documentc]
331:  likeChgDom, unlikeChgDom, refByDom, refNameDom :: ConceptChunk
341:refNameDom    = ccs (mkIdea "refNameDom"    (refName ^. term)                  $ Just "RefName")  EmptyS [srsDom]
346:  assumpDom, chgProbDom, likeChgDom, unlikeChgDom, refByDom, refNameDom]

drasil-example/swhs/lib/Drasil/SWHS/Concepts.hs
8:  likelyChg, physSyst, requirement, refBy, refName, srs, typUnc, unlikelyChg)
20:  physSyst, requirement, refBy, refName, srs, thModel, typUnc, unlikelyChg]

drasil-example/glassbr/lib/Drasil/GlassBR/Concepts.hs
7:  notApp, physSyst, response, requirement, refBy, refName, srs, type_, typUnc, 
29:  refBy, refName, stdOffDist, srs, thModel, typUnc, unlikelyChg]

drasil-example/ssp/lib/Drasil/SSP/Defs.hs
10:  likelyChg, physSyst, property, requirement, refBy, refName, safety, srs, typUnc, 
21:  physSyst, requirement, refBy, refName, srs, thModel, typUnc, unlikelyChg]

drasil-example/gamephysics/lib/Drasil/GamePhysics/Concepts.hs
8:  requirement, refBy, refName, srs, typUnc, unlikelyChg)
19:  likelyChg, ode, requirement, refBy, refName, srs, thModel, threeD, twoD, typUnc, unlikelyChg]

drasil-example/dblpend/lib/Drasil/DblPend/Unitals.hs
12:  requirement, refBy, refName, srs, typUnc)
31:  physSyst, requirement, refBy, refName, srs, thModel, typUnc]

drasil-example/pdcontroller/lib/Drasil/PDController/Concepts.hs
7:       (assumption, goalStmt, physSyst, requirement, refBy, refName, srs, typUnc)
12:     refName, srs, thModel, typUnc, pdControllerCI, proportionalCI, derivativeCI,
λ ~/Programming/Drasil/Drasil/code/ tableAccAbbS 

Similarly, because of this, RefBy is unable to be picked up by the extractor. Hence, RefBy is also impossible to be picked up.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching from String here to something that the extractor could pick up is a good idea (i.e., moving from show ls to something with a UID), but what should that new type be? Sentence is awkward because it would contain few-word sentences (abusing Sentence). NP? Unfortunately those don't contain UIDs. TypedUIDs is probably most appropriate, but our infrastructure really isn't ready for that change (yet).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely shows the problem with Show instances for us: it internalizes some knowledge into the Haskell part of Drasil too much. That information should be in 'data' (probably chunks, but I don't want to presume that.) We should definitely de-embed this knowledge.

My first instinct would be to create a new chunk (FieldLabel ?) with a uid and a label.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this part is still not addressed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this will need to be moved to a new issue. This work is a bit more involved, similar to the work for Refname: #4363 (comment)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it should be handled separately. But should it block this PR?

(Constraints s _) -> [s]
(CorrSolnPpties _ _) -> [],
(CorrSolnPpties _ cs) -> getC cs,
reqSub = Constant . f <$> \case
(FReqsSub' c _) -> def c
(FReqsSub c _) -> def c
(FReqsSub' c lcs) -> def c ++ concatMap getLC lcs
(FReqsSub c lcs) -> def c ++ concatMap getLC lcs
(NonFReqsSub c) -> def c,
lcsSec = Constant . f <$> \(LCsProg c) -> def c,
ucsSec = Constant . f <$> \(UCsProg c) -> def c,
Expand All @@ -139,17 +139,41 @@ sentencePlate f = appendPlate (secConPlate (f . concatMap getCon') $ f . concatM
} where
def :: Definition a => [a] -> [Sentence]
def = map (^. defn)

getIntroSub :: IntroSub -> [Sentence]
getIntroSub (IPurpose ss) = ss
getIntroSub (IScope s) = [s]
getIntroSub (IChar s1 s2 s3) = s1 ++ s2 ++ s3
getIntroSub (IOrgSec _ s1 s2) = s2 : getSec s1

der :: MayHaveDerivation a => [a] -> [Sentence]
der = concatMap (getDerivSent . (^. derivations))

getDerivSent :: Maybe Derivation -> [Sentence]
getDerivSent Nothing = []
getDerivSent (Just (Derivation h s)) = h : s

notes :: HasAdditionalNotes a => [a] -> [Sentence]
notes = concatMap (^. getNotes)

getPDSub :: PDSub -> [Sentence]
getPDSub (TermsAndDefs ms c) = def c ++ maybe [] pure ms
getPDSub (PhySysDesc _ s lc cs) = s ++ getLC lc ++ getC cs
getPDSub (Goals s c) = s ++ def c

getC :: [Contents] -> [Sentence]
getC = concatMap getCon'

getLC :: LabelledContent -> [Sentence]
getLC = getCon . (^. accessContents)

-- | Extracts 'Sentence's from a document description.
getDocDesc :: DocDesc -> [Sentence]
getDocDesc = fmGetDocDesc (sentencePlate id)
getDocDesc = fmGetDocDesc (sentencePlate id)
-- ^ FIXME: We want all Sentences from a document (not necessarily a document
-- description), so we use this function. But 'sentencePlate' does not include
-- all 'Sentence's! Some only appear when rendering (at least, after
-- `mkSections` is used on a `DocDesc` to create `[Section]`).

-- | Extracts 'Sentence's from a 'Section'.
getSec :: Section -> [Sentence]
Expand All @@ -166,16 +190,16 @@ getCon' = getCon . (^. accessContents)

-- | Extracts 'Sentence's from raw content.
getCon :: RawContent -> [Sentence]
getCon (Table s1 s2 t _) = isVar (s1, transpose s2) ++ [t]
getCon (Table s1 s2 t _) = isVar (s1, transpose s2) ++ [t]
getCon (Paragraph s) = [s]
getCon EqnBlock{} = []
getCon CodeBlock{} = []
getCon (DerivBlock h d) = h : concatMap getCon d
getCon (Enumeration lst) = getLT lst
getCon (Figure l _ _ _) = [l]
getCon (Bib bref) = getBib bref
getCon (Graph [(s1, s2)] _ _ l) = [s1, s2, l]
getCon Graph{} = []
getCon (Graph sss _ _ l) = let (ls, rs) = unzip sss
in l : ls ++ rs
getCon (Defini _ []) = []
getCon (Defini dt (hd:fs)) = concatMap getCon' (snd hd) ++ getCon (Defini dt fs)

Expand Down
124 changes: 74 additions & 50 deletions code/drasil-docLang/lib/Drasil/Sections/Introduction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Drasil.Sections.Introduction (orgSec, introductionSection,
purposeOfDoc, scopeOfRequirements, charIntRdrF, purpDoc) where

import Language.Drasil
import Language.Drasil hiding (organization)
import qualified Drasil.DocLang.SRS as SRS (intro, prpsOfDoc, scpOfReq,
charOfIR, orgOfDoc, goalStmt, thModel, inModel, sysCon)
import Drasil.DocumentLanguage.Definitions(Verbosity(..))
Expand All @@ -12,16 +12,17 @@ import qualified Language.Drasil.Sentence.Combinators as S
import Drasil.Sections.ReferenceMaterial(emptySectSentPlu, emptySectSentSing)

import Data.Drasil.Concepts.Computation (algorithm)
import Data.Drasil.Concepts.Documentation as Doc (assumption, characteristic,
decision, definition, desSpec, design, designDoc, document, documentation,
environment, goal, goalStmt, implementation, intReader, model,
organization, purpose, requirement, scope, section_, softwareDoc,
softwareVAV, srs, theory, user, vavPlan, problem, problemIntro,
information, systemConstraint, template)
import Drasil.Metadata (inModel, thModel)
import Data.Drasil.Concepts.Documentation (assumption, document, environment,
model, system, user, characteristic, decision, definition, desSpec, design,
designDoc, documentation, goal, goalStmt, implementation, information,
intReader, physSyst, problem, problemIntro, purpose, organization, requirement, scope,
section_, softwareDoc, softwareVAV, srs, systemConstraint, template, theory,
vavPlan)
import Data.Drasil.Citations (parnasClements1986, smithEtAl2007,
smithKoothoor2016, smithLai2005, koothoor2013)
import Data.Drasil.Software.Products
import Data.Drasil.Software.Products (sciCompS)

import Drasil.Metadata (inModel, thModel, dataDefn, genDefn)


-----------------------
Expand All @@ -30,18 +31,18 @@ import Data.Drasil.Software.Products

-- | 'Sentence' that explains the development process of a program.
developmentProcessParagraph :: Sentence
developmentProcessParagraph = foldlSent [S "This", phrase document,
S "will be used as a starting point for subsequent development",
developmentProcessParagraph = foldlSent [S "This", phrase document,
S "will be used as a starting point for subsequent development",
S "phases, including writing the", phraseNP (desSpec `andThe` softwareVAV) +:+.
S "plan", atStartNP (the designDoc), S "will show how the",
plural requirement, S "are to be realized, including", plural decision,
S "on the numerical", plural algorithm, S "and programming" +:+.
phrase environment, S "The", phrase vavPlan,
S "plan", atStartNP (the designDoc), S "will show how the",
plural requirement, S "are to be realized, including", plural decision,
S "on the numerical", plural algorithm, S "and programming" +:+.
phrase environment, S "The", phrase vavPlan,
S "will show the steps that will be used to increase confidence in the",
(phraseNP (softwareDoc `andThe` implementation) !.), S "Although",
S "the", short srs, S "fits in a series of", plural document,
S "that follow the so-called waterfall", phrase model `sC`
S "the actual development process is not constrained",
S "the", short srs, S "fits in a series of", plural document,
S "that follow the so-called waterfall", phrase model `sC`
S "the actual development process is not constrained",
S "in any way. Even when the waterfall model is not followed, as",
S "Parnas and Clements point out", refS parnasClements1986 `sC`
S "the most logical way to present the", phrase documentation,
Expand All @@ -50,10 +51,10 @@ developmentProcessParagraph = foldlSent [S "This", phrase document,

-- | 'Sentence' containing the subsections of the Introduction.
introductionSubsections :: Sentence
introductionSubsections = foldlList Comma List (map (uncurry S.the_ofThe)
[(phrase scope, plural requirement),
introductionSubsections = foldlList Comma List (map (uncurry S.the_ofThe)
[(phrase scope, plural requirement),
(plural characteristic, phrase intReader),
(phrase Doc.organization, phrase document)])
(phrase organization, phrase document)])

-------------------------
-- --
Expand All @@ -68,31 +69,31 @@ introductionSection :: Sentence -> Sentence -> [Section] -> Section
introductionSection EmptyS programDefinition = SRS.intro
[mkParagraph $ emptySectSentSing [problemIntro],
overviewParagraph programDefinition]
introductionSection problemIntroduction programDefinition = SRS.intro
introductionSection problemIntroduction programDefinition = SRS.intro
[mkParagraph problemIntroduction, overviewParagraph programDefinition]


-- | Constructor for the overview paragraph for the Introduction.
-- Takes the definition of the specific example being generated ('Sentence').
overviewParagraph :: Sentence -> Contents
overviewParagraph programDefinition = foldlSP [S "The following", phrase section_,
S "provides an overview of the", introduceAbb srs, S "for" +:+.
S "provides an overview of the", introduceAbb srs, S "for" +:+.
programDefinition, S "This", phrase section_, S "explains the", phrase purpose,
S "of this", phrase document `sC` introductionSubsections]


-- | Constructor for Purpose of Document section that each example controls.
purpDocPara1 :: CI -> Sentence
purpDocPara1 :: CI -> Sentence
purpDocPara1 proName = foldlSent [S "The primary purpose of this", phrase document, S "is to",
S "record the", plural requirement, S "of" +:+. short proName,
atStart' goal `sC` plural assumption `sC` plural thModel `sC`
S "record the", plural requirement, S "of" +:+. short proName,
atStart' goal `sC` plural assumption `sC` plural thModel `sC`
plural definition `sC` S "and other", phrase model, S "derivation",
phrase information, S "are specified" `sC` S "allowing the reader to fully",
S "understand" `S.and_` S "verify the", phrase purpose `S.and_` S "scientific",
S "basis of" +:+. short proName, S "With the exception of",
S "basis of" +:+. short proName, S "With the exception of",
namedRef (SRS.sysCon [] []) (plural systemConstraint) `sC` S "this",
short Doc.srs, S "will remain abstract, describing what", phrase problem,
S "is being solved, but not how to solve it"]
short srs, S "will remain abstract, describing what", phrase problem,
S "is being solved, but not how to solve it"]

-- | Combines 'purpDocPara1' and 'developmentProcessParagraph'.
-- Verbosity controls if the 'developmentProcessParagraph' is added or not.
Expand All @@ -107,7 +108,7 @@ purpDoc proName Succinct = [purpDocPara1 proName]
-- * Otherwise: Uses the default 'developmentProcessParagraph'.
purposeOfDoc :: [Sentence] -> Section
purposeOfDoc [purposeOfProgram] = SRS.prpsOfDoc [mkParagraph purposeOfProgram] []
purposeOfDoc [purposeOfProgram, developmentProcess] = SRS.prpsOfDoc
purposeOfDoc [purposeOfProgram, developmentProcess] = SRS.prpsOfDoc
[mkParagraph purposeOfProgram, mkParagraph developmentProcess] []
purposeOfDoc _ = SRS.prpsOfDoc [mkParagraph developmentProcessParagraph] []

Expand All @@ -121,9 +122,9 @@ scopeOfRequirements req = SRS.scpOfReq [foldlSP
-- | Constructor for characteristics of the intended reader subsection.
-- Takes the program name ('Idea'), assumed knowledge ('Sentence's), topic-related subjects ('Sentence's),
-- knowledge assets ('Sentence's), and references ('Section').
charIntRdrF :: (Idea a) => a -> [Sentence] -> [Sentence] -> [Sentence] ->
charIntRdrF :: (Idea a) => a -> [Sentence] -> [Sentence] -> [Sentence] ->
Section -> Section
charIntRdrF progName assumed topic asset r =
charIntRdrF progName assumed topic asset r =
SRS.charOfIR (intReaderIntro progName assumed topic asset r) []

-- | Helper that creates a paragraph. Called by 'charIntRdrF'. The parameters (in order) should be:
Expand All @@ -135,10 +136,10 @@ charIntRdrF progName assumed topic asset r =
-- * reference to User Characteristics section.
intReaderIntro :: (Idea a) => a -> [Sentence] -> [Sentence] -> [Sentence] ->
Section -> [Contents]
intReaderIntro _ [] [] [] _ =
intReaderIntro _ [] [] [] _ =
[foldlSP [S "Reviewers of this", phrase documentation,
S "do not need any prerequisite knowledge"]]
intReaderIntro progName assumed topic asset sectionRef =
intReaderIntro progName assumed topic asset sectionRef =
[foldlSP [S "Reviewers of this", phrase documentation,
S "should have an understanding of" +:+.
foldlList Comma List (assumed ++ topic), assetSent,
Expand All @@ -160,22 +161,45 @@ orgSec b s t = SRS.orgOfDoc (orgIntro b s t) []
-- an introduction ('Sentence'), a resource for a bottom up approach ('NamedIdea'), reference to that resource ('Section'),
-- and any other relevant information ('Sentence').
orgIntro :: NamedIdea c => c -> Section -> Sentence -> [Contents]
orgIntro bottom bottomSec trailingSentence = [foldlSP [
orgOfDocIntro, S "The presentation follows the standard pattern of presenting" +:+.
foldlList Comma List (map plural [nw Doc.goal, nw theory, nw definition, nw assumption]),
S "For readers that would like a more bottom up approach" `sC`
S "they can start reading the", namedRef bottomSec (plural bottom)`S.and_`
S "trace back to find any additional information they require"],
folder [refineChain (zip [goalStmt, thModel, inModel]
[SRS.goalStmt [] [], SRS.thModel [] [], SRS.inModel [] []]), trailingSentence]]
orgIntro bottom bottomSec trailingSentence =
foldlSP [
orgOfDocIntro, S "The presentation follows the standard pattern of presenting" +:+.
foldlList Comma List (map plural [nw goal, nw theory, nw definition, nw assumption]),
S "For readers that would like a more bottom up approach" `sC`
S "they can start reading the", namedRef bottomSec (plural bottom)`S.and_`
S "trace back to find any additional information they require"
] : flowDiscussion trailingSentence

orgOfDocIntro :: Sentence
orgOfDocIntro = foldlSent
[atStartNP (the organization), S "of this", phrase document,
S "follows the", phrase template, S "for an", short srs, S "for",
phrase sciCompS, S "proposed by", foldlList Comma List $
map refS [koothoor2013, smithLai2005, smithEtAl2007 , smithKoothoor2016]]

flowDiscussion :: Sentence -> [Contents]
flowDiscussion extraSentence = [
folder
[ refineChain (zip
[goalStmt, thModel, inModel]
[SRS.goalStmt [] [], SRS.thModel [] [], SRS.inModel [] []]) -- FIXME: This abuses `SRS.goalStmt` etc.
, extraSentence]
, foldlSP [S "The" +:+ plural goalStmt +:+ sParen (short goalStmt) +:+ S "are systematically refined into the" +:+
plural thModel +:+ sParen (short thModel) `sC` S "which in turn are refined into the" +:+
plural inModel +:+ sParen (short inModel) +:+. EmptyS +:+
S "This refinement process is guided by the" +:+ plural assumption +:+ sParen (short assumption) +:+
S "that constrain the" +:+ phrase system `sC` S "as well as the supporting" +:+
plural genDefn +:+ sParen (short genDefn) +:+ S "and" +:+ plural dataDefn +:+ sParen (short dataDefn) +:+
S "that provide the necessary mathematical and physical context." +:+
S "The" +:+ plural requirement +:+ sParen (short requirement) +:+ S "are traced back through the" +:+
short goalStmt `sC` short thModel `sC` S "and" +:+ short inModel +:+ S "to ensure consistency and completeness." +:+
S "Furthermore" `sC` S "the" +:+ phrase physSyst +:+ sParen (short physSyst) +:+ S "establishes the overall" +:+
S "context in which the" +:+ short goalStmt +:+ S "are formulated and the" +:+ short assumption +:+ S "are validated." +:+
S "Finally" `sC` S "the uncertainties (Uncerts.) are documented and linked to" +:+
S "the relevant" +:+ short inModel +:+ S "and" +:+ short dataDefn `sC` S "ensuring transparency in the modeling process."
]
]
where
folder = case trailingSentence of
folder = case extraSentence of
EmptyS -> foldlSP_
_ -> foldlSP

orgOfDocIntro :: Sentence
orgOfDocIntro = foldlSent
[atStartNP (the Doc.organization), S "of this", phrase document,
S "follows the", phrase template, S "for an", short Doc.srs, S "for",
phrase sciCompS, S "proposed by", foldlList Comma List $
map refS [koothoor2013, smithLai2005, smithEtAl2007 , smithKoothoor2016]]
Loading