Skip to content

Commit 980a621

Browse files
Update README to reflect new module resolution method
1 parent c6b98a6 commit 980a621

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@ JSDoc accepts plugins by simply installing their npm package:
1010

1111
To configure JSDoc to use the plugin, add the following to the JSDoc configuration file, e.g. `conf.json`:
1212

13-
```json
13+
```jsonc
1414
"plugins": [
1515
"jsdoc-plugin-typescript"
1616
],
1717
"typescript": {
18-
"moduleRoot": "src"
18+
"moduleRoot": "src" // optional
1919
}
2020
```
2121

2222
See http://usejsdoc.org/about-configuring-jsdoc.html for more details on how to configure JSDoc.
2323

24-
In the above snippet, `"src"` is the directory that contains the source files. Inside that directory, each `.js` file needs a `@module` annotation with a path relative to that `"moduleRoot"`, e.g.
24+
If `typescript.moduleRoot` is specified, the plugin will assume module ids are relative to that directory and format them as such. For example, `@type {import("./folder/file").Class}` will be converted to `@type {module:folder/file.Class}`. The file extension is removed along with any leading `../` segments (if the referenced module is outside `moduleRoot`).
2525

26-
```js
27-
/** @module ol/proj **/
28-
```
26+
In the absence of `typescript.moduleRoot`, the plugin will mirror the method JSDoc uses to assign module ids:
27+
28+
1. Parse the referenced module for an `@module` tag.
29+
2. If a tag is found and it has an explicit id, use that.
30+
3. If a tag is found, but it doesn't have an explicit id, use the file path relative to the **nearest shared parent directory**, and remove the file extension.
2931

3032
## What this plugin does
3133

0 commit comments

Comments
 (0)