diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-07-10 06:52:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-10 00:52:31 +0200 |
commit | 6aad9749d2b5203faf164cc33328174047c287e8 (patch) | |
tree | feed74daa3b58a383e9caacab4e1ba7c3bc34111 /docs/testing/documentation.md | |
parent | ab079a8d63e9a32d2ddae1071797f57823357967 (diff) |
docs(manual): split testing into multiple chapters (#11067)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'docs/testing/documentation.md')
-rw-r--r-- | docs/testing/documentation.md | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/docs/testing/documentation.md b/docs/testing/documentation.md new file mode 100644 index 000000000..f0a2061db --- /dev/null +++ b/docs/testing/documentation.md @@ -0,0 +1,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"; +} +```` |