blob: f0a2061dba587f11acd7408a42a823113fa498d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# Documentation tests
Deno supports type-checking your documentation examples.
This makes sure that examples within your documentation are up to date and
working.
The basic idea is this:
````ts
/**
* # Examples
*
* ```ts
* const x = 42;
* ```
*/
````
The triple backticks mark the start and end of code blocks.
If this example was in a file named foo.ts, running `deno test --doc foo.ts`
will extract this example, and then type-check it as a standalone module living
in the same directory as the module being documented.
To document your exports, import the module using a relative path specifier:
````ts
/**
* # Examples
*
* ```ts
* import { foo } from "./foo.ts";
* ```
*/
export function foo(): string {
return "foo";
}
````
|