Skip to content

Commit

Permalink
Change using directive to specia comemnt syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
romanowski committed Jan 18, 2022
1 parent 2ee729f commit 202f37a
Show file tree
Hide file tree
Showing 44 changed files with 326 additions and 325 deletions.
4 changes: 2 additions & 2 deletions examples/cross-build/Hello.js.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// using scala 2.13
// using target scala-js
//> using scala 2.13
//> using target scala-js

import scala.scalajs.js

Expand Down
4 changes: 2 additions & 2 deletions examples/cross-build/Hello.native.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// using scala 2.13
// using target scala-native
//> using scala 2.13
//> using target scala-native

import scala.scalanative.libc._
import scala.scalanative.unsafe._
Expand Down
2 changes: 1 addition & 1 deletion examples/scala-versions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Using directives syntax is still experimental and may change in future versions
So when we will have:

```scala title=version.scala
// using scala 2.12.5
//> using scala 2.12.5

object OldCode
//rest of the config
Expand Down
2 changes: 1 addition & 1 deletion examples/scala-versions/version.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File was generated from based on docs/cookbooks/scala-versions.md, do not edit manually!

// using scala 2.12.5
//> using scala 2.12.5

object OldCode
//rest of the config
2 changes: 1 addition & 1 deletion examples/scripting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ print all files located in path passed as the first argument
Create a file name `ls.sc`
```scala
#!/usr/bin/env scala-cli
// using lib "com.lihaoyi::os-lib:0.7.8"
//> using lib "com.lihaoyi::os-lib:0.7.8"
val cwd = if(args.nonEmpty) os.Path(args(0), os.pwd) else os.pwd
println(os.list(cwd).map(_.last).mkString("\n"))
```
Expand Down
2 changes: 1 addition & 1 deletion examples/utest/MyTests.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// using lib "com.lihaoyi::utest::0.7.10"
//> using lib "com.lihaoyi::utest::0.7.10"

import utest._

Expand Down
6 changes: 3 additions & 3 deletions gcbenchmark/gcbenchmark.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// using lib "com.lihaoyi::os-lib:0.8.0"
// using lib "com.lihaoyi::pprint:0.7.1"
// using scala "2.13"
//> using lib "com.lihaoyi::os-lib:0.8.0"
//> using lib "com.lihaoyi::pprint:0.7.1"
//> using scala "2.13"

// Usage: scala-cli gcbenchmark.scala -- <path_to_scala_cli_executable>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import scala.build.preprocessing.{ScopePath, Scoped}
case object RequirePlatformsDirectiveHandler extends RequireDirectiveHandler {
def name = "Platform"
def description = "Require a Scala platform for the current file"
def usage = "// using target.platform _platform_"
override def usageMd = "`// using target.platform `_platform_"
def usage = "//> using target.platform _platform_"
override def usageMd = "`//> using target.platform `_platform_"
override def examples = Seq(
"// using target.platform \"scala-js\"",
"// using target.platform \"scala-js\", \"scala-native\"",
"// using target.platform \"jvm\""
"//> using target.platform \"scala-js\"",
"//> using target.platform \"scala-js\", \"scala-native\"",
"//> using target.platform \"jvm\""
)

override def keys: Seq[String] = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import scala.build.preprocessing.{ScopePath, Scoped}
case object RequireScalaVersionDirectiveHandler extends RequireDirectiveHandler {
def name = "Scala version"
def description = "Require a Scala version for the current file"
def usage = "// using target.scala _version_"
override def usageMd = "`// using target.scala `_version_"
def usage = "//> using target.scala _version_"
override def usageMd = "`//> using target.scala `_version_"
override def examples = Seq(
"// using target.scala \"3\"",
"// using target.scala.>= \"2.13\"",
"// using target.scala.< \"3.0.2\""
"//> using target.scala \"3\"",
"//> using target.scala.>= \"2.13\"",
"//> using target.scala.< \"3.0.2\""
)

override def keys: Seq[String] = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import scala.build.preprocessing.{ScopePath, Scoped}
case object RequireScopeDirectiveHandler extends RequireDirectiveHandler {
def name = "Scope"
def description = "Require a scope for the current file"
def usage = "// using target.scope _scope_"
override def usageMd = "`// using target.scope `_scope_"
def usage = "//> using target.scope _scope_"
override def usageMd = "`//> using target.scope `_scope_"
override def examples = Seq(
"// using target.scope \"test\""
"//> using target.scope \"test\""
)

override def keys: Seq[String] = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ case object UsingCompilerPluginDirectiveHandler extends UsingDirectiveHandler {
def name = "Compiler plugins"
def description = "Adds compiler plugins"
def usage =
"// using plugin \"org:name:ver\" | // using plugins \"org:name:ver\", \"org2:name2:ver2\""
"//> using plugin \"org:name:ver\" | //> using plugins \"org:name:ver\", \"org2:name2:ver2\""
override def usageMd = "`using plugin `_org_`:`name`:`ver"
override def examples = Seq(
"// using plugin \"org.typelevel:::kind-projector:0.13.2\""
"//> using plugin \"org.typelevel:::kind-projector:0.13.2\""
)

private def parseDependency(depStr: String): Either[BuildException, AnyDependency] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import scala.build.preprocessing.ScopePath
case object UsingCustomJarDirectiveHandler extends UsingDirectiveHandler {
def name = "Custom JAR"
def description = "Manually add JAR(s) to the class path"
def usage = "`// using jar `_path_ | `// using jars `_path1_, _path2_ …"
def usage = "`//> using jar `_path_ | `//> using jars `_path1_, _path2_ …"
override def usageMd =
"""// using jar _path_
"""//> using jar _path_
|
|// using jars _path1_, _path2_ …""".stripMargin
|//> using jars _path1_, _path2_ …""".stripMargin

override def examples = Seq(
"// using jar \"/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar\""
"//> using jar \"/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar\""
)

override def keys = Seq("jar", "jars")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import scala.build.{Logger, Positioned}
case object UsingDependencyDirectiveHandler extends UsingDirectiveHandler {
def name = "Dependency"
def description = "Add dependencies"
def usage = "// using lib \"org:name:ver\" | // using libs \"org:name:ver\", \"org2:name2:ver2\""
override def usageMd = "`// using lib \"`_org_`:`name`:`ver\""
def usage =
"//> using lib \"org:name:ver\" | //> using libs \"org:name:ver\", \"org2:name2:ver2\""
override def usageMd = "`//> using lib \"`_org_`:`name`:`ver\""
override def examples = Seq(
"// using lib \"org.scalatest::scalatest:3.2.10\"",
"// using lib \"org.scalameta::munit:0.7.29\""
"//> using lib \"org.scalatest::scalatest:3.2.10\"",
"//> using lib \"org.scalameta::munit:0.7.29\""
)

private def parseDependency(depStr: String): Either[BuildException, AnyDependency] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import scala.build.{Logger, Positioned}
case object UsingJavaHomeDirectiveHandler extends UsingDirectiveHandler {
def name = "Java home"
def description = "Sets Java home used to run your application or tests"
def usage = "// using java-home|javaHome _path_"
def usage = "//> using java-home|javaHome _path_"
override def usageMd =
"""`// using java-home `_path_
"""`//> using java-home `_path_
|
|`// using javaHome `_path_""".stripMargin
|`//> using javaHome `_path_""".stripMargin
override def examples = Seq(
"// using java-home \"/Users/Me/jdks/11\""
"//> using java-home \"/Users/Me/jdks/11\""
)

override def keys = Seq("java-home", "javaHome")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import scala.build.preprocessing.ScopePath
case object UsingJavaOptionsDirectiveHandler extends UsingDirectiveHandler {
def name = "Java options"
def description = "Add Java options"
def usage = "// using java-opt _options_ | // using javaOpt _options_"
def usage = "//> using java-opt _options_ | //> using javaOpt _options_"
override def usageMd =
"""`// using java-opt `_options_
"""`//> using java-opt `_options_
|
|`// using javaOpt `_options_""".stripMargin
|`//> using javaOpt `_options_""".stripMargin
override def examples = Seq(
"// using javaOpt \"-Xmx2g\", \"-Dsomething=a\""
"//> using javaOpt \"-Xmx2g\", \"-Dsomething=a\""
)

override def keys = Seq("javaOpt", "javaOptions", "java-opt", "java-options")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import scala.build.{Logger, Positioned}
case object UsingJavaPropsDirectiveHandler extends UsingDirectiveHandler {
def name = "Java properties"
def description = "Add Java properties"
def usage = "// using java-prop|javaProp _key=val_"
def usage = "//> using java-prop|javaProp _key=val_"
override def usageMd =
"""`// using javaProp_ `_key=value_
|`// using javaProp_ `_key_""".stripMargin
"""`//> using javaProp_ `_key=value_
|`//> using javaProp_ `_key_""".stripMargin
override def examples = Seq(
"// using javaProp \"foo1=bar\", \"foo2\""
"//> using javaProp \"foo1=bar\", \"foo2\""
)

override def keys = Seq("javaProp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ case object UsingMainClassDirectiveHandler extends UsingDirectiveHandler {
def name = "Main class"
def description = "Specify default main class"

def usage = "// using main-class _main class_ | // using mainClass _main class_"
def usage = "//> using main-class _main class_ | //> using mainClass _main class_"

override def usageMd =
"""`// using main-class `_main class_
"""`//> using main-class `_main class_
|
|`// using mainClass `_main class_""".stripMargin
|`//> using mainClass `_main class_""".stripMargin

override def examples = Seq(
"// using main-class \"helloWorld\""
"//> using main-class \"helloWorld\""
)

override def keys = Seq("main-class", "mainClass")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ case object UsingOptionDirectiveHandler extends UsingDirectiveHandler {
def description = "Add Scala compiler options"
def usage = "using option _option_ | using options _option1_ _option2_ …"
override def usageMd =
"""`// using option `_option_
"""`//> using option `_option_
|
|`// using options `_option1_, _option2_ …""".stripMargin
|`//> using options `_option1_, _option2_ …""".stripMargin
override def examples = Seq(
"// using option \"-Xasync\"",
"// using options \"-Xasync\", \"-Xfatal-warnings\""
"//> using option \"-Xasync\"",
"//> using options \"-Xasync\", \"-Xfatal-warnings\""
)

override def keys = Seq("option", "options")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import scala.build.{Logger, Positioned}
case object UsingPlatformDirectiveHandler extends UsingDirectiveHandler {
def name = "Platform"
def description = "Set the default platform to Scala.JS or Scala Native"
def usage = "// using platform (jvm|scala-js|scala-native)+"
override def usageMd = "`// using platform `(`jvm`|`scala-js`|`scala-native`)+"
def usage = "//> using platform (jvm|scala-js|scala-native)+"
override def usageMd = "`//> using platform `(`jvm`|`scala-js`|`scala-native`)+"
override def examples = Seq(
"// using platform \"scala-js\"",
"// using platform \"jvm\", \"scala-native\""
"//> using platform \"scala-js\"",
"//> using platform \"jvm\", \"scala-native\""
)

private def split(input: String): (String, Option[String]) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import scala.build.preprocessing.ScopePath
case object UsingRepositoryDirectiveHandler extends UsingDirectiveHandler {
def name = "Repository"
def description = "Add a repository for dependency resolution"
def usage = "// using repository _repository_"
override def usageMd = "`// using repository `_repository_"
def usage = "//> using repository _repository_"
override def usageMd = "`//> using repository `_repository_"
override def examples = Seq(
"// using repository \"jitpack\"",
"// using repository \"sonatype:snapshots\"",
"// using repository \"https://maven-central.storage-download.googleapis.com/maven2\""
"//> using repository \"jitpack\"",
"//> using repository \"sonatype:snapshots\"",
"//> using repository \"https://maven-central.storage-download.googleapis.com/maven2\""
)

override def keys = Seq("repository", "repositories")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import scala.build.preprocessing.ScopePath
case object UsingResourcesDirectiveHandler extends UsingDirectiveHandler {
def name = "Resource directories"
def description = "Manually add a resource directory to the class path"
def usage = """// using resource _path_
def usage = """//> using resource _path_
|
|// using resources _path1_, _path2_ …""".stripMargin
|//> using resources _path1_, _path2_ …""".stripMargin
override def usageMd =
"""`// using resourceDir `_path_
"""`//> using resourceDir `_path_
|
|`// using resourceDirs `_path1_, _path2_ …""".stripMargin
|`//> using resourceDirs `_path1_, _path2_ …""".stripMargin
override def examples = Seq(
"// using resourceDir \"./resources\""
"//> using resourceDir \"./resources\""
)

override def keys = Seq("resourceDir", "resourceDirs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ case object UsingScalaJsOptionsDirectiveHandler extends UsingDirectiveHandler {

def description: String = "Add Scala JS options"

def usage: String = s"// using ${keys.mkString("|")} _value_"
def usage: String = s"//> using ${keys.mkString("|")} _value_"

override def usageMd: String =
"""
|`// using jsVersion` _value_
|`//> using jsVersion` _value_
|
|`// using jsMode` _value_
|`//> using jsMode` _value_
|
|`// using jsModuleKind` _value_
|`//> using jsModuleKind` _value_
|
|`// using jsCheckIr` _true|false_
|`//> using jsCheckIr` _true|false_
|
|`// using jsEmitSourceMaps` _true|false_
|`//> using jsEmitSourceMaps` _true|false_
|
|`// using jsDom` _true|false_
|`//> using jsDom` _true|false_
|
|`// using jsHeader` _value_
|`//> using jsHeader` _value_
|
|`// using jsAllowBigIntsForLongs` _true|false_
|`//> using jsAllowBigIntsForLongs` _true|false_
|
|`// using jsAvoidClasses` _true|false_
|`//> using jsAvoidClasses` _true|false_
|
|`// using jsAvoidLetsAndConsts` _true|false_
|`//> using jsAvoidLetsAndConsts` _true|false_
|
|`// using jsModuleSplitStyleStr` _value_
|`//> using jsModuleSplitStyleStr` _value_
|
|`// using jsEsVersionStr` _value_
|`//> using jsEsVersionStr` _value_
|""".stripMargin

override def examples: Seq[String] = Seq(
"// using jsModuleKind \"common\""
"//> using jsModuleKind \"common\""
)

def getSingleString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ case object UsingScalaNativeOptionsDirectiveHandler extends UsingDirectiveHandle

def description: String = "Add Scala Native options"

def usage: String = "// using nativeGc _value_ | using native-version _value_"
def usage: String = "//> using nativeGc _value_ | using native-version _value_"

override def usageMd: String =
"""`// using nativeGc` _value_
"""`//> using nativeGc` _value_
|
|`// using nativeVersion` _value_
|`//> using nativeVersion` _value_
|
|`// using nativeCompile` _value1_, _value2_
|`//> using nativeCompile` _value1_, _value2_
|
|`// using nativeLinking` _value1_, _value2_""".stripMargin
|`//> using nativeLinking` _value1_, _value2_""".stripMargin

override def examples: Seq[String] = Seq(
"// using nativeVersion \"0.4.0\""
"//> using nativeVersion \"0.4.0\""
)

override def keys: Seq[String] =
Expand Down
Loading

0 comments on commit 202f37a

Please sign in to comment.