Skip to content

Commit 06e7928

Browse files
committed
Add code comments for unmodular code generation.
1 parent 1a9a916 commit 06e7928

File tree

25 files changed

+47
-22
lines changed

25 files changed

+47
-22
lines changed

code/drasil-code/lib/Language/Drasil/Choices.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,15 @@ makeDocConfig = DocConfig
209209
data Comments = CommentFunc -- ^ Function/method-level comments.
210210
| CommentClass -- ^ Class-level comments.
211211
| CommentMod -- ^ File/Module-level comments.
212+
| CommentVarDecls -- ^ Variable declarations comments.
212213
deriving Eq
213214

214215
-- | Renders options for implementation of comments.
215216
instance RenderChoices Comments where
216217
showChs CommentFunc = S "CommentFunc"
217218
showChs CommentClass = S "CommentClass"
218219
showChs CommentMod = S "CommentMod"
220+
showChs CommentVarDecls = S "CommentVarDecls"
219221

220222
-- | Doxygen file verbosity options.
221223
data Verbosity = Verbose | Quiet

code/drasil-code/lib/Language/Drasil/Code/Imperative/Modules.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import Drasil.GOOL (MSBody, MSBlock, SVariable, SValue, MSStatement,
6262
DeclStatement(..), OODeclStatement(..), objDecNewNoParams,
6363
extObjDecNewNoParams, IOStatement(..), ControlStatement(..), ifNoElse,
6464
VisibilitySym(..), MethodSym(..), StateVarSym(..), pubDVar, convType,
65-
convTypeOO, VisibilityTag(..))
65+
convTypeOO, VisibilityTag(..), CommentStatement(..))
6666

6767
import qualified Drasil.GOOL as OO (SFile)
6868
import Drasil.GProc (ProcProg)
@@ -114,7 +114,7 @@ modularMainFunc = do
114114
varDef <- mapM genCalcCall (codeSpec g ^. execOrderO)
115115
wo <- genOutputCall
116116
let mainW = if CommentFunc `elem` commented g then docMain else mainFunction
117-
return $ Just $ mainW $ bodyStatements $
117+
return $ Just $ mainW $ bodyStatements $
118118
initLogFileVar (logKind g) mainFn ++ varDecDef v_filename mainFn (arg 0)
119119
: logInFile
120120
-- Constants must be declared before inputs because some derived input
@@ -134,7 +134,7 @@ unmodularMainFunc = do
134134
varDef <- mapM declVarCalc (codeSpec g ^. execOrderO)
135135
wo <- genOutputCall
136136
let mainW = if CommentFunc `elem` commented g then docMain else mainFunction
137-
return $ Just $ mainW $ bodyStatements $
137+
return $ Just $ mainW $ bodyStatements $
138138
initLogFileVar (logKind g) mainFn ++ varDecDef v_filename mainFn (arg 0)
139139
: logInFile
140140
-- Constants must be declared before inputs because some derived input
@@ -150,7 +150,10 @@ declVarCalc c = do
150150
val' <- convExpr val
151151
v <- mkVar (quantvar c)
152152
l <- maybeLog v
153-
return $ pure ((multi . (: l) . varDecDef v scp) val')
153+
cmnt <- getComment c
154+
let cmnt' = [comment cmnt | CommentVarDecls `elem` commented g]
155+
statements = cmnt' ++ varDecDef v scp val' : l
156+
return $ pure $ multi statements
154157

155158
-- | If there are no inputs, the 'inParams' object still needs to be declared
156159
-- if inputs are 'Bundled', constants are stored 'WithInputs', and constant

code/drasil-example/projectile/lib/Drasil/Projectile/Choices.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ baseChoices = defaultChoices {
117117
dataInfo = makeData Unbundled WithInputs Var,
118118
maps = makeMaps (matchConcepts [(piConst, [Pi])]) spaceToCodeType,
119119
optFeats = makeOptFeats
120-
(makeDocConfig [CommentFunc, CommentClass, CommentMod] Quiet Hide)
120+
(makeDocConfig [CommentFunc, CommentClass, CommentMod, CommentVarDecls] Quiet Hide)
121121
(makeLogConfig [] "log.txt")
122122
[SampleInput "../../../datafiles/projectile/sampleInput.txt", ReadME],
123123
srsConstraints = makeConstraints Warning Warning,

code/stable/projectile/projectile_m_l_nol_u_u_v_f/src/cpp/designLog.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/stable/projectile/projectile_m_l_nol_u_u_v_f/src/csharp/designLog.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/stable/projectile/projectile_m_l_nol_u_u_v_f/src/java/designLog.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/stable/projectile/projectile_m_l_nol_u_u_v_f/src/julia/designLog.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/stable/projectile/projectile_m_l_nol_u_u_v_f/src/python/designLog.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/stable/projectile/projectile_m_l_nol_u_u_v_f/src/swift/designLog.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/stable/projectile/projectile_m_p_nol_b_u_v_d/src/cpp/designLog.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)