Skip to content

Commit c2d6ae2

Browse files
dfa1claude
andcommitted
docs: extract tutorial into docs/tutorial.md
Move the getting-started walkthrough out of the README into its own Diátaxis tutorial file; README keeps a short pointer and the nav map links to it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7108536 commit c2d6ae2

2 files changed

Lines changed: 43 additions & 35 deletions

File tree

README.md

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ documentation, each serving a different need:
2222

2323
| | Purpose | Start here |
2424
|---|---|---|
25-
| **[Tutorial](#tutorial-getting-started)** | Learning by doing | [Getting started](#tutorial-getting-started) |
25+
| **[Tutorial](docs/tutorial.md)** | Learning by doing | [Getting started](docs/tutorial.md) |
2626
| **[How-to guides](#how-to-guides)** | Solving a specific task | [Hot paths](#compress-on-a-hot-path), [Dictionaries](#compress-many-small-payloads-with-a-dictionary), [Zero-copy](#avoid-heap-copies-with-memorysegment), [Self-built lib](#run-against-a-self-built-libzstd) |
2727
| **[Reference](#reference)** | Looking up facts | [Platforms](#supported-platforms), [API surface](#api-surface), [Symbol coverage](docs/supported.md), [Build](#build-from-source) |
2828
| **[Explanation](#explanation)** | Understanding the why | [Why FFM + Zig](#why-ffm-and-zig), [When zero-copy pays](docs/zero-copy.md), [Benchmarks](docs/benchmarks.md) |
@@ -31,40 +31,8 @@ documentation, each serving a different need:
3131

3232
## Tutorial: Getting started
3333

34-
This walks you from a clean checkout to your first compress/decompress round-trip.
35-
36-
**1. Clone with the zstd submodule and build.** You need JDK 25+, Maven, and
37-
[Zig](https://ziglang.org/) on `PATH` (Zig is the C compiler for the native lib).
38-
39-
```bash
40-
git clone --recurse-submodules https://github.com/dfa1/zstd-java.git
41-
cd zstd-java
42-
mvn install
43-
```
44-
45-
The build invokes `scripts/build-zstd.sh`, compiling `libzstd` from the vendored
46-
source — no autotools or CMake needed.
47-
48-
**2. Write your first round-trip.**
49-
50-
```java
51-
import io.github.dfa1.zstd.Zstd;
52-
53-
byte[] original = "hello world".getBytes();
54-
byte[] packed = Zstd.compress(original);
55-
byte[] restored = Zstd.decompress(packed); // size read from the frame header
56-
57-
assert java.util.Arrays.equals(original, restored);
58-
```
59-
60-
**3. Run it with native access enabled.** The FFM API requires an explicit flag:
61-
62-
```bash
63-
java --enable-native-access=ALL-UNNAMED Demo.java
64-
```
65-
66-
That's the whole loop. From here, pick a [how-to guide](#how-to-guides) for your
67-
actual task, or browse the [reference](#reference).
34+
New here? **[docs/tutorial.md](docs/tutorial.md)** takes you from a clean checkout
35+
to your first compress/decompress round-trip, step by step.
6836

6937
## How-to guides
7038

docs/tutorial.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Tutorial: Getting started
2+
3+
This walks you from a clean checkout to your first compress/decompress round-trip.
4+
5+
## 1. Clone and build
6+
7+
You need JDK 25+, Maven, and [Zig](https://ziglang.org/) on `PATH` (Zig is the C
8+
compiler for the native lib).
9+
10+
```bash
11+
git clone --recurse-submodules https://github.com/dfa1/zstd-java.git
12+
cd zstd-java
13+
mvn install
14+
```
15+
16+
The build invokes `scripts/build-zstd.sh`, compiling `libzstd` from the vendored
17+
source — no autotools or CMake needed.
18+
19+
## 2. Your first round-trip
20+
21+
```java
22+
import io.github.dfa1.zstd.Zstd;
23+
24+
byte[] original = "hello world".getBytes();
25+
byte[] packed = Zstd.compress(original);
26+
byte[] restored = Zstd.decompress(packed); // size read from the frame header
27+
28+
assert java.util.Arrays.equals(original, restored);
29+
```
30+
31+
## 3. Run with native access enabled
32+
33+
The FFM API requires an explicit flag:
34+
35+
```bash
36+
java --enable-native-access=ALL-UNNAMED Demo.java
37+
```
38+
39+
That's the whole loop. From here, pick a [how-to guide](../README.md#how-to-guides)
40+
for your actual task, or browse the [reference](../README.md#reference).

0 commit comments

Comments
 (0)