Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scope, motivation, and software review information to generated software-READMEs #3248

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
316318c
added scope, motivation, software review fields into SI
peter-michalski Jan 26, 2023
ba4d31a
adding blurb before example name
peter-michalski Jan 26, 2023
973da48
links SI motivation to README
peter-michalski Jan 27, 2023
571c4ac
adding new fields into example SI
peter-michalski Jan 27, 2023
1c91a7c
motivation generation in README
peter-michalski Jan 27, 2023
87045e6
updated stable README files
peter-michalski Jan 27, 2023
489d3c1
Merge branch 'master' into Issue3159-SI-expansion
peter-michalski Jan 27, 2023
7136b17
adding indent to maybeSub
peter-michalski Jan 27, 2023
7353304
adding period to first sentence README
peter-michalski Jan 27, 2023
1ef62c8
removing adding period in generator
peter-michalski Jan 27, 2023
5d8f5e3
pulling motivation out of justification, adding to SI
peter-michalski Jan 27, 2023
c33bfcc
adding background blurb to projectile
peter-michalski Jan 27, 2023
e61d585
added purpose to Pojectile
peter-michalski Jan 28, 2023
593e688
updating stable README
peter-michalski Jan 28, 2023
093493c
adding fields to website SI
peter-michalski Jan 28, 2023
335268a
updating stable projectile README purpose
peter-michalski Jan 29, 2023
1355c24
removing redundant blurb from generated README
peter-michalski Jan 31, 2023
f4adbb9
removing blurb from README in stable, updating projectile goal string
peter-michalski Feb 1, 2023
9881278
updated projectile stable
peter-michalski Feb 1, 2023
ad0fce2
Merge branch 'master' into Issue3159-SI-expansion
samm82 May 28, 2023
5512a58
remove redundant import from Projectile.Body
samm82 May 28, 2023
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 @@ -52,6 +52,8 @@ type CaseName = String
type ExamplePurpose = String
-- | Description of example
type ExampleDescr = String
-- | Motivation of example
type ExampleMotivation = String
Copy link
Owner

Choose a reason for hiding this comment

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

this information that is quite specific to the README has really gotten too large to fit in Language.Drasil.Code.Imperative.GOOL.ClassInterface. This should be split out into its own file.

It doesn't even belong to Language.Drasil.Code.Imperative, as it is quite independent of that. Finding a better home needs a design.

-- | File contributors
type Contributor = String
-- | Holds all information needed to create a README file.
Expand All @@ -66,5 +68,6 @@ data ReadMeInfo = ReadMeInfo {
configFP :: [FilePath],
caseName :: CaseName,
examplePurpose :: ExamplePurpose,
exampleDescr :: ExampleDescr
exampleDescr :: ExampleDescr,
exampleMotivation :: ExampleMotivation
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ genPackage unRepr = do
cfp = configFiles $ codeSpec g
db = sysinfodb $ codeSpec g
prps = show $ sentenceDoc db Implementation Linear
(foldlSent $ purpose $ codeSpec g)
(foldlSent_ $ purpose $ codeSpec g)
bckgrnd = show $ sentenceDoc db Implementation Linear
(foldlSent $ background $ codeSpec g)
(foldlSent_ $ background $ codeSpec g)
mtvtn = show $ sentenceDoc db Implementation Linear
(foldlSent_ $ motivation $ codeSpec g)
i <- genSampleInput
d <- genDoxConfig s
rm <- genReadMe ReadMeInfo {
Expand All @@ -149,7 +151,8 @@ genPackage unRepr = do
configFP = cfp,
caseName = "",
examplePurpose = prps,
exampleDescr = bckgrnd}
exampleDescr = bckgrnd,
exampleMotivation = mtvtn}
return $ package pd (m:catMaybes [i,rm,d])

-- | Generates an SCS program based on the problem and the user's design choices.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ makeReadMe ReadMeInfo {
configFP = configFPs,
caseName = name,
examplePurpose = purp,
exampleDescr = descr} =
makeMd [introInfo name auths $ fieldEmptySTR purp,
exampleDescr = descr,
exampleMotivation = motiv} =
makeMd [introInfo name auths (fieldEmptySTR purp) (fieldEmptySTR motiv),
whatInfo $ fieldEmptySTR descr,
makeInstr imptype configFPs,
verInfo progLang progLangVers,
Expand Down
12 changes: 12 additions & 0 deletions code/drasil-code/lib/Language/Drasil/CodeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ data CodeSpec where
purpose :: Purpose,
-- | Example Background.
background :: Background,
-- | Example Scope.
Copy link
Owner

Choose a reason for hiding this comment

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

why are these all Example X? The data structure is a "Code Specification". It feels like there is a mismatch.

Futhermore, are we now requiring all this information for all codes?

Copy link
Collaborator

Choose a reason for hiding this comment

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

My guess is that these were meant to specify that it is the purpose, etc., of the example itself, but I think this is a bit redundant

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe CodeSpec just needs to carry a reference to the SystemInformation it was constructed for? Right now, these fields are carried in both, and CodeSpecs are always a clone of SystemInformations manually created ones.

scope :: Scope,
-- | Example Software Review.
sftwr_rev :: SoftwareReview,
-- | Example Motivation.
motivation :: Motivation,
-- | All inputs.
inputs :: [Input],
-- | Explicit inputs (values to be supplied by a file).
Expand Down Expand Up @@ -100,6 +106,9 @@ codeSpec SI {_sys = sys
, _authors = as
, _purpose = ps
, _background = bk
, _scope = scp
, _sftwr_rev = sfrv
, _motivation = mtvtn
, _instModels = ims
, _datadefs = ddefs
, _configFiles = cfp
Expand All @@ -125,6 +134,9 @@ codeSpec SI {_sys = sys
authors = as,
purpose = ps,
background = bk,
scope = scp,
sftwr_rev = sfrv,
motivation = mtvtn,
inputs = allInputs,
extInputs = inputs',
derivedInputs = derived,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ si = SI {
_authors = [dong],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_quants = symbolsAll,
_concepts = [] :: [DefinedQuantityDict],
_instModels = iMods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ si = SI {
_authors = [alex, luthfi, olu],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
-- FIXME: The _quants field should be filled in with all the symbols, however
-- #1658 is why this is empty, otherwise we end up with unused (and probably
-- should be removed) symbols. But that's for another time. This is "fine"
Expand Down
3 changes: 3 additions & 0 deletions code/drasil-example/glassbr/lib/Drasil/GlassBR/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ si = SI {
_authors = [nikitha, spencerSmith],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_quants = symbolsForTable,
_concepts = [] :: [DefinedQuantityDict],
_instModels = iMods,
Expand Down
3 changes: 3 additions & 0 deletions code/drasil-example/hghc/lib/Drasil/HGHC/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ si = SI {
_quants = symbols,
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_concepts = [] :: [UnitalChunk],
_instModels = [], -- FIXME; empty _instModels
_datadefs = dataDefs,
Expand Down
3 changes: 3 additions & 0 deletions code/drasil-example/nopcm/lib/Drasil/NoPCM/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ si = SI {
_authors = [thulasi],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
-- FIXME: Everything after (and including) \\ should be removed when
-- #1658 is resolved. Basically, _quants is used here, but
-- tau does not appear in the document and thus should not be displayed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ si = SI {
_authors = [naveen],
_purpose = [],
_background = [],
_motivation = [],
Copy link
Owner

Choose a reason for hiding this comment

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

Reviewing multiple examples in a row that all set these 3 things to be empty. This really does start to feel like a hack. If we're going to implement a feature, shouldn't we be using it in all the examples? Just using it in Projectile does not convince me that this is a feature that is implemented at the right level.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We do have a form of this information that we write for the SRS documents, as we just recently did for #3777. It would be nice if we could share them with a chunk that defines what the purpose, background, and motivation of each case study, respectively, is.

This is also related to #3773. The specific purpose, background, and motivation of each case study are just instances of the generic concepts of purpose, background, and motivation. In other words, for our current design, these might just be unique ConceptInstances for each case study. Rather than having lists here, it might be that we just have a UID to the specific ConceptInstance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, actually, would it be nice to share the same SRS discussion of the purp., back., and moti. in the generated READMEs? I'm not sure anymore. We might want a longer version of that in the SRS, and a shorter one here. @smiths do you have any thoughts on this? Do you think we can share them?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@balacij I think for every example we should be able (if we haven't already) to write a one sentence purpose. This one sentence purpose would fit nicely in the README. It should also be usable in the SRS. As @NoahCardoso recently did, we can reuse the purpose in the Introduction to the SRS. Although we haven't done it yet, I could see us wanting to have a longer version of the purpose for the SRS. For instance, our one sentence purpose could be something like:

The software library provides a multi-domain Lattice Boltzmann solver.

(I'm working on a project with a colleague in mechanical engineering that could be described with that sentence.) The problem with this one sentence purpose is that it introduces at least two concepts that not everyone will be familiar with. This could be fine in a README file, but in the SRS, a description of what multi-domain means and what Lattice Boltzmann means would be in order. Following #3773, we could say that the purpose is an idea definition that includes two other idea definitions. In the README we might not generate the text for the definitions of the sub-ideas, but for the SRS, this would be a natural thing to do.

We could go through a similar conversation for Motivation and Scope. I think Motivation would be fairly simple, but Scope does get more involved. There are different views of Scope. There is a simple "high level" view, and then there is the view that decomposes the Scope into Scope Decisions (things that are entirely left out) and Assumptions. The Scope can also include typical values and examples.

_scope = [],
_sftwr_rev = [],
_quants = symbolsAll,
_concepts = [] :: [DefinedQuantityDict],
_datadefs = dataDefinitions,
Expand Down
29 changes: 24 additions & 5 deletions code/drasil-example/projectile/lib/Drasil/Projectile/Body.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Drasil.Projectile.Body (printSetting, si, srs, projectileTitle, fullSI) where

import Control.Lens ((^.))
import Language.Drasil
import Drasil.SRSDocument
import Language.Drasil.Chunk.Concept.NamedCombinators
Expand Down Expand Up @@ -67,7 +68,7 @@ mkSRS = [TableOfContents,
[ SSDProblem $ PDProg prob []
[ TermsAndDefs Nothing terms
, PhySysDesc projectileTitle physSystParts figLaunch []
, Goals [(phrase iVel +:+ S "vector") `S.the_ofThe` phrase projectile]]
, Goals [inputsPhrase]]
, SSDSolChSpec $ SCSProg
[ Assumptions
, TMs [] (Label : stdFields)
Expand All @@ -89,9 +90,24 @@ mkSRS = [TableOfContents,
Bibliography
]

inputsPhrase :: Sentence
inputsPhrase = (phrase iVel +:+ S "vector") `S.the_ofThe` phrase projectile

purpose :: Sentence
purpose = foldlSent_ [S "Given", inputsPhrase `sC` phrase projectileTitle, S "will"] +:+
foldlSent_ (map (^. defn) goals)

background :: Sentence
background = foldlSent [S "Common examples of", phrase projectile, phrase motion, S "include",
S "ballistics", plural problem, S "(missiles and bullets)" `S.andThe` S "flight of the balls",
S "in various sports (baseball, golf, football, etc.)"]

motivation :: Sentence
motivation = foldlSent [atStart projectile, phrase motion, S "is a common" +:+
phraseNP (problem `in_` physics)]

justification, scope :: Sentence
justification = foldlSent [atStart projectile, phrase motion, S "is a common" +:+.
phraseNP (problem `in_` physics), S "Therefore, it is useful to have a",
justification = foldlSent [motivation, S "Therefore, it is useful to have a",
phrase program, S "to solve and model these types of" +:+. plural problem,
atStartNP (the program), S "documented here is called", phrase projectileTitle]
scope = foldlSent_ [phraseNP (NP.the (analysis `ofA` twoD)),
Expand All @@ -106,8 +122,11 @@ si = SI {
_sys = projectileTitle,
_kind = Doc.srs,
_authors = [samCrawford, brooks, spencerSmith],
_purpose = [],
_background = [],
_purpose = [purpose],
_background = [background],
_motivation = [motivation],
_scope = [],
_sftwr_rev = [],
_quants = symbols,
_concepts = [] :: [DefinedQuantityDict],
_instModels = iMods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ si = SI {
_kind = Doc.notebook,
_authors = [spencerSmith],
_purpose = [],
_background = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_quants = [] :: [QuantityDict],
_concepts = [] :: [DefinedQuantityDict],
_instModels = [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ si = SI {
_authors = [olu],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_quants = symbols,
_concepts = [] :: [DefinedQuantityDict],
_instModels = iMods,
Expand Down
3 changes: 3 additions & 0 deletions code/drasil-example/ssp/lib/Drasil/SSP/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ si = SI {
_authors = [henryFrankis, brooks],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_quants = symbols,
_concepts = [] :: [DefinedQuantityDict],
_instModels = SSP.iMods,
Expand Down
3 changes: 3 additions & 0 deletions code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ si = SI {
_authors = [thulasi, brooks, spencerSmith],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_quants = symbols,
_concepts = [] :: [DefinedQuantityDict],
_instModels = insModel,
Expand Down
3 changes: 3 additions & 0 deletions code/drasil-example/template/lib/Drasil/Template/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ si = SI {
_authors = [authorName],
_background = [],
_purpose = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_quants = [] :: [QuantityDict],
_concepts = [] :: [DefinedQuantityDict],
_instModels = [] :: [InstanceModel],
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-gen/lib/Language/Drasil/TypeCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SysInfo.Drasil (SystemInformation(SI))

typeCheckSI :: SystemInformation -> IO ()
typeCheckSI
(SI _ _ _ _ _ _ _ ims dds _ _ _ _ _ _ chks _ _)
(SI _ _ _ _ _ _ _ _ _ _ ims dds _ _ _ _ _ _ chks _ _)
= do
-- build a variable context (a map of UIDs to "Space"s [types])
let cxt = M.map (\(dict, _) -> dict ^. typ) (symbolTable chks)
Expand Down
22 changes: 14 additions & 8 deletions code/drasil-printers/lib/Language/Drasil/Markdown/CreateMd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ makeMd :: [Doc] -> Doc
makeMd = vcat . punctuate secSep . filtEmp

-- | Example title, authors, and maybe purpose section.
introInfo :: String -> [String] -> Maybe String -> Doc
introInfo name auths descr = introSec (text name) (listToDoc auths) (length auths) (maybePurpDoc descr)
introInfo :: String -> [String] -> Maybe String -> Maybe String -> Doc
introInfo name auths descr motiv = introSec (text name) (prepName name)
(listToDoc auths) (length auths) (maybeSub "Purpose" descr) (maybeSub "Motivation" motiv)

-- | Helper for prepending the example name.
prepName :: String -> Doc
prepName name = text "> The program documented here is called" <+> text name <> text "."

-- | Instruction section, contains 3 paragraphs, Running, Building and Config Files.
-- The Config file section is only displayed if there are configuration files.
instDoc :: [String] -> Doc
instDoc cfp = regularSec (text "Making Examples")
(runInstDoc <> doubleSep <> makeInstDoc) <> configSec cfp

-- | Helper for creating optional Purpose subsection as Doc
maybePurpDoc :: Maybe String -> Doc
maybePurpDoc = maybe empty (\descr-> doubleSep <> text "> Purpose:" <+> text descr)
-- | Helper for creating optional Intro subsection as Doc
maybeSub :: String -> Maybe String -> Doc
maybeSub role = maybe empty (\content-> doubleSep <> text ("> " ++ role ++ ":")
<+> text content)

-- | 'What' section in generated README file, does not display if empty
whatInfo :: Maybe String -> Doc
Expand Down Expand Up @@ -125,9 +131,9 @@ bkQuote3 = text "```"
-- FIXME as explained in #2224 we still need to add in the purpose section,
-- this could be done by adding a third parameter to introSec
-- | Constructs introduction section from header and message.
introSec :: Doc -> Doc -> Int -> Doc -> Doc
introSec hd ms1 l descr = text "#" <+> hd <+> contSep <> (if l == 1 then text "> Author:" else text "> Authors: ")
<+> ms1 <> descr
introSec :: Doc -> Doc -> Doc -> Int -> Doc -> Doc -> Doc
introSec hd name ms1 l descr motiv = text "#" <+> hd <+> contSep <> name <> doubleSep <>
(if l == 1 then text "> Author:" else text "> Authors: ") <+> ms1 <> descr <> motiv

-- | Constructs regular section section from header and message.
regularSec :: Doc -> Doc -> Doc
Expand Down
4 changes: 2 additions & 2 deletions code/drasil-sysinfo/lib/SysInfo/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module SysInfo.Drasil (
-- * System Information
SystemInformation(..), Block(Parallel), sysinfodb
-- * Reference Database
, ReferenceDB, RefMap, Purpose, Background, citeDB, rdb, simpleMap
, citationDB, conceptDB
, ReferenceDB, RefMap, Purpose, Background, Scope, SoftwareReview, Motivation
, citeDB, rdb, simpleMap, citationDB, conceptDB

-- ** Utility Helper Functions
-- GetChunk
Expand Down
15 changes: 12 additions & 3 deletions code/drasil-sysinfo/lib/SysInfo/Drasil/SystemInformation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ module SysInfo.Drasil.SystemInformation (
-- ** Types
SystemInformation(..), Block(..),
-- ** Lenses
instModels, datadefs, configFiles, inputs, purpose, background,
defSequence, constraints, constants, sysinfodb, usedinfodb,
instModels, datadefs, configFiles, inputs, purpose, background, scope, sftwr_rev,
motivation, defSequence, constraints, constants, sysinfodb, usedinfodb,
-- ** Lookup Functions
citeDB, citationsFromBibMap,
-- * Reference Database
-- ** Types
ReferenceDB, RefMap, Purpose, Background,
ReferenceDB, RefMap, Purpose, Background, Scope, SoftwareReview, Motivation,
-- ** Constructors
rdb, simpleMap,
-- ** Lenses
Expand Down Expand Up @@ -50,6 +50,9 @@ data SystemInformation where
, _authors :: [c]
, _purpose :: Purpose
, _background :: Background
, _scope :: Scope
, _sftwr_rev :: SoftwareReview
, _motivation :: Motivation
, _quants :: [e]
, _concepts :: [f]
, _instModels :: [InstanceModel]
Expand All @@ -70,6 +73,12 @@ data SystemInformation where
type Purpose = [Sentence]
-- | Project Example background information, used in the 'What' section of README.
type Background = [Sentence]
-- | Project Example scope.
type Scope = [Sentence]
-- | Project Example software revision.
type SoftwareReview = [Sentence]
-- | Project Example motivation.
type Motivation = [Sentence]

-- | for listing 'QDefinition's in 'SystemInformation'.
data Block a = Coupled a a [a] | Parallel a [a]
Expand Down
3 changes: 3 additions & 0 deletions code/drasil-website/lib/Drasil/Website/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ si fl = SI {
_quants = [] :: [QuantityDict],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_sftwr_rev = [],
_concepts = [] :: [UnitalChunk],
_instModels = [],
_datadefs = [],
Expand Down
2 changes: 2 additions & 0 deletions code/stable/dblpendulum/src/cpp/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions code/stable/dblpendulum/src/csharp/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions code/stable/dblpendulum/src/java/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions code/stable/dblpendulum/src/python/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading