Skip to content

Commit f8dc3f3

Browse files
committed
Merge branch 'migration' (early part) into all
* 'migration' (early part): apply some manual fixes the migration script drop mention of transclusions fix: transclusions from FabricMC#415 feat: apply vuejs/vitepress#5014 chore: set minimumReleaseAge to 3 days chore: migrate to pnpm
2 parents 55b013a + 85bf21a commit f8dc3f3

26 files changed

+3156
-4342
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
crowdin.yaml @FabricMC/developers
66
netlify.toml @FabricMC/developers
77
package.json @FabricMC/developers
8-
package-lock.json @FabricMC/developers
8+
patches @FabricMC/developers
9+
pnpm-*.yaml @FabricMC/developers

.github/workflows/build.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ jobs:
2121
- uses: actions/setup-node@v4
2222
with:
2323
node-version-file: .nvmrc
24-
- run: npm ci
25-
- run: npm run build
24+
- uses: pnpm/action-setup@58e6119fe4f3092a76a7771efb55e04d25b6b26f
25+
with:
26+
run_install: true
27+
- run: pnpm build
2628
- if: github.event_name != 'pull_request'
2729
uses: actions/configure-pages@v4
2830
- if: github.event_name != 'pull_request'

.github/workflows/format.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
- uses: actions/setup-node@v4
2424
with:
2525
node-version-file: .nvmrc
26-
- run: npm ci
26+
- uses: pnpm/action-setup@58e6119fe4f3092a76a7771efb55e04d25b6b26f
27+
with:
28+
run_install: true
2729
- uses: FabricMCBot/markdownlint-cli2-action@b4c9feab76d8025d1e83c653fa3990936df0e6c8
2830
with:
2931
config: .markdownlint-cli2.yaml
@@ -42,7 +44,9 @@ jobs:
4244
- uses: actions/setup-node@v4
4345
with:
4446
node-version-file: .nvmrc
45-
- run: npm ci
47+
- uses: pnpm/action-setup@58e6119fe4f3092a76a7771efb55e04d25b6b26f
48+
with:
49+
run_install: true
4650
- run: npx prettier --write .
4751
- run: |
4852
readarray -d '' files < <(git ls-files --modified --others --exclude-standard -z)

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
.DS_Store
1111

1212
# Alternative Package Locks
13-
pnpm-lock.yaml
14-
pnpm-workspace.yaml
13+
package-lock.json
1514
yarn.lock
1615

1716
# LanguageTool Dictionaries and False Positives

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vitepress/sidebars/versioned
2+
pnpm-lock.yaml
23
reference/*.*
34
reference/latest/src/main/generated
45
translated

.vitepress/migrate.ts

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import * as fs from "node:fs";
2+
import * as process from "node:process";
3+
import * as tinyglobby from "tinyglobby";
4+
5+
const warn = (...args: [string, ...string[]]) =>
6+
console.warn(
7+
args
8+
.map((a) =>
9+
a.replace(/^reference[/]latest[/]src/, "@src").replace("/com/example/docs/", "/.../")
10+
)
11+
.join("\n ")
12+
);
13+
14+
const PRIORITY = [
15+
"index.md",
16+
"basics.md",
17+
"setup.md",
18+
"first-block.md",
19+
"first-entity.md",
20+
"first-item.md",
21+
].reverse();
22+
23+
const { compare } = Intl.Collator();
24+
25+
const sorter = (a: string, b: string) => {
26+
const as = a.split("/").map((f) => (f.endsWith(".md") ? f : f + "/"));
27+
const bs = b.split("/").map((f) => (f.endsWith(".md") ? f : f + "/"));
28+
29+
while (as.length * bs.length !== 0) {
30+
const aFragment = as.shift()!;
31+
const bFragment = bs.shift()!;
32+
33+
if ([...aFragment].reverse()[0] !== [...bFragment].reverse()[0]) {
34+
if (aFragment.endsWith(".md")) return -10.1;
35+
return +10.1;
36+
}
37+
38+
const comparison =
39+
PRIORITY.indexOf(bFragment) - PRIORITY.indexOf(aFragment) || compare(aFragment, bFragment);
40+
if (comparison !== 0) return comparison;
41+
}
42+
43+
return as.length - bs.length;
44+
};
45+
46+
const pathToContentMap = Object.fromEntries(
47+
tinyglobby
48+
.globSync(["contributing.md", "develop/**/*.md", "players/**/*.md"])
49+
.sort(sorter)
50+
.map((f) => [f, fs.readFileSync(f, "utf-8")] as const)
51+
.filter(([_, c]) => c.split("@[").length !== 1)
52+
);
53+
54+
const javaToNewMap: Record<string, string> = {};
55+
56+
for (const f of Object.keys(pathToContentMap)) {
57+
const newContent = pathToContentMap[f].replaceAll(
58+
/@\[code([^\]]*)\]\(([^\)]+)\)/g,
59+
(old, ...args) => {
60+
const config: Record<"highlight" | "transcludeWith", string> = Object.fromEntries(
61+
(args[0]! as string)
62+
.split(" ")
63+
.filter(Boolean)
64+
.filter((x) => !["java", "lang=java", "transclude"].includes(x))
65+
.map((kv) => kv.split("=", 2))
66+
);
67+
68+
const includedPath = (args[1] as string).replace(/^@\//, "");
69+
70+
if ("transclude" in config) {
71+
warn("LINE TRANSCLUSION DETECTED", f, includedPath);
72+
return old;
73+
}
74+
75+
let replacement = `<<< @/${includedPath}`;
76+
if ("transcludeWith" in config) {
77+
const region = config.transcludeWith
78+
.replace(/^[:_#]+/, "")
79+
.replace(/:+$/, "")
80+
.replaceAll("_", "-")
81+
.replaceAll(":", "--")
82+
.replace("Lightning", "lightning")
83+
.replace("hudLayer", "hud-layer")
84+
.replace("registerMenu", "register-menu")
85+
.replace("providerImplemented", "provider-implemented")
86+
.replace("registerScreens", "register-screens")
87+
.replace("gameruleClass", "gamerule-class")
88+
.replace(/^$/, "TODO-give-me-a-name");
89+
90+
if (!/^[a-z0-9-]+$/.test(region) && region !== "TODO-give-me-a-name") {
91+
warn("WEIRD REGION", region, f);
92+
}
93+
94+
replacement += "#";
95+
replacement += region;
96+
97+
const splits = (
98+
javaToNewMap[includedPath as keyof typeof javaToNewMap]
99+
|| fs.readFileSync(includedPath, "utf-8")
100+
).split(config.transcludeWith);
101+
102+
if (splits.length % 2 === 0) {
103+
warn("ODD NUMBER OF COMMENTS", region, includedPath, f);
104+
}
105+
106+
for (let i = 0; i < splits.length - 1; i++) {
107+
if (!/(\n[\t ]*(?:\/\/|#)) ?$/.test(splits[i])) {
108+
warn("WEIRD PRE-TRANSCLUSION", region, includedPath, f);
109+
}
110+
111+
splits[i] = splits[i].replace(
112+
/(\n[\t ]*(?:\/\/|#)) ?$/,
113+
(_, group) => group + ` #${i % 2 !== 0 ? "end" : ""}region ${region}`
114+
);
115+
}
116+
117+
for (const post of splits.slice(1)) {
118+
if (!/^\n/.test(post)) {
119+
warn("WEIRD POST-TRANSCLUSION", region, includedPath, f);
120+
}
121+
}
122+
123+
javaToNewMap[includedPath] = splits.join("");
124+
}
125+
126+
if ("highlight" in config) {
127+
replacement += config.highlight;
128+
}
129+
130+
return replacement;
131+
}
132+
);
133+
134+
if (process.env.DO_IT) {
135+
fs.writeFileSync(f, newContent);
136+
}
137+
}
138+
139+
if (process.env.DO_IT) {
140+
for (const f of Object.keys(javaToNewMap)) {
141+
fs.writeFileSync(f, javaToNewMap[f]);
142+
}
143+
}

contributing.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ git clone https://github.com/your-username/fabric-docs.git
6161

6262
#### Installing Dependencies {#install-dependencies}
6363

64-
If you want to preview your changes locally, you will need to install [Node.js 18+](https://nodejs.org/en/).
64+
If you want to preview your changes locally, you will need to install [Node.js 18+](https://nodejs.org/en/) and [pnpm](https://pnpm.io/).
6565

6666
After that, make sure to install all dependencies with:
6767

6868
```sh
69-
npm install
69+
pnpm install
7070
```
7171

7272
#### Running the Development Server {#run-the-development-server}
7373

7474
This will allow you to preview your changes locally at `localhost:5173` and will automatically reload the page when you make changes.
7575

7676
```sh
77-
npm run dev
77+
pnpm dev
7878
```
7979

8080
Now you can open and browse the website from the browser by visiting `http://localhost:5173`.
@@ -84,15 +84,15 @@ Now you can open and browse the website from the browser by visiting `http://loc
8484
This will compile all Markdown files into static HTML files and place them in `.vitepress/dist`:
8585

8686
```sh
87-
npm run build
87+
pnpm build
8888
```
8989

9090
#### Previewing the Built Website {#previewing-the-built-website}
9191

9292
This will start a local server on port `4173` serving the content found in `.vitepress/dist`:
9393

9494
```sh
95-
npm run preview
95+
pnpm preview
9696
```
9797

9898
#### Opening a Pull Request {#opening-a-pull-request}
@@ -189,21 +189,7 @@ For example, to highlight lines 15-21 of the `ExampleMod.java` file from the mod
189189
<<< @/reference/latest/src/main/java/com/example/docs/ExampleMod.java{15-21}
190190
```
191191

192-
<<< @/reference/latest/src/main/java/com/example/docs/ExampleMod.java{15-21}[java]
193-
194-
:::
195-
196-
If you need a greater span of control, you can use the [transclude feature from `markdown-it-vuepress-code-snippet-enhanced`](https://github.com/fabioaanthony/markdown-it-vuepress-code-snippet-enhanced).
197-
198-
For example, this will embed the sections of the file above that are marked with the `#entrypoint` tag:
199-
200-
::: code-group
201-
202-
```md
203-
@[code transcludeWith=#entrypoint](@/reference/latest/src/main/java/com/example/docs/ExampleMod.java)
204-
```
205-
206-
@[code transcludeWith=#entrypoint](@/reference/latest/src/main/java/com/example/docs/ExampleMod.java)
192+
<<< @/reference/latest/src/main/java/com/example/docs/ExampleMod.java{15-21}
207193

208194
:::
209195

develop/blocks/block-containers.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ In this tutorial we'll create a block that uses its container to duplicate any i
1515

1616
This should be familiar to the reader if they've followed the [Creating Your First Block](../blocks/first-block) and [Block Entities](../blocks/block-entities) guides. We'll create a `DuplicatorBlock` that extends `BaseEntityBlock` and implements `EntityBlock`.
1717

18-
@[code transcludeWith=:::block](@/reference/latest/src/main/java/com/example/docs/block/custom/DuplicatorBlock.java)
18+
<<< @/reference/latest/src/main/java/com/example/docs/block/custom/DuplicatorBlock.java#block
1919

2020
Then, we need to create a `DuplicatorBlockEntity`, which needs to implement the `Container` interface. As most containers are generally expected to work the same way, you can copy and paste a helper called `ImplementedContainer` that does most of the work, leaving us with just a few methods to implement.
2121

2222
::: details Show `ImplementedContainer`
2323

24-
@[code](@/reference/latest/src/main/java/com/example/docs/container/ImplementedContainer.java)
24+
<<< @/reference/latest/src/main/java/com/example/docs/container/ImplementedContainer.java
2525

2626
:::
2727

28-
@[code transcludeWith=:::be](@/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java)
28+
<<< @/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java#be
2929

3030
The `items` list is where the container's contents are stored. For this block we have it set to a size of 1 slot for the input.
3131

@@ -35,15 +35,15 @@ Don't forget to register the block and block entity in their respective classes!
3535

3636
If we want the contents to persist between game reloads like a vanilla `BlockEntity`, we need to save it as NBT. Thankfully, Mojang provides a helper class called `ContainerHelper` with all the necessary logic.
3737

38-
@[code transcludeWith=:::save](@/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java)
38+
<<< @/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java#save
3939

4040
## Interacting with the Container {#interacting-with-the-container}
4141

4242
Technically, the container is already functional. However, to insert items, we currently need to use hoppers. Let's make it so that we can insert items by right-clicking the block.
4343

4444
To do that, we need to override the `useItemOn` method in the `DuplicatorBlock`:
4545

46-
@[code transcludeWith=:::useon](@/reference/latest/src/main/java/com/example/docs/block/custom/DuplicatorBlock.java)
46+
<<< @/reference/latest/src/main/java/com/example/docs/block/custom/DuplicatorBlock.java#useon
4747

4848
Here, if the player is holding an item and there is an empty slot, we move the item from the player's hand to the block's container and return `InteractionResult.SUCCESS`.
4949

@@ -57,7 +57,7 @@ Let's now make it so that the block duplicates the stack you threw in it, but on
5757

5858
To do this, we'll add a `tick` function to the `DuplicatorBlockEntity`, and a field to store how much we've been waiting:
5959

60-
@[code transcludeWith=:::tick](@/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java)
60+
<<< @/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java#tick
6161

6262
The `DuplicatorBlock` should now have a `getTicker` method that returns a reference to `DuplicatorBlockEntity::tick`.
6363

@@ -75,13 +75,13 @@ To create this behavior, we need to implement the `WorldlyContainer` interface i
7575

7676
Let's modify the `DuplicatorBlockEntity` to only accept items from the top:
7777

78-
@[code transcludeWith=:::accept](@/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java)
78+
<<< @/reference/latest/src/main/java/com/example/docs/block/entity/custom/DuplicatorBlockEntity.java#accept
7979

8080
The `getSlotsForFace` returns an array of the slot _indices_ that can be interacted with from the given side. In this case, we only have a single slot (`0`), so we return an array with just that index.
8181

8282
Also, we should modify the `useItemOn` method of the `DuplicatorBlock` to actually respect the new behavior:
8383

84-
@[code transcludeWith=:::place](@/reference/latest/src/main/java/com/example/docs/block/custom/DuplicatorBlock.java)
84+
<<< @/reference/latest/src/main/java/com/example/docs/block/custom/DuplicatorBlock.java#place
8585

8686
Now, if we try to insert items from the side instead of the top, it won't work!
8787

develop/blocks/block-entity-renderer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ When creating a `BlockEntityRenderer` for the `CounterBlockEntity`, it's importa
1919

2020
First, we need to create a `BlockEntityRenderState` for our `CounterBlockEntity` to hold the data that will be used for rendering. In this case, we will need the `clicks` to be available during rendering.
2121

22-
@[code transcludeWith=::render-state](@/reference/latest/src/client/java/com/example/docs/rendering/blockentity/CounterBlockEntityRenderState.java)
22+
@[code transcludeWith=:::render-state](@/reference/latest/src/client/java/com/example/docs/rendering/blockentity/CounterBlockEntityRenderState.java)
2323

2424
Then we create a `BlockEntityRenderer` for our `CounterBlockEntity`.
2525

develop/data-generation/advancements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Now that we've got a criterion and its conditions, we need a way to trigger it.
113113

114114
Almost there! Next, we need an instance of our criterion to work with. Let's put it in a new class, called `ModCriteria`.
115115

116-
@[code lang=java transcludeWith=:::datagen-advancements:mod-criteria](@/reference/latest/src/main/java/com/example/docs/advancement/ModCriteria.java)
116+
@[code lang=java transcludeWith=:::datagen-advancements:mod-criteria:](@/reference/latest/src/main/java/com/example/docs/advancement/ModCriteria.java)
117117

118118
To make sure that our criteria are initialized at the right time, add a blank `init` method:
119119

0 commit comments

Comments
 (0)