Skip to content

Commit 38e50f1

Browse files
authored
docs: show icons in code-groups and code titles, update sidebar (#6970)
1 parent be969cf commit 38e50f1

30 files changed

+674
-523
lines changed

docs/.vitepress/config.ts

Lines changed: 246 additions & 177 deletions
Large diffs are not rendered by default.

docs/.vitepress/style/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ html:not(.dark) [img-dark] {
66
display: none;
77
}
88

9+
details summary {
10+
cursor: pointer;
11+
}
12+
913
/* Overrides */
1014

1115
.sp .sp-link.link:hover,

docs/.vitepress/theme/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import '../style/main.css'
1010
import '../style/vars.css'
1111
import 'uno.css'
1212
import '@shikijs/vitepress-twoslash/style.css'
13+
import 'virtual:group-icons.css'
1314

1415
if (inBrowser) {
1516
import('./pwa')

docs/advanced/metadata.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ test('custom', ({ task }) => {
2222

2323
Once a test is completed, Vitest will send a task including the result and `meta` to the Node.js process using RPC. To intercept and process this task, you can utilize the `onTaskUpdate` method available in your reporter implementation:
2424

25-
```ts
26-
// custom-reporter.js
25+
```ts [custom-reporter.js]
2726
export default {
2827
// you can intercept packs if needed
2928
onTaskUpdate(packs) {

docs/advanced/reporters.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ Of course, you can create your reporter from scratch. Just extend the `BaseRepor
1818

1919
And here is an example of a custom reporter:
2020

21-
```ts
22-
// ./custom-reporter.js
21+
```ts [custom-reporter.js]
2322
import { BaseReporter } from 'vitest/reporters'
2423

2524
export default class CustomReporter extends BaseReporter {
@@ -32,8 +31,7 @@ export default class CustomReporter extends BaseReporter {
3231

3332
Or implement the `Reporter` interface:
3433

35-
```ts
36-
// ./custom-reporter.js
34+
```ts [custom-reporter.js]
3735
import { Reporter } from 'vitest/reporters'
3836

3937
export default class CustomReporter implements Reporter {
@@ -45,7 +43,7 @@ export default class CustomReporter implements Reporter {
4543

4644
Then you can use your custom reporter in the `vitest.config.ts` file:
4745

48-
```ts
46+
```ts [vitest.config.ts]
4947
import { defineConfig } from 'vitest/config'
5048
import CustomReporter from './custom-reporter.js'
5149

docs/advanced/runner.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ Vitest exposes a `Custom` task type that allows users to reuse built-int reporte
246246

247247
A task is an object that is part of a suite. It is automatically added to the current suite with a `suite.task` method:
248248

249-
```js
250-
// ./utils/custom.js
249+
```js [custom.js]
251250
import { createTaskCollector, getCurrentSuite, setFn } from 'vitest/suite'
252251

253252
export { afterAll, beforeAll, describe } from 'vitest'
@@ -270,9 +269,8 @@ export const myCustomTask = createTaskCollector(
270269
)
271270
```
272271

273-
```js
274-
// ./garden/tasks.test.js
275-
import { afterAll, beforeAll, describe, myCustomTask } from '../custom.js'
272+
```js [tasks.test.js]
273+
import { afterAll, beforeAll, describe, myCustomTask } from './custom.js'
276274
import { gardener } from './gardener.js'
277275

278276
describe('take care of the garden', () => {

docs/api/vi.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ For example, you have this file structure:
136136

137137
If you call `vi.mock` in a test file without a factory or options provided, it will find a file in the `__mocks__` folder to use as a module:
138138

139-
```ts
140-
// increment.test.js
139+
```ts [increment.test.js]
141140
import { vi } from 'vitest'
142141

143142
// axios is a default export from `__mocks__/axios.js`
@@ -175,14 +174,13 @@ import { increment } from './increment.js'
175174
```
176175
:::
177176

178-
```ts
179-
// ./increment.js
177+
```ts [increment.js]
180178
export function increment(number) {
181179
return number + 1
182180
}
183181
```
184182

185-
```ts
183+
```ts [increment.test.js]
186184
import { beforeEach, test } from 'vitest'
187185
import { increment } from './increment.js'
188186

@@ -216,8 +214,7 @@ Type helper for TypeScript. Just returns the object that was passed.
216214

217215
When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will only make TypeScript believe that the first level values are mocked. You can pass down `{ deep: true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually is.
218216

219-
```ts
220-
// example.ts
217+
```ts [example.ts]
221218
export function add(x: number, y: number): number {
222219
return x + y
223220
}
@@ -227,8 +224,7 @@ export function fetchSomething(): Promise<Response> {
227224
}
228225
```
229226

230-
```ts
231-
// example.test.ts
227+
```ts [example.test.ts]
232228
import * as example from './example'
233229

234230
vi.mock('./example')
@@ -277,14 +273,13 @@ Removes module from the mocked registry. All calls to import will return the ori
277273

278274
The same as [`vi.unmock`](#vi-unmock), but is not hoisted to the top of the file. The next import of the module will import the original module instead of the mock. This will not unmock previously imported modules.
279275

280-
```ts
281-
// ./increment.js
276+
```ts [increment.js]
282277
export function increment(number) {
283278
return number + 1
284279
}
285280
```
286281

287-
```ts
282+
```ts [increment.test.js]
288283
import { increment } from './increment.js'
289284

290285
// increment is already mocked, because vi.mock is hoisted

docs/config/file.md

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)