summaryrefslogtreecommitdiff
path: root/docs/tools/documentation_generator.md
blob: 661fa22e5d200c6453a71a8830e20a501a9cca2f (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
## Documentation Generator

`deno doc` followed by a list of one or more source files will print the JSDoc
documentation for each of the module's **exported** members. Currently, only
exports in the style `export <declaration>` and `export ... from ...` are are
supported.

For example, given a file `add.ts` with the contents:

```ts
/**
 * Adds x and y.
 * @param {number} x
 * @param {number} y
 * @returns {number} Sum of x and y
 */
export function add(x: number, y: number): number {
  return x + y;
}
```

Running the Deno `doc` command, prints the function's JSDoc comment to `stdout`:

```shell
deno doc add.ts
function add(x: number, y: number): number
  Adds x and y. @param {number} x @param {number} y @returns {number} Sum of x and y
```

Use the `--json` flag to output the documentation in JSON format. This JSON
format is consumed by the
[deno doc website](https://github.com/denoland/doc_website) and used to generate
module documentation.