Skip to content

Commit c8fc935

Browse files
authored
Merge pull request #1297 from romanowski/sip-docs
Add mechanism to restrict options based on description and generate reference docs for SIP
2 parents 932c942 + 52aca4d commit c8fc935

File tree

71 files changed

+2724
-1786
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2724
-1786
lines changed

modules/build/src/main/scala/scala/build/CrossSources.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ object CrossSources {
137137
elem,
138138
logger,
139139
maybeRecoverOnError,
140-
inputs.withRestrictedFeatures
140+
inputs.allowRestrictedFeatures
141141
).iterator
142142
)
143143
.take(1)

modules/build/src/main/scala/scala/build/Inputs.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final case class Inputs(
2424
mayAppendHash: Boolean,
2525
workspaceOrigin: Option[WorkspaceOrigin],
2626
enableMarkdown: Boolean,
27-
withRestrictedFeatures: Boolean
27+
allowRestrictedFeatures: Boolean
2828
) {
2929

3030
def isEmpty: Boolean =
@@ -303,7 +303,7 @@ object Inputs {
303303
directories: Directories,
304304
forcedWorkspace: Option[os.Path],
305305
enableMarkdown: Boolean,
306-
withRestrictedFeatures: Boolean
306+
allowRestrictedFeatures: Boolean
307307
): Inputs = {
308308

309309
assert(validElems.nonEmpty)
@@ -364,7 +364,7 @@ object Inputs {
364364
mayAppendHash = needsHash,
365365
workspaceOrigin = Some(workspaceOrigin0),
366366
enableMarkdown = enableMarkdown,
367-
withRestrictedFeatures = withRestrictedFeatures
367+
allowRestrictedFeatures = allowRestrictedFeatures
368368
)
369369
}
370370

@@ -491,7 +491,7 @@ object Inputs {
491491
acceptFds: Boolean,
492492
forcedWorkspace: Option[os.Path],
493493
enableMarkdown: Boolean,
494-
withRestrictedFeatures: Boolean
494+
allowRestrictedFeatures: Boolean
495495
): Either[BuildException, Inputs] = {
496496
val validatedArgs: Seq[Either[String, Seq[Element]]] =
497497
validateArgs(args, cwd, download, stdinOpt, acceptFds)
@@ -513,7 +513,7 @@ object Inputs {
513513
directories,
514514
forcedWorkspace,
515515
enableMarkdown,
516-
withRestrictedFeatures
516+
allowRestrictedFeatures
517517
))
518518
}
519519
else
@@ -534,7 +534,7 @@ object Inputs {
534534
acceptFds: Boolean = false,
535535
forcedWorkspace: Option[os.Path] = None,
536536
enableMarkdown: Boolean = false,
537-
withRestrictedFeatures: Boolean
537+
allowRestrictedFeatures: Boolean
538538
): Either[BuildException, Inputs] =
539539
if (
540540
args.isEmpty && scriptSnippetList.isEmpty && scalaSnippetList.isEmpty && javaSnippetList.isEmpty
@@ -556,7 +556,7 @@ object Inputs {
556556
acceptFds,
557557
forcedWorkspace,
558558
enableMarkdown,
559-
withRestrictedFeatures
559+
allowRestrictedFeatures
560560
)
561561

562562
def default(): Option[Inputs] =
@@ -571,7 +571,7 @@ object Inputs {
571571
mayAppendHash = true,
572572
workspaceOrigin = None,
573573
enableMarkdown = enableMarkdown,
574-
withRestrictedFeatures = false
574+
allowRestrictedFeatures = false
575575
)
576576

577577
def empty(projectName: String): Inputs =

modules/build/src/main/scala/scala/build/preprocessing/DataPreprocessor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ case object DataPreprocessor extends Preprocessor {
1010
input: Inputs.SingleElement,
1111
logger: Logger,
1212
maybeRecoverOnError: BuildException => Option[BuildException] = e => Some(e),
13-
withRestrictedFeatures: Boolean
13+
allowRestrictedFeatures: Boolean
1414
): Option[Either[BuildException, Seq[PreprocessedSource]]] =
1515
input match {
1616
case file: Inputs.VirtualData =>

modules/build/src/main/scala/scala/build/preprocessing/DirectivesProcessor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ object DirectivesProcessor {
2626
path: Either[String, os.Path],
2727
cwd: ScopePath,
2828
logger: Logger,
29-
withRestrictedFeatures: Boolean
29+
allowRestrictedFeatures: Boolean
3030
): Either[BuildException, DirectivesProcessorOutput[T]] = {
3131
val configMonoidInstance = implicitly[ConfigMonoid[T]]
3232

3333
def handleValues(handler: DirectiveHandler[T])(
3434
scopedDirective: ScopedDirective,
3535
logger: Logger
3636
) =
37-
if (withRestrictedFeatures && handler.isRestricted)
37+
if (!allowRestrictedFeatures && handler.isRestricted)
3838
val msg =
3939
"This directive is not supported with 'scala' command. Please run it with `scala-cli` command or with `--power` flag."
4040
Left(DirectiveErrors(

modules/build/src/main/scala/scala/build/preprocessing/JavaPreprocessor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final case class JavaPreprocessor(
3535
input: Inputs.SingleElement,
3636
logger: Logger,
3737
maybeRecoverOnError: BuildException => Option[BuildException] = e => Some(e),
38-
withRestrictedFeatures: Boolean
38+
allowRestrictedFeatures: Boolean
3939
): Option[Either[BuildException, Seq[PreprocessedSource]]] =
4040
input match {
4141
case j: Inputs.JavaFile => Some(either {
@@ -56,7 +56,7 @@ final case class JavaPreprocessor(
5656
Right(j.path),
5757
scopePath,
5858
logger,
59-
withRestrictedFeatures
59+
allowRestrictedFeatures
6060
))
6161
Seq(PreprocessedSource.OnDisk(
6262
j.path,

modules/build/src/main/scala/scala/build/preprocessing/MarkdownPreprocessor.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ case object MarkdownPreprocessor extends Preprocessor {
1414
input: Inputs.SingleElement,
1515
logger: Logger,
1616
maybeRecoverOnError: BuildException => Option[BuildException],
17-
withRestrictedFeatures: Boolean
17+
allowRestrictedFeatures: Boolean
1818
): Option[Either[BuildException, Seq[PreprocessedSource]]] =
1919
input match {
2020
case markdown: Inputs.MarkdownFile =>
@@ -28,7 +28,7 @@ case object MarkdownPreprocessor extends Preprocessor {
2828
ScopePath.fromPath(markdown.path),
2929
logger,
3030
maybeRecoverOnError,
31-
withRestrictedFeatures
31+
allowRestrictedFeatures
3232
)
3333
}
3434
preprocessed
@@ -46,7 +46,7 @@ case object MarkdownPreprocessor extends Preprocessor {
4646
scopePath: ScopePath,
4747
logger: Logger,
4848
maybeRecoverOnError: BuildException => Option[BuildException],
49-
withRestrictedFeatures: Boolean
49+
allowRestrictedFeatures: Boolean
5050
): Either[BuildException, List[PreprocessedSource.InMemory]] = either {
5151
def preprocessSnippets(
5252
maybeCode: Option[String],
@@ -63,7 +63,7 @@ case object MarkdownPreprocessor extends Preprocessor {
6363
scopeRoot = scopePath / os.up,
6464
logger = logger,
6565
maybeRecoverOnError = maybeRecoverOnError,
66-
withRestrictedFeatures = withRestrictedFeatures
66+
allowRestrictedFeatures = allowRestrictedFeatures
6767
)
6868
}.getOrElse(ProcessingOutput(BuildRequirements(), Nil, BuildOptions(), None))
6969
val processedCode = processingOutput.updatedContent.getOrElse(code)

modules/build/src/main/scala/scala/build/preprocessing/Preprocessor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ trait Preprocessor {
88
input: Inputs.SingleElement,
99
logger: Logger,
1010
maybeRecoverOnError: BuildException => Option[BuildException] = e => Some(e),
11-
withRestrictedFeatures: Boolean
11+
allowRestrictedFeatures: Boolean
1212
): Option[Either[BuildException, Seq[PreprocessedSource]]]
1313
}

modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ case object ScalaPreprocessor extends Preprocessor {
7272
input: Inputs.SingleElement,
7373
logger: Logger,
7474
maybeRecoverOnError: BuildException => Option[BuildException] = e => Some(e),
75-
withRestrictedFeatures: Boolean
75+
allowRestrictedFeatures: Boolean
7676
): Option[Either[BuildException, Seq[PreprocessedSource]]] =
7777
input match {
7878
case f: Inputs.ScalaFile =>
@@ -87,7 +87,7 @@ case object ScalaPreprocessor extends Preprocessor {
8787
scopePath / os.up,
8888
logger,
8989
maybeRecoverOnError,
90-
withRestrictedFeatures
90+
allowRestrictedFeatures
9191
)
9292
) match {
9393
case None =>
@@ -137,7 +137,7 @@ case object ScalaPreprocessor extends Preprocessor {
137137
v.scopePath / os.up,
138138
logger,
139139
maybeRecoverOnError,
140-
withRestrictedFeatures
140+
allowRestrictedFeatures
141141
)
142142
).map {
143143
case ProcessingOutput(reqs, scopedReqs, opts, updatedContent) =>
@@ -168,7 +168,7 @@ case object ScalaPreprocessor extends Preprocessor {
168168
scopeRoot: ScopePath,
169169
logger: Logger,
170170
maybeRecoverOnError: BuildException => Option[BuildException],
171-
withRestrictedFeatures: Boolean
171+
allowRestrictedFeatures: Boolean
172172
): Either[BuildException, Option[ProcessingOutput]] = either {
173173
val (content0, isSheBang) = SheBang.ignoreSheBangLines(content)
174174
val afterStrictUsing: StrictDirectivesProcessingOutput =
@@ -178,7 +178,7 @@ case object ScalaPreprocessor extends Preprocessor {
178178
scopeRoot,
179179
logger,
180180
maybeRecoverOnError,
181-
withRestrictedFeatures
181+
allowRestrictedFeatures
182182
))
183183

184184
val afterProcessImports: Option[SpecialImportsProcessingOutput] = value {
@@ -297,7 +297,7 @@ case object ScalaPreprocessor extends Preprocessor {
297297
cwd: ScopePath,
298298
logger: Logger,
299299
maybeRecoverOnError: BuildException => Option[BuildException] = e => Some(e),
300-
withRestrictedFeatures: Boolean
300+
allowRestrictedFeatures: Boolean
301301
): Either[BuildException, StrictDirectivesProcessingOutput] = either {
302302
val contentChars = content.toCharArray
303303
val ExtractedDirectives(codeOffset, directives0) =
@@ -317,7 +317,7 @@ case object ScalaPreprocessor extends Preprocessor {
317317
path,
318318
cwd,
319319
logger,
320-
withRestrictedFeatures
320+
allowRestrictedFeatures
321321
)
322322
}
323323

@@ -330,7 +330,7 @@ case object ScalaPreprocessor extends Preprocessor {
330330
path,
331331
cwd,
332332
logger,
333-
withRestrictedFeatures
333+
allowRestrictedFeatures
334334
)
335335
}
336336

modules/build/src/main/scala/scala/build/preprocessing/ScriptPreprocessor.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final case class ScriptPreprocessor(codeWrapper: CodeWrapper) extends Preprocess
1414
input: Inputs.SingleElement,
1515
logger: Logger,
1616
maybeRecoverOnError: BuildException => Option[BuildException] = e => Some(e),
17-
withRestrictedFeatures: Boolean
17+
allowRestrictedFeatures: Boolean
1818
): Option[Either[BuildException, Seq[PreprocessedSource]]] =
1919
input match {
2020
case script: Inputs.Script =>
@@ -29,7 +29,7 @@ final case class ScriptPreprocessor(codeWrapper: CodeWrapper) extends Preprocess
2929
ScopePath.fromPath(script.path),
3030
logger,
3131
maybeRecoverOnError,
32-
withRestrictedFeatures
32+
allowRestrictedFeatures
3333
)
3434
}
3535
preprocessed
@@ -49,7 +49,7 @@ final case class ScriptPreprocessor(codeWrapper: CodeWrapper) extends Preprocess
4949
script.scopePath,
5050
logger,
5151
maybeRecoverOnError,
52-
withRestrictedFeatures
52+
allowRestrictedFeatures
5353
)
5454
}
5555
preprocessed
@@ -71,7 +71,7 @@ object ScriptPreprocessor {
7171
scopePath: ScopePath,
7272
logger: Logger,
7373
maybeRecoverOnError: BuildException => Option[BuildException],
74-
withRestrictedFeatures: Boolean
74+
allowRestrictedFeatures: Boolean
7575
): Either[BuildException, List[PreprocessedSource.InMemory]] = either {
7676

7777
val (contentIgnoredSheBangLines, _) = SheBang.ignoreSheBangLines(content)
@@ -85,7 +85,7 @@ object ScriptPreprocessor {
8585
scopePath / os.up,
8686
logger,
8787
maybeRecoverOnError,
88-
withRestrictedFeatures
88+
allowRestrictedFeatures
8989
))
9090
.getOrElse(ProcessingOutput(BuildRequirements(), Nil, BuildOptions(), None))
9191

modules/build/src/test/scala/scala/build/tests/PreprocessingTests.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PreprocessingTests extends munit.FunSuite {
1212
val logger = TestLogger()
1313
val scalaFile = Inputs.SourceScalaFile(os.temp.dir(), os.SubPath("NotExists.scala"))
1414

15-
val res = ScalaPreprocessor.preprocess(scalaFile, logger, withRestrictedFeatures = false)
15+
val res = ScalaPreprocessor.preprocess(scalaFile, logger, allowRestrictedFeatures = false)
1616
val expectedMessage = s"File not found: ${scalaFile.path}"
1717

1818
assert(res.nonEmpty)
@@ -27,7 +27,7 @@ class PreprocessingTests extends munit.FunSuite {
2727
val res = ScriptPreprocessor(CustomCodeWrapper).preprocess(
2828
scalaScript,
2929
logger,
30-
withRestrictedFeatures = false
30+
allowRestrictedFeatures = false
3131
)
3232
val expectedMessage = s"File not found: ${scalaScript.path}"
3333

@@ -40,7 +40,7 @@ class PreprocessingTests extends munit.FunSuite {
4040
val logger = TestLogger()
4141
val markdownFile = Inputs.MarkdownFile(os.temp.dir(), os.SubPath("NotExists.md"))
4242

43-
val res = MarkdownPreprocessor.preprocess(markdownFile, logger, withRestrictedFeatures = false)
43+
val res = MarkdownPreprocessor.preprocess(markdownFile, logger, allowRestrictedFeatures = false)
4444
val expectedMessage = s"File not found: ${markdownFile.path}"
4545

4646
assert(res.nonEmpty)

0 commit comments

Comments
 (0)