Skip to content

Commit

Permalink
Replaced direct field access with sysInfo lens in CodeSpec.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinlu-Y committed Sep 11, 2024
1 parent f803135 commit 31a4181
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Language.Drasil.Code.Imperative.DrasilState (GenState, DrasilState(..),
genICName)
import Language.Drasil.Choices (ImplementationType(..), Structure(..),
InternalConcept(..))
import Language.Drasil.CodeSpec (CodeSpec(..))
import Language.Drasil.CodeSpec (CodeSpec(..), sysInfo)
import Language.Drasil.Mod (Description)
import Language.Drasil.Printers (SingleLine(OneLine), sentenceDoc)

Expand All @@ -24,6 +24,7 @@ import qualified Data.Map as Map (filter, lookup, null)
import Data.Maybe (mapMaybe)
import Control.Lens ((^.))
import Control.Monad.State (get)
import SysInfo.Drasil hiding (sysinfodb)

-- | Returns a module description based on a list of descriptions of what is
-- contained in the module.
Expand All @@ -40,7 +41,7 @@ unmodularDesc = do
implTypeStr Program = "program"
implTypeStr Library = "library"
return $ show $ sentenceDoc (sysinfodb spec) Implementation OneLine $ capSent $
foldlSent ([S "a", S (implTypeStr (implType g)), S "to"] ++ purpose spec)
foldlSent ([S "a", S (implTypeStr (implType g)), S "to"] ++ codeSpec g ^. sysInfo .purpose)

-- | Returns description of what is contained in the Input Parameters module.
-- If user chooses the 'Bundled' input parameter, this module will include the structure for holding the
Expand Down
23 changes: 12 additions & 11 deletions code/drasil-code/lib/Language/Drasil/Code/Imperative/Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ import Language.Drasil.Code.Lang (Lang(..))
import Language.Drasil.Choices (Choices(..), Modularity(..), Architecture(..),
Visibility(..), DataInfo(..), Constraints(..), choicesSent, DocConfig(..),
LogConfig(..), OptionalFeatures(..), InternalConcept(..))
import Language.Drasil.CodeSpec (CodeSpec(..), getODE)
import Language.Drasil.CodeSpec (CodeSpec(..), getODE, sysInfo)
import Language.Drasil.Printers (SingleLine(OneLine), sentenceDoc)

import Drasil.GOOL (OOProg, VisibilityTag(..),
ProgData(..), initialState)
import qualified Drasil.GOOL as OO (GSProgram, SFile, ProgramSym(..), unCI)
import Drasil.GProc (ProcProg)
import qualified Drasil.GProc as Proc (GSProgram, SFile, ProgramSym(..), unCI)
import SysInfo.Drasil hiding (sysinfodb)

import System.Directory (setCurrentDirectory, createDirectoryIfMissing,
getCurrentDirectory)
Expand Down Expand Up @@ -149,13 +150,13 @@ genPackage unRepr = do
-- prps = show $ sentenceDoc db Implementation OneLine
-- (foldlSent $ purpose $ codeSpec g)
prps = show $ sentenceDoc db Implementation OneLine
(foldlSent $ sysInfo ^. purpose)
(foldlSent $ codeSpec g ^. sysInfo .purpose)
bckgrnd = show $ sentenceDoc db Implementation OneLine
(foldlSent $ background $ codeSpec g)
(foldlSent $ codeSpec g ^. sysInfo . background)
mtvtn = show $ sentenceDoc db Implementation OneLine
(foldlSent $ motivation $ codeSpec g)
(foldlSent $ codeSpec g ^. sysInfo . motivation)
scp = show $ sentenceDoc db Implementation OneLine
(foldlSent $ scope $ codeSpec g)
(foldlSent $ codeSpec g ^. sysInfo . scope)
i <- genSampleInput
d <- genDoxConfig s
rm <- genReadMe ReadMeInfo {
Expand All @@ -182,7 +183,7 @@ genProgram = do
g <- get
ms <- chooseModules $ modular g
let n = pName $ codeSpec g
let p = show $ sentenceDoc (sysinfodb $ codeSpec g) Implementation OneLine $ foldlSent $ purpose $ codeSpec g
let p = show $ sentenceDoc (sysinfodb $ codeSpec g) Implementation OneLine $ foldlSent $ codeSpec g ^. sysInfo .purpose
return $ OO.prog n p ms

-- | Generates either a single module or many modules, based on the users choice
Expand Down Expand Up @@ -261,13 +262,13 @@ genPackageProc unRepr = do
cfp = configFiles $ codeSpec g
db = sysinfodb $ codeSpec g
prps = show $ sentenceDoc db Implementation OneLine
(foldlSent $ purpose $ codeSpec g)
(foldlSent $ codeSpec g ^. sysInfo .purpose)
bckgrnd = show $ sentenceDoc db Implementation OneLine
(foldlSent $ background $ codeSpec g)
(foldlSent $ codeSpec g ^. sysInfo . background)
mtvtn = show $ sentenceDoc db Implementation OneLine
(foldlSent $ motivation $ codeSpec g)
(foldlSent $ codeSpec g ^. sysInfo . motivation)
scp = show $ sentenceDoc db Implementation OneLine
(foldlSent $ scope $ codeSpec g)
(foldlSent $ codeSpec g ^. sysInfo . scope)
i <- genSampleInput
d <- genDoxConfig s
rm <- genReadMe ReadMeInfo {
Expand All @@ -294,7 +295,7 @@ genProgramProc = do
g <- get
ms <- chooseModulesProc $ modular g
let n = pName $ codeSpec g
let p = show $ sentenceDoc (sysinfodb $ codeSpec g) Implementation OneLine $ foldlSent $ purpose $ codeSpec g
let p = show $ sentenceDoc (sysinfodb $ codeSpec g) Implementation OneLine $ foldlSent $ codeSpec g ^. sysInfo .purpose
return $ Proc.prog n p ms

-- | Generates either a single module or many modules, based on the users choice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Drasil.DocumentLanguage.TraceabilityGraph where

import Language.Drasil
import Database.Drasil hiding (cdb)
import SysInfo.Drasil
import SysInfo.Drasil hiding (purpose)
import Control.Lens ((^.))
import qualified Data.Map as Map
import Drasil.DocumentLanguage.TraceabilityMatrix (TraceViewCat, traceMReferees, traceMReferrers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Drasil.DocumentLanguage.TraceabilityMatrix where

import Language.Drasil
import Database.Drasil hiding (cdb)
import SysInfo.Drasil
import SysInfo.Drasil hiding (purpose)
import qualified Language.Drasil.Sentence.Combinators as S

import Data.Drasil.Concepts.Documentation (purpose, component, dependency,
Expand Down

0 comments on commit 31a4181

Please sign in to comment.