@@ -24,6 +24,55 @@ Note this only builds for English locale unlike a production build.
2424> Documentation is written in ` mdx ` , a superset of markdown empowered with jsx.
2525> JetBrains and VSCode both provide MDX plugins.
2626
27+ ## Testing
28+
29+ ``` console
30+ cargo run website-test
31+ ```
32+
33+ [ ` website-test ` ] ( ../tools/website-test ) is a tool to test all code blocks in the docs as Rust doctests.
34+ It gathers the Rust code blocks automatically, but by default they're all tested separate. In case of a
35+ walkthrough, it makes more sense to combine the changes described in the blocks & test the code as one.
36+ For this end ` website-test ` scans all doc files for a special flag:
37+
38+ ``` html
39+ <!-- COMBINE CODE BLOCKS >
40+ ```
41+ If a file ends with this specific comment (and an optional newline after it), all code blocks will be
42+ sown together, with respect to the diff markers in them. For example:
43+
44+ ```md
45+ \`\`\`rust
46+ fn main() {
47+ println!("Hello, World");
48+ }
49+ \`\`\`
50+
51+ \`\`\`rust
52+ fn main() {
53+ - println!("Hello, World");
54+ + println!("Goodbye, World");
55+ }
56+ \`\`\`
57+
58+ <!-- COMBINE CODE BLOCKS>
59+ ```
60+
61+ Will be tested as:
62+ ```rust
63+ fn main() {
64+ println!("Goodbye, World");
65+ }
66+ ```
67+
68+ :::warning
69+ The current implementation only uses the code before the diff or the code to remove as context,
70+ so make sure there's enough of it. The test assembler will tell you if there isn't.
71+ :::
72+
73+ While assembling the code blocks, the test assembler will put special meaning into a code
74+ line `// ...`. This line tells the test assembler to disregard any previous context for applying a diff
75+
2776## Production Build
2877
2978```console
0 commit comments