Skip to content

Commit

Permalink
Merge 0d426f4 into 40ace47
Browse files Browse the repository at this point in the history
  • Loading branch information
reid-spencer committed Oct 7, 2023
2 parents 40ace47 + 0d426f4 commit 6511f46
Show file tree
Hide file tree
Showing 32 changed files with 752 additions and 311 deletions.
16 changes: 12 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ lazy val utils = project
.configure(C.withScala3)
.configure(C.withCoverage(70))
.enablePlugins(BuildInfoPlugin)
.configure(
C.withBuildInfo("https://riddl.tech", "Ossum Inc.", "com.reactific.riddl.utils", "RiddlBuildInfo", 2019))
.configure(C.withBuildInfo("https://riddl.tech", "Ossum Inc.", "com.reactific.riddl.utils", "RiddlBuildInfo", 2019))
.settings(
name := "riddl-utils",
libraryDependencies ++= Seq(Dep.compress, Dep.lang3) ++ Dep.testing,
libraryDependencies ++= Seq(Dep.compress, Dep.lang3) ++ Dep.testing
)

val Language: Configuration = config("language")
Expand Down Expand Up @@ -118,6 +117,15 @@ lazy val stats: Project = project
.settings(name := "riddl-stats", libraryDependencies ++= Seq(Dep.pureconfig) ++ Dep.testing)
.dependsOn(commands % "compile->compile;test->test", testkit % "test->compile")

val DiagramsTrans = config("diagrams")
lazy val diagrams: Project = project
.in(file("diagrams"))
.configure(C.withCoverage(50))
.configure(C.withScala3)
.configure(C.mavenPublish)
.settings(name := "riddl-diagrams", libraryDependencies ++= Dep.testing)
.dependsOn(language, passes, testkit % "compile->test")

val Prettify = config("prettify")
lazy val prettify = project
.in(file("prettify"))
Expand All @@ -142,7 +150,7 @@ lazy val hugo: Project = project
Test / parallelExecution := false,
libraryDependencies ++= Seq(Dep.pureconfig) ++ Dep.testing
)
.dependsOn(passes % "compile->compile;test->test", commands, testkit % "test->compile", stats)
.dependsOn(passes % "compile->compile;test->test", commands, diagrams, testkit % "test->compile", stats)

lazy val scaladocSiteProjects = List(
(utils, Utils),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,54 @@ object CommandOptions {
noANSIMessages <- optional(objCur, "noANSIMessages", false)(cc => cc.asBoolean)
sortMessages <- optional(objCur, "sort-messages-by-location", noBool)(cc => cc.asBoolean.map(Option(_)))
suppressWarnings <- optional(objCur, "suppress-warnings", noBool)(cc => cc.asBoolean.map(Option(_)))
suppressStyleWarnings <-
optional(objCur, "suppress-style-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
suppressMissingWarnings <-
optional(objCur, "suppress-missing-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
hideWarnings <- optional(objCur, "hide-warnings", noBool)(cc => cc.asBoolean.map(Option(_)))
suppressStyleWarnings <- optional(objCur, "suppress-style-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
suppressMissingWarnings <- optional(objCur, "suppress-missing-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
suppressUsageWarnings <- optional(objCur, "suppress-usage-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
suppressInfoMessages <- optional(objCur, "suppress-info-messages", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
hideWarnings <- optional(objCur, "hide-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
hideStyleWarnings <- optional(objCur, "hide-style-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
hideMissingWarnings <-
optional(objCur, "hide-missing-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
hideMissingWarnings <- optional(objCur, "hide-missing-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
hideUsageWarnings <- optional(objCur, "hide-usage-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
hideInfoMessages <- optional(objCur, "hide-info-messages", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
showWarnings <- optional(objCur, "show-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
showStyleWarnings <- optional(objCur, "show-style-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
showMissingWarnings <-
optional(objCur, "show-missing-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
showUnusedWarnings <-
optional(objCur, "show-unused-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
showMissingWarnings <- optional(objCur, "show-missing-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
showUsageWarnings <- optional(objCur, "show-usage-warnings", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
showInfoMessages <- optional(objCur, "show-info-messages", noBool) { cc =>
cc.asBoolean.map(Option(_))
}
pluginsDir <- optional(objCur, "plugins-dir", Option.empty[Path]) { cc =>
cc.asString.map(f => Option(Path.of(f)))
}
maxParallel <- optional(objCur, "max-parallel-parsing", Some(4)) { cc =>
cc.asInt.map(Option(_))
}
yield {
val default = CommonOptions()
val shouldShowWarnings = suppressWarnings
Expand Down Expand Up @@ -158,19 +173,30 @@ object CommandOptions {
.map(!_)
.getOrElse(showStyleWarnings.getOrElse(default.showStyleWarnings))
)
val shouldShowUsage = suppressUsageWarnings
.map(!_)
.getOrElse(hideUsageWarnings.map(!_).getOrElse(showUsageWarnings.getOrElse(default.showUsageWarnings)))
val shouldShowInfos = suppressInfoMessages
.map(!_)
.getOrElse(
hideInfoMessages
.map(!_)
.getOrElse(showInfoMessages.getOrElse(default.showInfoMessages))
)
CommonOptions(
showTimes,
verbose,
dryRun,
quiet,
shouldShowWarnings,
shouldShowMissing,
shouldShowStyle,
showUsageWarnings = showUnusedWarnings
.getOrElse(default.showStyleWarnings),
showWarnings = shouldShowWarnings,
showMissingWarnings = shouldShowMissing,
showStyleWarnings = shouldShowStyle,
showUsageWarnings = shouldShowUsage,
showInfoMessages = shouldShowInfos,
debug,
pluginsDir,
sortMessagesByLocation = sortMessages.getOrElse(false)
sortMessagesByLocation = sortMessages.getOrElse(false),
maxParallelParsing = maxParallel.getOrElse(4)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,57 @@ object CommonOptionsHelper {
.optional()
.action((_, c) => c.copy(noANSIMessages = true))
.text("Do not print messages with ANSI formatting"),
opt [Unit] ('w', name = "suppress-warnings")
.optional()
.action((_, c) =>
c.copy(
showWarnings = false,
showMissingWarnings = false,
showStyleWarnings = false,
showUsageWarnings = false
)
)
.text("Suppress all warning messages so only errors are shown"),
opt[Unit]('w', name = "suppress-warnings")
.optional()
.action((_, c) =>
c.copy(
showWarnings = false,
showMissingWarnings = false,
showStyleWarnings = false,
showUsageWarnings = false
))
.text("Suppress all warning messages so only errors are shown"),
opt[Unit]('m', name = "suppress-missing-warnings")
.optional()
.action((_, c) => c.copy(showMissingWarnings = false))
.text("Show warnings about things that are missing"),
.text("Suppress warnings about things that are missing"),
opt[Unit]('s', name = "suppress-style-warnings")
.optional()
.action((_, c) => c.copy(showStyleWarnings = false))
.text("Show warnings about questionable input style. "),
opt[Unit]('u', name = "suppress-unused-warnings")
.text("Suppress warnings about questionable input style. "),
opt[Unit]('u', name = "suppress-usage-warnings")
.optional()
.action((_, c) => c.copy(showUsageWarnings = false))
.text("Suppress warnings about usage of definitions. "),
opt[Unit](name = "suppress-info-messages")
.optional()
.action((_, c) => c.copy(showInfoMessages = false))
.text("Suppress information output"),
opt[Unit]('w', name = "hide-warnings")
.optional()
.action((_, c) =>
c.copy(
showWarnings = false,
showMissingWarnings = false,
showStyleWarnings = false,
showUsageWarnings = false
)),
opt[Unit]('m', name = "hide-missing-warnings")
.optional()
.action((_, c) => c.copy(showMissingWarnings = false))
.text("Hide warnings about things that are missing"),
opt[Unit]('s', name = "hide-style-warnings")
.optional()
.action((_, c) => c.copy(showStyleWarnings = false))
.text("Hide warnings about questionable input style. "),
opt[Unit]('u', name = "hide-usage-warnings")
.optional()
.action((_, c) => c.copy(showUsageWarnings = false))
.text("Show warnings about questionable input style. "),
.text("Hide warnings about usage of definitions. "),
opt[Unit](name = "hide-info-messages")
.optional()
.action((_, c) => c.copy(showInfoMessages = false))
.text("Hide information output"),
opt[File]('P', name = "plugins-dir")
.optional()
.action((file, c) => c.copy(pluginsDir = Some(file.toPath)))
Expand All @@ -98,6 +126,12 @@ object CommonOptionsHelper {
.action((_, c) => c.copy(sortMessagesByLocation = true))
.text(
"Print all messages sorted by the file name and line number in which they occur."
),
opt[Int]('x', name = "max-parallel-processing")
.optional()
.action((v,c) => c.copy(maxParallelParsing = v))
.text(
"Controls the maximum number of include files that will be parsed in parallel"
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import org.scalatest.wordspec.AnyWordSpec
import java.nio.file.Path

class CommonOptionsTest extends AnyWordSpec with Matchers {
"RiddlOptions" should {
"CommonOptions" should {
"handle --suppress-warnings options" in {
val args = Array("--suppress-warnings")
val (common, _) = CommonOptionsHelper.parseCommonOptions(args)
common match {
case Some(options) =>
options.showWarnings mustBe false
options.showStyleWarnings mustBe false
options.showMissingWarnings mustBe false
case Some(config) =>
config.showWarnings mustBe false
config.showStyleWarnings mustBe false
config.showMissingWarnings mustBe false
config.showUsageWarnings mustBe false
config.showInfoMessages mustBe true
case None => fail("Failed to parse options")
}
}
Expand All @@ -33,6 +35,8 @@ class CommonOptionsTest extends AnyWordSpec with Matchers {
config.showWarnings mustBe true
config.showStyleWarnings mustBe false
config.showMissingWarnings mustBe true
config.showUsageWarnings mustBe true
config.showInfoMessages mustBe true
case None => fail("Failed to parse options")
}
}
Expand All @@ -45,10 +49,111 @@ class CommonOptionsTest extends AnyWordSpec with Matchers {
config.showWarnings mustBe true
config.showStyleWarnings mustBe true
config.showMissingWarnings mustBe false
config.showUsageWarnings mustBe true
config.showInfoMessages mustBe true
case None => fail("Failed to parse options")
}
}

"handle --suppress-usage-warnings options" in {
val args = Array("--suppress-usage-warnings")
val (common, _) = CommonOptionsHelper.parseCommonOptions(args)
common match {
case Some(config) =>
config.showWarnings mustBe true
config.showStyleWarnings mustBe true
config.showMissingWarnings mustBe true
config.showUsageWarnings mustBe false
config.showInfoMessages mustBe true
case None => fail("Failed to parse options")
}
}

"handle --suppress-info-messages options" in {
val args = Array("--suppress-info-messages")
val (common, _) = CommonOptionsHelper.parseCommonOptions(args)
common match {
case Some(config) =>
config.showWarnings mustBe true
config.showStyleWarnings mustBe true
config.showMissingWarnings mustBe true
config.showUsageWarnings mustBe true
config.showInfoMessages mustBe false
case None => fail("Failed to parse options")
}
}

"handle --hide-warnings options" in {
val args = Array("--hide-warnings")
val (common, _) = CommonOptionsHelper.parseCommonOptions(args)
common match {
case Some(config) =>
config.showWarnings mustBe false
config.showStyleWarnings mustBe false
config.showMissingWarnings mustBe false
config.showUsageWarnings mustBe false
config.showInfoMessages mustBe true
case None => fail("Failed to parse options")
}
}

"handle --hide-style-warnings options" in {
val args = Array("--hide-style-warnings")
val (common, _) = CommonOptionsHelper.parseCommonOptions(args)
common match {
case Some(config) =>
config.showWarnings mustBe true
config.showStyleWarnings mustBe false
config.showMissingWarnings mustBe true
config.showUsageWarnings mustBe true
config.showInfoMessages mustBe true
case None => fail("Failed to parse options")
}
}

"handle --hide-missing-warnings options" in {
val args = Array("--hide-missing-warnings")
val (common, _) = CommonOptionsHelper.parseCommonOptions(args)
common match {
case Some(config) =>
config.showWarnings mustBe true
config.showStyleWarnings mustBe true
config.showMissingWarnings mustBe false
config.showUsageWarnings mustBe true
config.showInfoMessages mustBe true
case None => fail("Failed to parse options")
}
}

"handle --hide-usage-warnings options" in {
val args = Array("--hide-usage-warnings")
val (common, _) = CommonOptionsHelper.parseCommonOptions(args)
common match {
case Some(config) =>
config.showWarnings mustBe true
config.showStyleWarnings mustBe true
config.showMissingWarnings mustBe true
config.showUsageWarnings mustBe false
config.showInfoMessages mustBe true
case None => fail("Failed to parse options")
}
}

"handle --hide-info-messages options" in {
val args = Array("--hide-info-messages")
val (common, _) = CommonOptionsHelper.parseCommonOptions(args)
common match {
case Some(config) =>
config.showWarnings mustBe true
config.showStyleWarnings mustBe true
config.showMissingWarnings mustBe true
config.showUsageWarnings mustBe true
config.showInfoMessages mustBe false
case None => fail("Failed to parse options")
}
}


"options at top level do not override in common object" in {
val optionFile = Path.of("riddlc/src/test/input/common-overrides.conf")
CommandOptions.loadCommonOptions(optionFile) match {
Expand Down
Empty file added content/Root/_index.md
Empty file.
1 change: 1 addition & 0 deletions content/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ geekdocToC: 4
---
| Term | Type | Brief Description |
| :---: | :---: | :--- |
| [`Root`](/) | [Root](https://riddl.tech/concepts/root/) | -- undefined -- |
| [`referenced`](/substitutions/referenced) | [Context](https://riddl.tech/concepts/context/) | -- undefined -- |
| [`substitutions`](/substitutions) | [Domain](https://riddl.tech/concepts/domain/) | -- undefined -- |
Loading

0 comments on commit 6511f46

Please sign in to comment.