Skip to content

Commit

Permalink
broken; added LabelledContent as a SecCons; started to implement datC…
Browse files Browse the repository at this point in the history
…on as LabelledContent instead of Contents
  • Loading branch information
niazim3 committed Jul 6, 2018
1 parent 98c674c commit 70ffb51
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 35 deletions.
13 changes: 5 additions & 8 deletions code/drasil-example/Drasil/SRS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ doc' sys authors secs = Document (Doc.srs `forTT'` sys) authors secs
intro, prpsOfDoc, scpOfReq, charOfIR, orgOfDoc, stakeholder, theCustomer, theClient,
genSysDes, sysCont, userChar, sysCon, scpOfTheProj, prodUCTable, indPRCase, specSysDes,
probDesc, termAndDefn, termogy, physSyst, goalStmt, solCharSpec, assumpt, thModel,
genDefn, inModel, dataDefn, datCon, propCorSol, require, nonfuncReq, funcReq, likeChg, traceyMandG, tOfSymb,
genDefn, inModel, dataDefn, propCorSol, require, nonfuncReq, funcReq, likeChg, traceyMandG, tOfSymb,
appendix, reference, offShelfSol, valsOfAuxCons, unlikeChg :: [Contents] -> [Section] -> Section

intro cs ss = section' (titleize Doc.introduction) cs ss "Intro"
Expand Down Expand Up @@ -75,7 +75,6 @@ thModel cs ss = section' (titleize' Doc.thModel) cs ss "TMs"
genDefn cs ss = section' (titleize' Doc.genDefn) cs ss "GDs"
inModel cs ss = section' (titleize' Doc.inModel) cs ss "IMs"
dataDefn cs ss = section' (titleize' Doc.dataDefn) cs ss "DDs"
datCon cs ss = section' (titleize' Doc.datumConstraint) cs ss "DataConstraints"

propCorSol cs ss = section' (titleize' Doc.propOfCorSol) cs ss "CorSolProps"

Expand All @@ -97,15 +96,13 @@ offShelfSol cs ss = section' (titleize' Doc.offShelfSolution) cs ss "ExistingSol

tOfSymb cs ss = section' (titleize Doc.tOfSymb) cs ss "ToS"


datCon :: [LabelledContent] -> [Section] -> Section
datCon cs ss = sectionLC (titleize' Doc.datumConstraint) cs ss (mkLabelRA "DataConstraints")

--function that sets the shortname of each section to be the reference address
section' :: Sentence -> [Contents] -> [Section] -> RefAdd -> Section
section' a b c d = section a b c (mkLabelRA' (d ++ "Label") d)
where
getStr :: Sentence -> String
getStr (S s) = s
getStr ((:+:) s1 s2) = getStr s1 ++ getStr s2
getStr _ = error "Term is not a string"

--
missingP :: [Contents]
missingP = [Paragraph $ S "..."]
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ solChSpecF progName (probDes, likeChg, unlikeChg) ddEndSent (mid, hasUncertainty
generDefn = genDefnF g
dataDefin = dataDefnF ddEndSent dd
instModels = inModelF probDes dataDefin theModels generDefn i
dataConstr = datConF mid hasUncertainty trail dc
dataConstr = datConF mid hasUncertainty trail (llcc "dataConstraintsSection" (mkLabelRA'' "dataConstraintsSection") dc)


solutionCharSpecIntro :: (Idea a) => a -> Section -> Contents
Expand Down Expand Up @@ -194,9 +194,10 @@ inModelIntro r1 r2 r3 r4 = foldlSP [S "This", phrase section_,
where end = S " and" +:+ (makeRef r4)

-- wrapper for datConPar
datConF :: Sentence -> Sentence -> Sentence -> [Contents] -> Section
datConF :: Sentence -> Sentence -> Sentence -> [LabelledContent] -> Section
datConF hasUncertainty mid trailing tables = SRS.datCon
((dataConstraintParagraph hasUncertainty (listofTablesToRefs tables) mid trailing):tables) []
((llcc "dataConsIntro" (mkLabelRA'' "dataConsSection") $

This comment was marked as resolved.

Copy link
@niazim3

niazim3 Jul 6, 2018

Author Collaborator

Do we want a label just for the introduction of a section when there is a label for the entire section (when line 115 will work)? @szymczdm

This comment was marked as resolved.

Copy link
@niazim3

niazim3 Jul 9, 2018

Author Collaborator

Upon looking into it again, realized that a separate label is alright in this scenario since one label is for the introductory contents (since "paragraph should have a label" as mentioned in Tuesday, June 19th's meeting) and the tables that should be passed in will have their own labels.

dataConstraintParagraph hasUncertainty (listofTablesToRefs tables) mid trailing):tables) []

-- reference to the input/ ouput tables -> optional middle sentence(s) (use EmptyS if not wanted) ->
-- True if standard ending sentence wanted -> optional trailing sentence(s) -> Contents
Expand Down
4 changes: 2 additions & 2 deletions code/drasil-lang/Language/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module Language.Drasil (
, Referable(..), Document(..), DType(..), Section(..), Contents(..)
, SecCons(..), ListType(..), ItemType(..), ListPair
, LabelledContent, llcc
, section, fig, figWithWidth, section''
, section, fig, figWithWidth, section'', sectionLC
, datadefn, reldefn
-- Reference
, makeRef, acroTest, find'
Expand Down Expand Up @@ -231,7 +231,7 @@ import Language.Drasil.Output.Formats (DocType(SRS,MG,MIS,Website), DocSpec(DocS
import Language.Drasil.Document (Document(..), DType(..)
, Section(..), Contents(..), SecCons(..), ListType(..), ItemType(..)
, section, fig, figWithWidth, section''
, datadefn, reldefn
, datadefn, reldefn, sectionLC
, ListPair
, LabelledContent, llcc)
import Language.Drasil.Unicode -- all of it
Expand Down
46 changes: 25 additions & 21 deletions code/drasil-lang/Language/Drasil/Document.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ type ListPair = (Title,ItemType) -- ^ Title: Item
type Filepath = String
type Lbl = Sentence

-- | A Document has a Title ('Sentence'), Author(s) ('Sentence'), and Sections
-- which hold the contents of the document
data Document = Document Title Author [Section]

--FIXME: Remove Data and Theory from below.
-- | Types of definitions
data DType = Data QDefinition -- ^ QDefinition is the chunk with the defining
Expand Down Expand Up @@ -84,23 +80,6 @@ data Contents = Table [Sentence] [[Sentence]] Title Bool RefAdd
| Defnt DType [(Identifier, [Contents])] RefAdd
type Identifier = String

-- | Section Contents are split into subsections or contents, where contents
-- are standard layout objects (see 'Contents')
data SecCons = Sub Section
| Con Contents

-- | Sections have a title ('Sentence') and a list of contents ('SecCons')
-- and its shortname
data Section = Section
{ tle :: Title
, cons :: [SecCons]
, _lb :: Label
}
makeLenses ''Section

instance HasLabel Section where getLabel = lb
instance HasShortName Section where shortname = lb . shortname

data LabelledContent = LblC { _uniqueID :: UID
, _lbl :: Label
, ctype :: Contents
Expand All @@ -116,6 +95,28 @@ instance HasShortName LabelledContent where shortname = lbl . shortname
llcc :: UID -> Label -> Contents -> LabelledContent
llcc = LblC

-- | Section Contents are split into subsections or contents, where contents
-- are standard layout objects (see 'Contents')
data SecCons = Sub Section
| Con Contents
| LCon LabelledContent

-- | Sections have a title ('Sentence') and a list of contents ('SecCons')
-- and its shortname
data Section = Section
{ tle :: Title
, cons :: [SecCons]
, _lb :: Label
}
makeLenses ''Section

instance HasLabel Section where getLabel = lb
instance HasShortName Section where shortname = lb . shortname

-- | A Document has a Title ('Sentence'), Author(s) ('Sentence'), and Sections
-- which hold the contents of the document
data Document = Document Title Author [Section]

{-
instance HasShortName Contents where
shortname (Table _ _ _ _ r) = shortname' $ "Table:" ++ r
Expand Down Expand Up @@ -168,6 +169,9 @@ section title intro secs lbe = Section title (map Con intro ++ map Sub secs) lbe
section'' :: Sentence -> [Contents] -> [Section] -> Label -> Section
section'' title intro secs lbe = section title intro secs lbe

sectionLC :: Sentence -> [LabelledContent] -> [Section] -> Label -> Section
sectionLC title intro secs lbe = Section title (map LCon intro ++ map Sub secs) lbe

-- | Figure smart constructor. Assumes 100% of page width as max width.
fig :: Lbl -> Filepath -> RefAdd -> Contents
fig l f = Figure l f 100
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-lang/drasil-lang.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: drasil-lang
Version: 0.1.9
Version: 0.1.10
Cabal-Version: >= 1.18
Author: Dan Szymczak, Steven Palmer, Jacques Carette, Spencer Smith
build-type: Simple
Expand Down

0 comments on commit 70ffb51

Please sign in to comment.