Skip to content

Commit

Permalink
Merge pull request #1826 from JacquesCarette/doxygenDefns
Browse files Browse the repository at this point in the history
Add definitions to Doxygen comments
  • Loading branch information
smiths authored Aug 14, 2019
2 parents 231dfaf + 84a7c39 commit 1e3e4a6
Show file tree
Hide file tree
Showing 36 changed files with 287 additions and 293 deletions.
17 changes: 13 additions & 4 deletions code/drasil-code/Language/Drasil/Code/Imperative/Comments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ module Language.Drasil.Code.Imperative.Comments (
) where

import Language.Drasil
import Database.Drasil (defTable)
import Language.Drasil.Code.Imperative.State (State(..))
import Language.Drasil.CodeSpec (CodeSpec(..), CodeSystInfo(..))
import Language.Drasil.Printers (Linearity(Linear), sentenceDoc,
unitDoc)
import Language.Drasil.Printers (Linearity(Linear), sentenceDoc, unitDoc)

import Data.Map (Map)
import qualified Data.Map as Map (lookup)
import Data.Maybe (maybe)
import Control.Monad.Reader (Reader, ask)
import Control.Lens (view)
import Text.PrettyPrint.HughesPJ (Doc, (<+>), empty, parens, render, text)
import Text.PrettyPrint.HughesPJ (Doc, (<+>), colon, empty, parens, render,
text)

getTermDoc :: (NamedIdea c) => UID -> Map UID c -> Reader State Doc
getTermDoc cname m = do
Expand All @@ -22,6 +23,13 @@ getTermDoc cname m = do
return $ (maybe (text "No description given") (sentenceDoc db
Implementation Linear . phraseNP . view term) . Map.lookup cname) m

getDefnDoc :: UID -> Reader State Doc
getDefnDoc cname = do
g <- ask
let db = sysinfodb $ csi $ codeSpec g
return $ maybe empty ((<+>) colon . sentenceDoc db Implementation Linear .
view defn . fst) (Map.lookup cname $ defTable db)

getUnitsDoc :: (MayHaveUnit c) => UID -> Map UID c -> Doc
getUnitsDoc cname m = maybe empty (parens . unitDoc Linear . usymb)
(Map.lookup cname m >>= getUnit)
Expand All @@ -30,8 +38,9 @@ getComment :: (NamedIdea c, MayHaveUnit c) => UID -> Map UID c ->
Reader State String
getComment l m = do
t <- getTermDoc l m
d <- getDefnDoc l
let u = getUnitsDoc l m
return $ render $ t <+> u
return $ render $ (t <> d) <+> u

paramComment :: UID -> Reader State String
paramComment l = do
Expand Down
13 changes: 7 additions & 6 deletions code/drasil-database/Database/Drasil.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{- re-export many things to simplify external use -}
module Database.Drasil (
-- ChunkDB
ChunkDB, RefbyMap, TraceMap, UMap, asOrderedList, cdb, collectUnits, conceptMap
, conceptinsLookup, conceptinsTable, dataDefnTable, datadefnLookup, defResolve
, gendefLookup, gendefTable, generateRefbyMap, insmodelLookup, insmodelTable
, labelledconLookup, labelledcontentTable, refbyLookup, refbyTable
, sectionLookup, sectionTable, symbResolve, termResolve, termTable
, theoryModelLookup, theoryModelTable, traceLookup, traceMap, traceTable
ChunkDB(defTable), RefbyMap, TraceMap, UMap, asOrderedList, cdb, collectUnits
, conceptMap, conceptinsLookup, conceptinsTable, dataDefnTable
, datadefnLookup, defResolve, gendefLookup, gendefTable, generateRefbyMap
, insmodelLookup, insmodelTable, labelledconLookup, labelledcontentTable
, refbyLookup, refbyTable, sectionLookup, sectionTable, symbResolve
, termResolve, termTable, theoryModelLookup, theoryModelTable, traceLookup
, traceMap, traceTable
-- ChunkDB.GetChunk
, ccss, ccss', combine, getIdeaDict, vars
-- SystemInformation
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-database/Database/Drasil/ChunkDB.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE TemplateHaskell #-}
module Database.Drasil.ChunkDB (ChunkDB, RefbyMap, TraceMap, UMap,
module Database.Drasil.ChunkDB (ChunkDB(defTable), RefbyMap, TraceMap, UMap,
asOrderedList, cdb, collectUnits, conceptMap, conceptinsLookup,
conceptinsTable, dataDefnTable, datadefnLookup, defResolve, gendefLookup,
gendefTable, generateRefbyMap, insmodelLookup, insmodelTable,
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-example/Drasil/GlassBR/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ symbMap = cdb thisSymbols (map nw acronyms ++ map nw thisSymbols ++ map nw con
++ map nw softwarecon ++ map nw terms ++ [nw lateralLoad, nw materialProprty]
++ [nw distance, nw algorithm] ++
map nw fundamentals ++ map nw derived ++ map nw physicalcon)
(map cw symb ++ Doc.srsDomains) (map unitWrapper [metre, second, kilogram]
(map cw symb ++ terms ++ Doc.srsDomains) (map unitWrapper [metre, second, kilogram]
++ map unitWrapper [pascal, newton]) GB.dataDefs iMods [] tMods concIns section
labCon

Expand Down
2 changes: 1 addition & 1 deletion code/drasil-example/Drasil/GlassBR/Requirements.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ sysSetValsFollowingAssumpsTable :: LabelledContent
sysSetValsFollowingAssumpsTable = mkValsSourceTable (mkQRTupleRef r2AQs r2ARs ++ mkQRTuple r2DDs) "ReqAssignments"
(S "Required Assignments" `follows` sysSetValsFollowingAssumps)
where
r2AQs = loadSF : map qw (take 4 assumptionConstants)
r2AQs = qw loadSF : map qw (take 4 assumptionConstants)
r2ARs = assumpGL : replicate 4 assumpSV
r2DDs = [loadDF, hFromt, glaTyFac, standOffDis, aspRat]

Expand Down
84 changes: 35 additions & 49 deletions code/drasil-example/Drasil/GlassBR/Unitals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Language.Drasil.ShortHands
import Theory.Drasil (mkQuantDef)
import Utils.Drasil

import Control.Lens ((^.))
import Prelude hiding (log)

import Data.Drasil.Concepts.Math (xComp, yComp, zComp)
Expand Down Expand Up @@ -36,9 +35,10 @@ constrained :: [ConstrainedChunk]
constrained = map cnstrw inputDataConstraints ++
[cnstrw probBr, cnstrw probFail]

plateLen, plateWidth, charWeight, standOffDist :: UncertQ
aspectRatio, pbTol, tNT :: UncertainChunk
glassTypeCon, nomThick :: ConstrainedChunk
plateLen, plateWidth, aspectRatio, charWeight, standOffDist :: UncertQ
pbTol, tNT :: UncertainChunk
nomThick :: ConstrainedChunk
glassTypeCon :: ConstrConcept

{--}

Expand All @@ -59,12 +59,12 @@ inputsWUncrtn :: [UncertainChunk]
inputsWUncrtn = [pbTol, tNT]

--derived inputs with uncertainties and no units
derivedInsWUncrtn :: [UncertainChunk]
derivedInsWUncrtn :: [UncertQ]
derivedInsWUncrtn = [aspectRatio]

--inputs with no uncertainties
inputsNoUncrtn :: [ConstrainedChunk]
inputsNoUncrtn = [glassTypeCon, nomThick]
inputsNoUncrtn = [cnstrw glassTypeCon, nomThick]

inputDataConstraints :: [UncertainChunk]
inputDataConstraints = map uncrtnw inputsWUnitsUncrtn ++
Expand All @@ -82,10 +82,9 @@ plateWidth = uqcND "plateWidth" (nounPhraseSP "plate width (short dimension)")
[ physc $ Bounded (Exc, 0) (Inc, sy plateLen),
sfwrc $ Bounded (Inc, sy dimMin) (Inc, sy dimMax)] (dbl 1.2) defaultUncrt

aspectRatio = uvc "aspectRatio" (aR ^. term)
(Variable "AR") Real
aspectRatio = uq (constrained' (dqdNoUnit aspectRatioCon (Variable "AR") Real)
[ physc $ UpFrom (Inc, 1),
sfwrc $ UpTo (Inc, sy arMax)] (dbl 1.5) defaultUncrt
sfwrc $ UpTo (Inc, sy arMax)] (dbl 1.5)) defaultUncrt

pbTol = uvc "pbTol" (nounPhraseSP "tolerable probability of breakage")
(sub cP (Concat [lBreak, lTol])) Real
Expand All @@ -101,27 +100,18 @@ tNT = uvc "tNT" (nounPhraseSP "TNT equivalent factor")
(Variable "TNT") Real
[ gtZeroConstr ] (dbl 1.0) defaultUncrt

standOffDist = uqcND "standOffDist" (nounPhraseSP "stand off distance")
(Variable "SD") metre Real
standOffDist = uq (constrained' (dqd sD (Variable "SD") Real metre)
[ gtZeroConstr,
sfwrc $ Bounded (Inc, sy sdMin) (Inc, sy sdMax)]
(dbl 45) defaultUncrt
--FIXME: ^ incorporate definition in here?
sfwrc $ Bounded (Inc, sy sdMin) (Inc, sy sdMax)] (dbl 45)) defaultUncrt

nomThick = cuc "nomThick"
(nounPhraseSent $ S "nominal thickness" +:+ displayDblConstrntsAsSet
nomThick nominalThicknesses)
lT millimetre {-DiscreteD nominalThicknesses-} Rational
[enumc nominalThicknesses] 8

-- the S "glass type" is supposed to be using "phrase glassTy"
-- but the problem is still the Capitalization issue with new
-- constructor `Ch` of generating the sentence. So for the sentence
-- only "S" can be capitalized
glassTypeCon = cvc "glassTypeCon" (nounPhraseSent $ S "glass type" +:+
displayStrConstrntsAsSet glassTypeCon (map (getAccStr . snd) glassType))
lG {-DiscreteS (map (getAccStr . snd) glassType)-} String
[EnumeratedStr Software $ map (getAccStr . snd) glassType] Nothing
glassTypeCon = constrainedNRV' (dqdNoUnit glassTy lG String)
[EnumeratedStr Software $ map (getAccStr . snd) glassType]

{--}

Expand Down Expand Up @@ -188,31 +178,25 @@ sdMin = mkQuantDef (unitary "sdMin"
{--}

symbols :: [UnitaryChunk]
symbols = [minThick, sflawParamK, sflawParamM, demand, tmDemand, lRe, tmLRe, nonFactorL, loadDur,
eqTNTWeight]
symbols = [minThick, sflawParamK, sflawParamM, loadDur] ++
map mkUnitary [demand, tmDemand, lRe, tmLRe, nonFactorL, eqTNTWeight]

minThick, sflawParamK, sflawParamM, demand, tmDemand, sdx, sdy, sdz, lRe, tmLRe, nonFactorL, loadDur,
eqTNTWeight :: UnitaryChunk
minThick, sflawParamK, sflawParamM, sdx, sdy, sdz, loadDur :: UnitaryChunk

demand = unitary "demand" (nounPhraseSP "applied load (demand)")
lQ pascal Rational --correct Space used?
demand, tmDemand, lRe, tmLRe, nonFactorL, eqTNTWeight :: UnitalChunk

tmDemand = unitary "tmDemand" (nounPhraseSP "applied load (demand) or pressure")
(Variable "Load") pascal Rational --correct Space used?

lRe = unitary "lRe" (nounPhraseSP "load resistance")
(Variable "LR") pascal Rational --correct Space used?
demand = ucs' demandq lQ Rational pascal --correct Space used?

tmLRe = unitary "tmLRe" (nounPhraseSP "capacity or load resistance")
(Variable "capacity") pascal Rational --correct Space used?
tmDemand = ucs' load (Variable "Load") Rational pascal --correct Space used?

lRe = ucs' loadResis (Variable "LR") Rational pascal --correct Space used?

nonFactorL = unitary "nonFactorL" (nounPhraseSP "non-factored load")
(Variable "NFL") pascal Rational --correct Space used?
tmLRe = ucs' capacity (Variable "capacity") Rational pascal --correct Space used?

nonFactorL = ucs' nonFactoredL (Variable "NFL") Rational pascal --correct Space used?

eqTNTWeight = unitary "eqTNTWeight"
(nounPhraseSP "explosive mass in equivalent weight of TNT")
(sub (eqSymb charWeight) (eqSymb tNT)) kilogram Real
eqTNTWeight = ucs' eqTNTChar (sub (eqSymb charWeight) (eqSymb tNT)) Real
kilogram

loadDur = unitary "loadDur" (nounPhraseSP "duration of load")
(sub lT lDur) second Real
Expand All @@ -238,15 +222,17 @@ sflawParamM = unitary "sflawParamM" (nounPhraseSP "surface flaw parameter") --pa
{-Quantities-}

unitless :: [QuantityDict]
unitless = [riskFun, isSafePb, isSafeProb, isSafeLR, isSafeLoad, stressDistFac, sdfTol,
dimlessLoad, tolLoad, loadSF, gTF, lDurFac]
unitless = [riskFun, isSafePb, isSafeProb, isSafeLR, isSafeLoad, stressDistFac,
sdfTol, dimlessLoad, tolLoad, lDurFac] ++ map qw [gTF, loadSF]

riskFun, isSafePb, isSafeProb, isSafeLR, isSafeLoad, stressDistFac, sdfTol,
dimlessLoad, tolLoad, loadSF, gTF, lDurFac :: QuantityDict
dimlessLoad, tolLoad, lDurFac :: QuantityDict

gTF, loadSF :: DefinedQuantityDict

dimlessLoad = vc "dimlessLoad" (nounPhraseSP "dimensionless load") (hat lQ) Real

gTF = vc "gTF" (glassTypeFac ^. term) (Variable "GTF") Integer
gTF = dqdNoUnit glTyFac (Variable "GTF") Integer

isSafePb = vc "isSafePb" (nounPhraseSP "probability of glass breakage safety requirement")
(Variable "is-safePb") Boolean
Expand All @@ -257,8 +243,8 @@ isSafeLR = vc "isSafeLR" (nounPhraseSP "3 second load equivalent resistance
isSafeLoad = vc "isSafeLoad" (nounPhraseSP "load resistance safety requirement")
(Variable "is-safeLoad") Boolean

lDurFac = vc'' loadDurFactor (Variable "LDF") Real
loadSF = vc'' lShareFac (Variable "LSF") Natural
lDurFac = vc'' loadDurFactor (Variable "LDF") Real
loadSF = dqdNoUnit loadShareFac (Variable "LSF") Natural

riskFun = vc "riskFun" (nounPhraseSP "risk of failure") cB Real

Expand Down Expand Up @@ -309,9 +295,9 @@ blastTy = dcc "blastTy" (nounPhraseSP "blast type")
"equivalent factor, and stand off distance from the point of explosion.")
bomb = dcc "bomb" (nounPhraseSP "bomb") ("a container filled " ++
"with a destructive substance designed to exlode on impact or via detonation")
capacity = dcc "capacity" (nounPhraseSP "capacity")
capacity = dcc "capacity" (nounPhraseSP "capacity or load resistance")
"load resistance calculated"
demandq = dcc "demandq" (nounPhraseSP "demand")
demandq = dcc "demandq" (nounPhraseSP "applied load (demand)")
"3 second duration equivalent pressure"
eqTNTChar = dcc "eqTNTChar" (nounPhraseSP "equivalent TNT charge mass")
("Mass of TNT placed on the ground in a hemisphere that represents the " ++
Expand Down Expand Up @@ -347,7 +333,7 @@ lateral = dcc "lateral" (nounPhraseSP "lateral")
lite = dcc "lite" (cn' "lite")
("Pieces of glass that are cut, prepared, and used to create the window " ++
"or door.")
load = dcc "load" (nounPhraseSP "load")
load = dcc "load" (nounPhraseSP "applied load (demand) or pressure")
"A uniformly distributed lateral pressure."
loadResis = cc' lResistance
(foldlSent [S "The uniform lateral load that a glass construction can sustain",
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-example/Drasil/Projectile/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ symbMap = cdb (qw pi_ : map qw physicscon ++ unitalQuants ++ symbols)
(nw projectileTitle : nw mass : nw inParam : [nw errMsg, nw program] ++
map nw doccon ++ map nw doccon' ++ map nw physicCon ++ map nw physicCon' ++
map nw physicscon ++ map nw mathcon ++ concepts ++ unitalIdeas ++
map nw acronyms ++ map nw symbols ++ map nw [metre, radian, second]) (cw pi_ : srsDomains)
map nw acronyms ++ map nw symbols ++ map nw [metre, radian, second]) (cw pi_ : map cw constrained ++ srsDomains)
(map unitWrapper [metre, radian, second]) dataDefs iMods genDefns tMods concIns [] []

usedDB :: ChunkDB
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-example/Drasil/SWHS/Unitals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ timeFinal = uqc "timeFinal" (nounPhraseSP "final time")
sfwrc $ UpTo (Exc, sy timeFinalMax)] (dbl 50000) defaultUncrt

timeStep = uqc "timeStep" (nounPhraseSP "time step for simulation")
("The finite discretization of time used in the numerical method" ++
("The finite discretization of time used in the numerical method " ++
"for solving the computational model")
(sub (eqSymb time) lStep) second Rational
[physc $ Bounded (Exc,0) (Exc, sy timeFinal)]
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-lang/Language/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module Language.Drasil (
, UnitalChunk(..), makeUCWDS
, uc, uc', ucs, ucs', ucsWS
-- Chunk.Unitary
, Unitary(..), UnitaryChunk, unitary, unitary', unit_symb
, Unitary(..), UnitaryChunk, unitary, unitary', mkUnitary, unit_symb
-- Chunk.Relation
, RelationConcept, makeRC
--Chunk.DefinedQuantity
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-printers/Language/Drasil/Plain/Print.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ specDoc f (E e) = pExprDoc f e
specDoc _ (S s) = text s
specDoc f (Sy u) = unitDoc f u
specDoc _ (Sp s) = specialDoc s
specDoc f (Ref _ r s) = specDoc f s <+> parens (text r)
specDoc f (Ref _ r s) = specDoc f s <+> text ("Ref: " ++ r)
specDoc f (s1 :+: s2) = specDoc f s1 <> specDoc f s2
specDoc _ EmptyS = empty
specDoc f (Quote s) = doubleQuotes $ specDoc f s
Expand Down
Loading

0 comments on commit 1e3e4a6

Please sign in to comment.