Skip to content

Commit 79672e7

Browse files
committed
Include environment variables in the automatically generated reference docs
1 parent c6550c2 commit 79672e7

File tree

3 files changed

+130
-1
lines changed

3 files changed

+130
-1
lines changed

modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import java.util
1313

1414
import scala.build.info.{ArtifactId, BuildInfo, ExportDependencyFormat, ScopedBuildInfo}
1515
import scala.build.internal.Constants
16+
import scala.build.internals.EnvVar
1617
import scala.build.options.{BuildOptions, BuildRequirements, WithBuildRequirements}
1718
import scala.build.preprocessing.directives.DirectiveHandler
1819
import scala.build.preprocessing.directives.DirectivesPreprocessingUtils.*
@@ -606,6 +607,34 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] {
606607
b.mkString
607608
}
608609

610+
private def envVarContent(groups: Seq[EnvVar.EnvVarGroup], onlyRestricted: Boolean): String = {
611+
val b = new StringBuilder
612+
b.section(
613+
"""---
614+
|title: Environment variables
615+
|sidebar_position: 7
616+
|---""".stripMargin
617+
)
618+
b.section(
619+
"""Scala CLI uses environment variables to configure its behavior.
620+
|Below you can find a list of environment variables used and recognized by Scala CLI.
621+
|
622+
|However, it should by no means be treated as an exhaustive list.
623+
|Some tools and libraries Scala CLI integrates with may have their own, which may or may not be listed here.
624+
|""".stripMargin
625+
)
626+
groups.foreach { group =>
627+
b.section(
628+
s"## ${group.groupName}",
629+
group.all
630+
.filter(ev => !ev.requiresPower || !onlyRestricted)
631+
.map(ev => s" - `${ev.name}`: ${if ev.requiresPower then "" else ""}${ev.description}")
632+
.mkString("\n")
633+
)
634+
}
635+
b.mkString
636+
}
637+
609638
def run(options: InternalDocOptions, args: RemainingArgs): Unit = {
610639

611640
val scalaCli = new ScalaCliCommands(
@@ -644,16 +673,21 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] {
644673
)
645674
val restrictedDocsDir = os.rel / "scala-command"
646675

676+
val allEnvVarsContent = envVarContent(EnvVar.allGroups, onlyRestricted = false)
677+
val restrictedEnvVarsContent = envVarContent(Seq(EnvVar.ScalaCli), onlyRestricted = true)
678+
647679
if (options.check) {
648680
val content = Seq(
649681
(os.rel / "cli-options.md") -> allCliOptionsContent,
650682
(os.rel / "commands.md") -> allCommandsContent,
651683
(os.rel / "directives.md") -> allDirectivesContent,
652684
(os.rel / "build-info.md") -> buildInfoContent,
685+
(os.rel / "env-vars.md") -> allEnvVarsContent,
653686
(os.rel / restrictedDocsDir / "cli-options.md") -> restrictedCliOptionsContent,
654687
(os.rel / restrictedDocsDir / "commands.md") -> restrictedCommandsContent,
655688
(os.rel / restrictedDocsDir / "directives.md") -> restrictedDirectivesContent,
656-
(os.rel / restrictedDocsDir / "runner-specification") -> scalaOptionsReference
689+
(os.rel / restrictedDocsDir / "runner-specification") -> scalaOptionsReference,
690+
(os.rel / restrictedDocsDir / "env-vars.md") -> restrictedEnvVarsContent
657691
)
658692
var anyDiff = false
659693
for ((dest, content0) <- content) {
@@ -678,6 +712,7 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] {
678712
maybeWrite(options.outputPath / "commands.md", allCommandsContent)
679713
maybeWrite(options.outputPath / "directives.md", allDirectivesContent)
680714
maybeWrite(options.outputPath / "build-info.md", buildInfoContent)
715+
maybeWrite(options.outputPath / "env-vars.md", allEnvVarsContent)
681716

682717
maybeWrite(
683718
options.outputPath / restrictedDocsDir / "cli-options.md",
@@ -692,6 +727,10 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] {
692727
options.outputPath / restrictedDocsDir / "runner-specification.md",
693728
scalaOptionsReference
694729
)
730+
maybeWrite(
731+
options.outputPath / restrictedDocsDir / "env-vars.md",
732+
restrictedEnvVarsContent
733+
)
695734
}
696735
}
697736
}

website/docs/reference/env-vars.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Environment variables
3+
sidebar_position: 7
4+
---
5+
6+
Scala CLI uses environment variables to configure its behavior.
7+
Below you can find a list of environment variables used and recognized by Scala CLI.
8+
9+
However, it should by no means be treated as an exhaustive list.
10+
Some tools and libraries Scala CLI integrates with may have their own, which may or may not be listed here.
11+
12+
13+
## Scala CLI
14+
- `SCALA_CLI_CONFIG`: Scala CLI configuration file path
15+
- `SCALA_CLI_HOME`: Scala CLI home directory
16+
- `SCALA_CLI_INTERACTIVE`: Interactive mode toggle
17+
- `SCALA_CLI_INTERACTIVE_INPUTS`: Interactive mode inputs
18+
- `SCALA_CLI_POWER`: Power mode toggle
19+
- `SCALA_CLI_PRINT_STACK_TRACES`: Print stack traces toggle
20+
- `SCALA_CLI_SODIUM_JNI_ALLOW`: Allow to load libsodiumjni
21+
- `SCALA_CLI_VENDORED_ZIS`: Toggle io.github.scala_cli.zip.ZipInputStream
22+
23+
## Java
24+
- `JAVA_HOME`: Java installation directory
25+
- `JAVA_OPTS`: Java options
26+
- `JDK_JAVA_OPTIONS`: JDK Java options
27+
28+
## Bloop
29+
- `BLOOP_COMPUTATION_CORES`: ⚡ Number of computation cores to be used
30+
- `BLOOP_DAEMON_DIR`: ⚡ Bloop daemon directory
31+
- `BLOOP_JAVA_OPTS`: ⚡ Bloop Java options
32+
- `BLOOP_MODULE`: ⚡ Bloop default module
33+
- `BLOOP_PORT`: ⚡ Bloop default port
34+
- `BLOOP_SCALA_VERSION`: ⚡ Bloop default Scala version
35+
- `BLOOP_VERSION`: ⚡ Bloop default version
36+
- `BLOOP_SERVER`: ⚡ Bloop default host
37+
- `SCALA_CLI_EXTRA_TIMEOUT`: ⚡ Extra timeout
38+
39+
## Coursier
40+
- `COURSIER_BIN_DIR`: Coursier app binaries directory
41+
- `COURSIER_CACHE`: Coursier cache location
42+
- `COURSIER_CONFIG_DIR`: Coursier configuration directory
43+
- `COURSIER_CREDENTIALS`: Coursier credentials
44+
- `INSIDE_EMACS`: Emacs toggle
45+
- `COURSIER_EXPERIMENTAL`: Experimental mode toggle
46+
- `COURSIER_JNI`: Coursier JNI toggle
47+
- `COURSIER_MODE`: Coursier mode (can be set to 'offline')
48+
- `COURSIER_NO_TERM`: Terminal toggle
49+
- `COURSIER_PROGRESS`: Progress bar toggle
50+
- `COURSIER_REPOSITORIES`: Coursier repositories
51+
- `COURSIER_VENDORED_ZIS`: Toggle io.github.scala_cli.zip.ZipInputStream
52+
- `CS_MAVEN_HOME`: Coursier Maven home directory
53+
54+
## Spark
55+
- `SPARK_HOME`: ⚡ Spark installation directory
56+
57+
## Miscellaneous
58+
- `PATH`: The app path variable
59+
- `DYLD_LIBRARY_PATH`: Runtime library paths on Mac OS X
60+
- `LD_LIBRARY_PATH`: Runtime library paths on Linux
61+
- `PATHEXT`: Executable file extensions on Windows
62+
- `SHELL`: The currently used shell
63+
- `VCVARSALL`: Visual C++ Redistributable Runtimes
64+
- `ZDOTDIR`: Zsh configuration directory
65+
66+
## Internal
67+
- `CI`: ⚡ Marker for running on the CI
68+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Environment variables
3+
sidebar_position: 7
4+
---
5+
6+
Scala CLI uses environment variables to configure its behavior.
7+
Below you can find a list of environment variables used and recognized by Scala CLI.
8+
9+
However, it should by no means be treated as an exhaustive list.
10+
Some tools and libraries Scala CLI integrates with may have their own, which may or may not be listed here.
11+
12+
13+
## Scala CLI
14+
- `SCALA_CLI_CONFIG`: Scala CLI configuration file path
15+
- `SCALA_CLI_HOME`: Scala CLI home directory
16+
- `SCALA_CLI_INTERACTIVE`: Interactive mode toggle
17+
- `SCALA_CLI_INTERACTIVE_INPUTS`: Interactive mode inputs
18+
- `SCALA_CLI_POWER`: Power mode toggle
19+
- `SCALA_CLI_PRINT_STACK_TRACES`: Print stack traces toggle
20+
- `SCALA_CLI_SODIUM_JNI_ALLOW`: Allow to load libsodiumjni
21+
- `SCALA_CLI_VENDORED_ZIS`: Toggle io.github.scala_cli.zip.ZipInputStream
22+

0 commit comments

Comments
 (0)