Skip to content

Commit 6efe335

Browse files
adpi2sjrdjulienrfbishaboshaszymon-rd
authored
Add the Toolkit tutorials: MUnit, OS-Lib, UPickle and sttp (#2795)
* Init tutorials about MUnit in the Scala Toolkit * Tutorial for MUnit async tests. * Small imprvements - Use you instead of we - Remove Scala-CLI tab on Scala code - Add info about InvalidTestClassError * Add tutorial on writing assertions * +you -we * complete tutorial for running individual tests * Improve intro and “next steps” * Make munit-test-suite tutorial more concise * Adding small tutorial about testing exceptions * Remove explanations * Init tutorials about sttp * Fix munit -> sttp * Navigate from munit * Fix next page on sttp-request-body * Tutorial on uploading files * Fixing some typos * Apply suggestions from code review Co-authored-by: Adrien Piquerez <adrien.piquerez@gmail.com> * Rename dynamic urls tutorialg * Fix address & change the link * Split into lines * Fix some URLs * Add tutorial about flaky tests * Add tutorial about resource management in MUnit * Review & structure fixes to sttp tutorials * Missing .html * Fix links * Shorter sentences and other changes * Apply suggestions from code review Co-authored-by: Simon R <dev.jaca@gmail.com> * WIP: os-lib tutorial * wip * wip * wip * wip * wip * wip * wip * apply review feedback from Szymon * Reworking tutorials to have two tabs * Add scala versions to snippets * Fix Scala-cli installation * Explain testOnly * Init upicle tutorials * Reading jsons lesson * Fixes to the tutorial * More work on reading JSONs tutorial * 3 tutorials in total for upickle * More tutorials on upickle * Update links to prev/next * Fixes in the upickle tutorials * Fix links * Review JSON tutorials * Add scala versions to snippets * Tutorials on STTP x UPickle * Use real examples from the Github REST API * Add snippets for different versions of Scala * Fix pages of toolkit tutorials * Restructuring the Toolkit tutorials * Fix title of upickle-parse-json * Fix titles of upickle-parse-json and sttp-query-parameters * OS-Lib adjustments * what else can OS-Lib do * oslib: take Julien's suggestion * revise OS-Lib examples to not be REPL based * Add short introduction * Add MUnit intro * Add uPickle intro * Add uPickle what else * Add a word about why testing is useful * expand overall intro * expand introduction * Add sttp intro * Link build tool tab together * Add checks for class=tabs-build-tool * Fix function.js * fix default build tool tab * Rework introduction * Review MUnit * Review install boxes in intros * Review OS-Lib * Review upickle * Review sttp * Update nums and pages * Finishing touches * update Gemfile.lock for use on MacOS * make overall intro a bit more concise * proofread MUnit sections * proofread uPickle sections * rewrite the sttp intro pretty heavily * proofread entire sttp tutorial * avoid talk of 'install'ing libraries * fix broken link * Update versions * small fixes in munit * small fixes in uPickle * Rename files * Run mdoc in http-client tutos * Run mdoc on JSON tutorials * Run mdoc in OS tutorials * run mdoc in testing tutorials * fix mdoc * using dep, not using lib * Add toolkit in the index page and nav bar * Use toolkit lib in all build tools * Add index in intro * Use dep toolkit-test * Fix install munit --------- Co-authored-by: Sébastien Doeraene <sjrdoeraene@gmail.com> Co-authored-by: Julien Richard-Foy <julien@richard-foy.fr> Co-authored-by: Jamie Thompson <bishbashboshjt@gmail.com> Co-authored-by: Szymon Rodziewicz <szymonrodant@gmail.com> Co-authored-by: Szymon R <dev.jaca@gmail.com> Co-authored-by: Seth Tisue <seth@tisue.net>
1 parent 8d227be commit 6efe335

Some content is hidden

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

42 files changed

+2505
-54
lines changed

_config.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ defaults:
192192
overview-name: "Scaladoc"
193193
layout: multipage-overview
194194
permalink: "/scala3/guides/scaladoc/:title.html"
195+
-
196+
scope:
197+
path: "_overviews/toolkit"
198+
values:
199+
partof: toolkit
200+
overview-name: "The Scala Toolkit"
201+
layout: multipage-overview
202+
permalink: "/toolkit/:title.html"
195203
-
196204
scope:
197205
path: "scala3"
@@ -203,6 +211,6 @@ highlighter: rouge
203211
permalink: /:categories/:title.html:output_ext
204212
baseurl:
205213
scala3ref: "https://docs.scala-lang.org/scala3/reference"
206-
exclude: ["vendor"]
214+
exclude: ["vendor", ".metals"]
207215
plugins:
208216
- jekyll-redirect-from

_data/doc-nav-header.yml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
url: "/tutorials/scala-on-android.html"
3838
- title: Scala with Maven
3939
url: "/tutorials/scala-with-maven.html"
40+
- title: Using the Scala Toolkit
41+
url: "/toolkit/introduction.html"
4042
- title: Reference
4143
url: "#"
4244
submenu:

_includes/_markdown/install-munit.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{% altDetails install-info-box 'Getting MUnit' %}
2+
3+
{% tabs munit-unit-test-1 class=tabs-build-tool %}
4+
{% tab 'Scala CLI' %}
5+
You can require the entire toolkit in a single line:
6+
```scala
7+
//>usingdep"org.scala-lang::toolkit-test:0.1.7"
8+
```
9+
10+
Alternatively, you can require just a specific version of MUnit:
11+
```scala
12+
//>usingdep"org.scalameta::munit:1.0.0-M7"
13+
```
14+
{% endtab %}
15+
{% tab 'sbt' %}
16+
In your build.sbt file, you can add the dependency on toolkit-test:
17+
```scala
18+
lazyvalexample= project.in(file("example"))
19+
.settings(
20+
scalaVersion :="3.2.2",
21+
libraryDependencies +="org.scala-lang"%%"toolkit-test"%"0.1.7"%Test
22+
)
23+
```
24+
Here the `Test` configuration means that the dependency is only used by the source files in `example/src/test`.
25+
26+
Alternatively, you can require just a specific version of MUnit:
27+
```scala
28+
libraryDependencies +="org.scalameta"%%"munit"%"1.0.0-M7"%Test
29+
```
30+
{% endtab %}
31+
{% tab 'Mill' %}
32+
In your build.sc file, you can add a `test` object extending `Tests` and `TestModule.Munit`:
33+
```scala
34+
objectexampleextendsScalaModule {
35+
defscalaVersion="3.2.2"
36+
objecttestextendsTestswithTestModule.Munit {
37+
defivyDeps=
38+
Agg(
39+
ivy"org.scala-lang::toolkit-test:0.1.7"
40+
)
41+
}
42+
}
43+
```
44+
45+
Alternatively, you can require just a specific version of MUnit:
46+
```scala
47+
ivy"org.scalameta::munit:1.0.0-M7"
48+
```
49+
{% endtab %}
50+
{% endtabs %}
51+
{% endaltDetails %}

_includes/_markdown/install-os-lib.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{% altDetails require-info-box 'Getting OS-Lib' %}
2+
3+
{% tabs oslib-install class=tabs-build-tool %}
4+
{% tab 'Scala CLI' %}
5+
You can require the entire toolkit in a single line:
6+
```scala
7+
//>usingtoolkit"latest"
8+
```
9+
10+
Alternatively, you can require just a specific version of OS-Lib:
11+
```scala
12+
//>usingdep"com.lihaoyi::os-lib:0.9.1"
13+
```
14+
{% endtab %}
15+
{% tab 'sbt' %}
16+
In your `build.sbt`, you can add a dependency on the toolkit:
17+
```scala
18+
lazyvalexample= project.in(file("example"))
19+
.settings(
20+
scalaVersion :="3.2.2",
21+
libraryDependencies +="org.scala-lang"%%"toolkit"%"0.1.7"
22+
)
23+
```
24+
Alternatively, you can require just a specific version of OS-Lib:
25+
```scala
26+
libraryDependencies +="com.lihaoyi"%%"os-lib"%"0.9.1"
27+
```
28+
{% endtab %}
29+
{% tab 'Mill' %}
30+
In your `build.sc` file, you can add a dependency on the Toolkit:
31+
```scala
32+
objectexampleextendsScalaModule {
33+
defscalaVersion="3.2.2"
34+
defivyDeps=
35+
Agg(
36+
ivy"org.scala-lang::toolkit:0.1.7"
37+
)
38+
}
39+
```
40+
Alternatively, you can require just a specific version of OS-Lib:
41+
```scala
42+
ivy"com.lihaoyi::os-lib:0.9.1"
43+
```
44+
{% endtab %}
45+
{% endtabs %}
46+
{% endaltDetails %}

_includes/_markdown/install-sttp.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{% altDetails install-info-box 'Getting sttp' %}
2+
3+
{% tabs sttp-install-methods class=tabs-build-tool%}
4+
{% tab 'Scala CLI' %}
5+
You can require the entire toolkit in a single line:
6+
```scala
7+
//>usingtoolkit"latest"
8+
```
9+
10+
Alternatively, you can require just a specific version of sttp:
11+
```scala
12+
//>usingdep"com.softwaremill.sttp.client4::core:4.0.0-M1"
13+
```
14+
{% endtab %}
15+
{% tab 'sbt' %}
16+
In your build.sbt file, you can add a dependency on the Toolkit:
17+
```scala
18+
lazyvalexample= project.in(file("example"))
19+
.settings(
20+
scalaVersion :="3.2.2",
21+
libraryDependencies +="org.scala-lang"%%"toolkit"%"0.1.7"
22+
)
23+
```
24+
25+
Alternatively, you can require just a specific version of sttp:
26+
```scala
27+
libraryDependencies +="com.softwaremill.sttp.client4"%%"core"%"4.0.0-M1"
28+
```
29+
{% endtab %}
30+
{% tab 'Mill' %}
31+
In your build.sc file, you can add a dependency on the Toolkit:
32+
```scala
33+
objectexampleextendsScalaModule {
34+
defscalaVersion="3.2.2"
35+
defivyDeps=
36+
Agg(
37+
ivy"org.scala-lang::toolkit:0.1.7"
38+
)
39+
}
40+
```
41+
Alternatively, you can require just a specific version of sttp:
42+
```scala
43+
ivy"com.softwaremill.sttp.client4::core:4.0.0-M1"
44+
```
45+
{% endtab %}
46+
{% endtabs %}
47+
{% endaltDetails %}
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{% altDetails install-info-box 'Getting upickle' %}
2+
3+
{% tabs upickle-install-methods class=tabs-build-tool %}
4+
{% tab 'Scala CLI' %}
5+
Using Scala CLI, you can require the entire toolkit in a single line:
6+
```scala
7+
//>usingtoolkit"latest"
8+
```
9+
10+
Alternatively, you can require just a specific version of UPickle:
11+
```scala
12+
//>usingdep"com.lihaoyi::upickle:3.1.0
13+
```
14+
{% endtab %}
15+
{% tab 'sbt' %}
16+
In your build.sbt file, you can add the dependency on the Toolkit:
17+
```scala
18+
lazy val example = project.in(file("example"))
19+
.settings(
20+
scalaVersion := "3.2.2",
21+
libraryDependencies += "org.scala-lang"%%"toolkit"%"0.1.7"
22+
)
23+
```
24+
Alternatively, you can require just a specific version of UPickle:
25+
```scala
26+
libraryDependencies +="com.lihaoyi"%%"upickle"%"3.1.0"
27+
```
28+
{% endtab %}
29+
{% tab 'Mill' %}
30+
In your build.sc file, you can add the dependency to the upickle library:
31+
```scala
32+
objectexampleextendsScalaModule {
33+
defscalaVersion="3.2.2"
34+
defivyDeps=
35+
Agg(
36+
ivy"org.scala-lang::toolkit:0.1.7"
37+
)
38+
}
39+
```
40+
Alternatively, you can require just a specific version of UPickle:
41+
```scala
42+
ivy"com.lihaoyi::upickle:3.1.0"
43+
```
44+
{% endtab %}
45+
{% endtabs %}
46+
{% endaltDetails %}

_includes/markdown.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%if include.selector%}<{{include.selector}} {%if include.classes%}class="{{include.classes}}"{%endif%} {%if include.id%}id="{{include.id}}{%endif%}">{%endif%}
2+
{% capture markdown %}{% include {{include.path}} %}{% endcapture %}{{ markdown | markdownify }}
3+
{%if include.selector%}</{{include.selector}}>{%endif%}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
introduction.md
2+
testing-intro.md
3+
testing-suite.md
4+
testing-run.md
5+
testing-run-only.md
6+
testing-exceptions.md
7+
testing-asynchronous.md
8+
testing-resources.md
9+
testing-what-else.md
10+
os-intro.md
11+
os-read-directory.md
12+
os-read-file.md
13+
os-write-file.md
14+
os-run-process.md
15+
os-what-else.md
16+
json-intro.md
17+
json-parse.md
18+
json-modify.md
19+
json-deserialize.md
20+
json-serialize.md
21+
json-files.md
22+
json-what-else.md
23+
http-client-intro.md
24+
http-client-request.md
25+
http-client-uris.md
26+
http-client-request-body.md
27+
http-client-json.md
28+
http-client-upload-file.md
29+
http-client-what-else.md
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Sending HTTP requests with sttp
3+
type: chapter
4+
description: The introduction of the sttp library
5+
num: 23
6+
previous-page: json-what-else
7+
next-page: http-client-request
8+
---
9+
10+
sttp is a popular and feature-rich library for making HTTP requests to web servers.
11+
12+
It provides both a synchronous API and an asynchronous `Future`-based API. It also supports WebSockets.
13+
14+
Extensions are available that add capabilities such as streaming, logging, telemetry, and serialization.
15+
16+
sttp offers the same APIs on all platforms (JVM, Scala.js, and Scala Native).
17+
18+
sttp is a good choice for small synchronous scripts as well as large-scale, highly concurrent, asynchronous applications.
19+
20+
{% include markdown.html path="_markdown/install-sttp.md" %}

0 commit comments

Comments
 (0)
close