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

Reconcile _some_ conflicting/implicit knowledge about 'program' names during generation of various artifacts #3665

Merged
merged 6 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
10 changes: 5 additions & 5 deletions code/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ BATCHTERM=dumb
#--- Actual targets ---#
########################

# Default `make` will just run examples and test them against stable.
# See `test` target for more details.
all: test ##@Examples Run examples and test against stable.
# Default `make` will just run examples and test them against stable. See `test`
# target for more details.
all: test test_website ##@Examples Run examples and test against stable.
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved

install: ##@Examples Install all example project binaries into your local binary path (see $(stack path) for local-bin-path).
stack install $(stackArgs)
Expand Down Expand Up @@ -239,7 +239,7 @@ test: $(TEST_EXAMPLES) ##@Examples Run all examples and compare against the stab

# First builds the website and then tests the generated contenst with those in
# the stable-website folder.
test_website: $(TEST_WEBSITE)
test_website: $(TEST_WEBSITE) ##@Website Test freshly generated website against last known 'stable' copy.
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved
@echo ---------------------------------------
@echo Testing Website complete, checking logs
@echo ---------------------------------------
Expand All @@ -254,7 +254,7 @@ stabilize: $(STABILIZE_EXAMPLES) ##@Examples Overwrites the stable folder with u

# First build the website, and then overwrite the contents in the stable-website
# folder with currently generated ones.
website_stabilize: $(STABILIZE_WEBSITE)
website_stabilize: $(STABILIZE_WEBSITE) ##@Website Stabilize a freshly generated copy of the website artifacts.
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved
@echo ----------------------------
@echo Stabilized website artifacts
@echo ----------------------------
Expand Down
5 changes: 2 additions & 3 deletions code/drasil-docLang/lib/Drasil/DocumentLanguage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import Control.Lens ((^.), set)
import Data.Function (on)
import Data.List (nub, sortBy, sortOn)
import qualified Data.Map as Map (elems, toList, assocs, keys)
import Data.Char (isSpace)
import Data.Maybe (maybeToList)
import Drasil.Sections.ReferenceMaterial (emptySectSentPlu)

Expand Down Expand Up @@ -179,7 +178,7 @@ fillReferences dd si@SI{_sys = sys} = si2
-- set new reference table in the chunk database
chkdb2 = set refTable (idMap $ nub $ refsFromSRS ++ inRefs
++ map (ref.makeTabRef'.getTraceConfigUID) (traceMatStandard si) ++ secRefs -- secRefs can be removed once #946 is complete
++ traceyGraphGetRefs (filter (not.isSpace) $ abrv sys) ++ map ref cites
++ traceyGraphGetRefs (programName sys) ++ map ref cites
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved
++ map ref conins ++ map ref ddefs ++ map ref gdefs ++ map ref imods
++ map ref tmods ++ map ref concIns ++ map ref secs ++ map ref lblCon
++ refs) chkdb
Expand Down Expand Up @@ -425,7 +424,7 @@ introChgs xs _ = foldlSP [S "This", phrase Doc.section_, S "lists the",
mkTraceabilitySec :: TraceabilitySec -> SystemInformation -> Section
mkTraceabilitySec (TraceabilityProg progs) si@SI{_sys = sys} = TG.traceMGF trace
(map (\(TraceConfig _ pre _ _ _) -> foldlList Comma List pre) fProgs)
(map LlC trace) (filter (not.isSpace) $ abrv sys) []
(map LlC trace) (programName sys) []
where
trace = map (\(TraceConfig u _ desc cols rows) -> TM.generateTraceTableView
u desc cols rows si) fProgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Data.Maybe (fromMaybe)
import Data.Drasil.Concepts.Math (graph)
import Data.Drasil.Concepts.Documentation (traceyGraph, component, dependency, reference, purpose, traceyMatrix)
import qualified Language.Drasil.Sentence.Combinators as S
import Data.Char (isSpace, toLower)
import Data.Char (toLower)
import Drasil.Sections.ReferenceMaterial (emptySectSentPlu)

-- * Main Functions
Expand Down Expand Up @@ -187,10 +187,10 @@ traceyGraphPath :: String -> String -> String

traceGFiles = ["avsa", "avsall", "refvsref", "allvsr", "allvsall"]
traceGUIDs = map mkUid ["TraceGraphAvsA", "TraceGraphAvsAll", "TraceGraphRefvsRef", "TraceGraphAllvsR", "TraceGraphAllvsAll"]
traceyGraphPaths ex = map (\x -> resourcePath ++ map toLower (filter (not.isSpace) ex) ++ "/" ++ x ++ ".svg") traceGFiles
traceyGraphGetRefs ex = map makeFigRef' traceGUIDs ++ zipWith (\x y -> Reference (x +++. "Link") (URI y) (shortname' $ S $ show x)) traceGUIDs (traceyGraphPaths $ map toLower $ filter (not.isSpace) ex)
traceyGraphPaths ex = map (\x -> resourcePath ++ map toLower ex ++ "/" ++ x ++ ".svg") traceGFiles
traceyGraphGetRefs ex = map makeFigRef' traceGUIDs ++ zipWith (\x y -> Reference (x +++. "Link") (URI y) (shortname' $ S $ show x)) traceGUIDs (traceyGraphPaths $ map toLower ex)
-- for actual use in creating the graph figures
traceyGraphPath ex f = resourcePath ++ map toLower (filter (not.isSpace) ex) ++ "/" ++ f ++ ".svg"
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved
traceyGraphPath ex f = resourcePath ++ map toLower ex ++ "/" ++ f ++ ".svg"

-- | Traceability graphs reference path.
resourcePath :: String
Expand Down
9 changes: 7 additions & 2 deletions code/drasil-lang/lib/Language/Drasil/Chunk/CodeVar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-- | Defines chunk types for use in code generation.
module Language.Drasil.Chunk.CodeVar where

import Data.Char (isSpace)
import Control.Lens ((^.), view, makeLenses, Lens')

import Language.Drasil.Classes (CommonIdea(abrv), Quantity, Idea(getA), NamedIdea(..), Callable)
Expand Down Expand Up @@ -30,9 +31,13 @@ class CodeIdea c where
class CodeIdea c => DefiningCodeExpr c where
codeExpr :: Lens' c CodeExpr

-- | Convert the program name to an abbreviated 'String' without any special characters.
-- | Convert an abbreviation into one deemed 'code-friendly', removing spaces,
-- and replacing special characters with underscores.
--
-- FIXME: This should NOT be treated as a 'getter', but something we cache
-- local to something that has a 'program name'.
programName :: CommonIdea c => c -> String
programName = toPlainName . abrv
programName = toPlainName . filter (not . isSpace) . abrv

-- | Used when a function name needs to be distinguishable from a variable name.
funcPrefix :: String
Expand Down
7 changes: 4 additions & 3 deletions code/drasil-utils/lib/Utils/Drasil/Strings.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ module Utils.Drasil.Strings (

import Utils.Drasil.Lists (replaceAll)

-- | Replace occurences of special characters (@",~`-=!@#$%^&*+[]\\;'/|\"<>? "@) with underscores (@"_"@).
-- | Replace occurences of special characters (@",~`-=!@#$%^&*+[]\\;'/|\"<>? "@)
-- with underscores (@"_"@).
--
-- TODO: This can probably become a bit more comprehensive,
-- anything other than a-z, A-Z, or 0-9 could probably be replaced.
-- TODO: This can probably become a bit more comprehensive, anything other
-- than a-z, A-Z, or 0-9 could probably be replaced.
toPlainName :: String -> String
toPlainName = replaceAll ",~`-=!@#$%^&*+[]\\;'/|\"<>? " '_'
2 changes: 1 addition & 1 deletion code/drasil-website/lib/Drasil/Website/CaseStudy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ getConRep Const = S "C"
getRealNum :: [CodeType] -> Sentence
getRealNum (Double:_) = S "D"
getRealNum (Float:_) = S "F"
getRealNum _ = error "This shouldn't happen. Make sure Real numbers have a preferred type."
getRealNum _ = error "This shouldn't happen. Make sure Real numbers have a preferred type."
29 changes: 16 additions & 13 deletions code/drasil-website/lib/Drasil/Website/Example.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Drasil.Website.Example where
import Language.Drasil hiding (E)
import SysInfo.Drasil (SystemInformation(..))
import Language.Drasil.Code (Choices(..), Lang(..))
import Data.Char (toLower, isSpace)
import Data.Char (toLower)

import qualified Drasil.DblPend.Body as DblPend (fullSI)
import qualified Drasil.GamePhysics.Body as GamePhysics (fullSI)
Expand Down Expand Up @@ -79,16 +79,16 @@ fullExList codePth srsDoxPth = Enumeration $ Bullet $ map (, Nothing) (allExampl
allExampleList :: [Example] -> [ItemType]
allExampleList = map (\x -> Nested (nameAndDesc x) $ Bullet $ map (, Nothing) (individualExList x))
where
nameAndDesc E{sysInfoE = SI{_sys = sys, _purpose = purp}} = S (programName sys) +:+ S " - To" +:+. head purp
nameAndDesc E{sysInfoE = SI{_sys = sys, _purpose = purp}} = S (abrv sys) +:+ S " - To" +:+. head purp
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved

-- | Display the points for generated documents and call 'versionList' to display the code.
individualExList :: Example -> [ItemType]
-- No choices mean no generated code, so we do not need to display generated code and thus do not call versionList.
individualExList E{sysInfoE = SI{_sys = sys}, choicesE = [], codePath = srsP} =
[Flat $ S (programName sys ++ "_SRS") +:+ namedRef (getSRSRef srsP "html" $ programName sys) (S "[HTML]") +:+ namedRef (getSRSRef srsP "pdf" $ programName sys) (S "[PDF]")]
[Flat $ S "SRS:" +:+ namedRef (getSRSRef srsP "html" $ programName sys) (S "[HTML]") +:+ namedRef (getSRSRef srsP "pdf" $ programName sys) (S "[PDF]")]
-- Anything else means we need to display program information, so use versionList.
individualExList ex@E{sysInfoE = SI{_sys = sys}, codePath = srsP} =
[Flat $ S (programName sys ++ "_SRS") +:+ namedRef (getSRSRef srsP "html" $ programName sys) (S "[HTML]") +:+ namedRef (getSRSRef srsP "pdf" $ programName sys) (S "[PDF]"),
[Flat $ S "SRS:" +:+ namedRef (getSRSRef srsP "html" $ programName sys) (S "[HTML]") +:+ namedRef (getSRSRef srsP "pdf" $ programName sys) (S "[PDF]"),
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved
Nested (S generatedCodeTitle) $ Bullet $ map (, Nothing) (versionList getCodeRef ex),
Nested (S generatedCodeDocsTitle) $ Bullet $ map (, Nothing) (versionList getDoxRef noSwiftEx)]
where
Expand Down Expand Up @@ -178,8 +178,8 @@ getCodeRef ex@E{sysInfoE=SI{_sys = sys}, choicesE = chcs} l verName =

-- System name, different between one set of choices and multiple sets.
sysName = case chcs of
[_] -> map toLower $ filter (not.isSpace) $ programName sys
_ -> map toLower (filter (not.isSpace) $ programName sys) ++ "/" ++ verName
[_] -> map toLower $ programName sys
_ -> map toLower (programName sys) ++ "/" ++ verName
-- Program language converted for use in file folder navigation.
programLang = convertLang l

Expand All @@ -188,11 +188,11 @@ getDoxRef :: Example -> Lang -> String -> Reference
getDoxRef ex@E{sysInfoE=SI{_sys = sys}, choicesE = chcs} l verName =
makeURI refUID refURI refShortNm
where
refUID = "doxRef" ++ sysName ++ programLang
refURI = getDoxPath (srsDoxPath ex) sysName programLang
refUID = "doxRef" ++ progName ++ programLang
refURI = getDoxPath (srsDoxPath ex) progName programLang
refShortNm = shortname' $ S refUID

sysName = filter (not.isSpace) $ programName sys
progName = programName sys
-- Here is the only difference from getCodeRef. When there is more than one set of choices,
-- we append version name to program language since the organization of folders follows this way.
programLang = case chcs of
Expand All @@ -208,15 +208,18 @@ getSRSRef path sufx ex = makeURI refUID (getSRSPath path (map toLower sufx) ex)
-- | Get the paths of where each reference exist for SRS files. Some example abbreviations have spaces,
-- so we just filter those out. The suffix should only be either html or pdf.
getSRSPath :: FilePath -> String -> String -> FilePath
getSRSPath path sufx ex = path ++ map toLower (filter (not.isSpace) ex)
++ "/SRS/srs/" ++ filter (not.isSpace) ex ++ "_SRS." ++ map toLower sufx
getSRSPath path sufx ex =
path
++ map toLower ex -- FIXME: The majority of these `map toLower`s are implicit knowledge!!!
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved
++ "/SRS/srs/"
++ ex ++ "_SRS." ++ map toLower sufx

-- | Get the file paths for generated code and doxygen locations.
getCodePath, getDoxPath :: FilePath -> String -> String -> FilePath
-- | Uses 'repoRt' path (codePath in this module).
getCodePath path ex programLang = path ++ "code/stable/" ++ map toLower (filter (not.isSpace) ex) ++ "/src/" ++ programLang -- need repoCommit path
getCodePath path ex programLang = path ++ "code/stable/" ++ map toLower ex ++ "/src/" ++ programLang -- need repoCommit path
-- | Uses 'exRt' path (srsDoxPath in this module).
getDoxPath path ex programLang = path ++ map toLower (filter (not.isSpace) ex) ++ "/doxygen/" ++ programLang ++ "/index.html" -- need example path
getDoxPath path ex programLang = path ++ map toLower ex ++ "/doxygen/" ++ programLang ++ "/index.html" -- need example path

-- | Gather all references used in making the Examples section.
exampleRefs :: FilePath -> FilePath -> [Reference]
Expand Down
28 changes: 14 additions & 14 deletions code/stable-website/index.html

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

Loading
Loading