Skip to content

Commit

Permalink
Add support for automatic entry points
Browse files Browse the repository at this point in the history
If a package uses a "typedoc" conditional export, then TypeDoc
will use that. If not provided, TypeDoc will use the "import"
and "node" import conditions

Resolves #1937
  • Loading branch information
Gerrit0 committed Sep 8, 2024
1 parent 03af76a commit 6d323a1
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 67 deletions.
2 changes: 0 additions & 2 deletions .config/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"alphabetical-ignoring-documents"
],
"name": "TypeDoc API",
"entryPointStrategy": "resolve",
"entryPoints": ["../src/index.ts"],

"excludeExternals": true,
"excludeInternal": false,
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: Changelog

# Beta

- TypeDoc will now discover entry points from `package.json` exports if they are not provided manually, #1937.
- Fixed an issue where properties were not properly marked optional in some cases. This primarily affected destructured parameters.
- Constructor signatures now use the parent class name as their name (e.g. `X`, not `new X`)
- Removed the `hideParameterTypesInTitle` option, this was originally added as a workaround for many signatures overflowing
Expand Down
82 changes: 46 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"markdown-it": "^14.1.0",
"minimatch": "^9.0.5",
"shiki": "^1.9.1",
"yaml": "^2.4.5"
"yaml": "^2.4.5",
"resolve-import": "^1.4.6"
},
"peerDependencies": {
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x"
Expand Down
11 changes: 9 additions & 2 deletions site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ or a JSON model.
## Quick Start

TypeDoc generates documentation based on your exports. It will follow re-exports
to document members declared in other files.
to document members declared in other files for each entry point.

```bash
# Install
npm install --save-dev typedoc

# Build docs using the exports of src/index.ts
# Build docs using package.json "exports" or "main" fields as entry points
npx typedoc
```

If TypeDoc is unable to discover your entry points, they can be provided manually:

```bash
# Build docs using exports from src/index.ts
npx typedoc src/index.ts
```

Expand Down
10 changes: 10 additions & 0 deletions site/options/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ the exports of these files and create documentation according to the exports.
Entry points can be handled in one of four ways, see [--entryPointStrategy](#entryPointStrategy)
for details.

If this option is not set, TypeDoc will automatically discover your entry points
according to the ["exports"](https://nodejs.org/api/packages.html#exports) or
["main"](https://nodejs.org/api/packages.html#main) fields in your package.json,
using your tsconfig options to map the JavaScript files back to the original TypeScript
source.

If a `"typedoc"` [conditional
export](https://nodejs.org/api/packages.html#conditional-exports) is used,
TypeDoc will use it instead of the `"import"` export condition.

The set of entry points provided to TypeDoc determines the names displayed in the documentation.
By default, TypeDoc will derive a [basePath](output.md#basePath) based on your entry point
paths to determine the displayed module name, but it can be also be set with the [`@module`](../tags/module.md) tag.
Expand Down
Loading

0 comments on commit 6d323a1

Please sign in to comment.