Skip to content

Commit 9658008

Browse files
authored
Merge pull request #8 from mengxinssfd/support-typedoc-v0.26
Support typedoc v0.26
2 parents 17bc252 + 6f2298b commit 9658008

23 files changed

+761
-438
lines changed

assets/style.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
vertical-align: top;
5151
margin: 0;
5252
}
53-
.tsd-navigation.settings h3{
53+
.tsd-navigation.settings h3,
54+
.tsd-accordion-summary h3 {
5455
display: flex;
5556
align-items: center;
5657
font-size: 14px;

example/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This project shows off some of TypeDoc's features:
2323

2424
- Built-in support for various TypeScript language constructs
2525
- Markdown in doc comments
26-
- Syntax highligting in code blocks
26+
- Syntax highlighting in code blocks
2727

2828
## Index of Examples
2929

@@ -34,8 +34,9 @@ Here are some examples we wanted to highlight:
3434

3535
### Rendering
3636

37-
- Markdown showcase: {@link markdownShowcase | `markdownShowcase`}
38-
- Syntax highlighting showcase: {@link syntaxHighlightingShowcase | `syntaxHighlightingShowcase` }
37+
- External Markdown: [here](./src/documents/external-markdown.md)
38+
- Markdown showcase: [here](./src/documents/markdown.md)
39+
- Syntax highlighting showcase: [here](./src/documents/syntax-highlighting.md)
3940

4041
### Functions
4142

example/media/typescript-logo.svg

+6
Loading

example/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typedoc-theme-example",
33
"version": "1.1.3",
44
"scripts": {
5-
"build:docs": "typedoc"
5+
"build:docs": "typedoc --options ./typedoc.json"
66
},
77
"license": "MIT",
88
"devDependencies": {
@@ -11,6 +11,7 @@
1111
"@types/react-dom": "^18.0.11",
1212
"lodash": "^4.17.21",
1313
"react": "^18.2.0",
14-
"react-dom": "^18.2.0"
14+
"react-dom": "^18.2.0",
15+
"typedoc": "^0.26.2"
1516
}
1617
}

example/src/classes/CancellablePromise.ts

+31-25
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ function isPromiseWithCancel<T>(value: unknown): value is PromiseWithCancel<T> {
4242
* [real-cancellable-promise](https://github.com/srmagura/real-cancellable-promise).
4343
*
4444
* @typeParam T what the `CancellablePromise` resolves to
45+
*
46+
* @groupDescription Methods
47+
* Descriptions can be added for groups with `@groupDescription`, which will show up in
48+
* the index where groups are listed. This works for both manually created groups which
49+
* are created with `@group`, and implicit groups like the `Methods` group that this
50+
* description is attached to.
4551
*/
4652
export class CancellablePromise<T> {
4753
/**
@@ -100,7 +106,7 @@ export class CancellablePromise<T> {
100106
onRejected?:
101107
| ((reason: any) => TResult2 | PromiseLike<TResult2>)
102108
| undefined
103-
| null
109+
| null,
104110
): CancellablePromise<TResult1 | TResult2> {
105111
let fulfill;
106112
let reject;
@@ -147,7 +153,7 @@ export class CancellablePromise<T> {
147153
onRejected?:
148154
| ((reason: any) => TResult | PromiseLike<TResult>)
149155
| undefined
150-
| null
156+
| null,
151157
): CancellablePromise<T | TResult> {
152158
return this.then(undefined, onRejected);
153159
}
@@ -161,11 +167,11 @@ export class CancellablePromise<T> {
161167
* @returns A Promise for the completion of the callback.
162168
*/
163169
finally(
164-
onFinally?: (() => void) | undefined | null
170+
onFinally?: (() => void) | undefined | null,
165171
): CancellablePromise<T> {
166172
return new CancellablePromise(
167173
this.promise.finally(onFinally),
168-
this.cancel
174+
this.cancel,
169175
);
170176
}
171177

@@ -207,8 +213,8 @@ export class CancellablePromise<T> {
207213
T7 | PromiseLike<T7>,
208214
T8 | PromiseLike<T8>,
209215
T9 | PromiseLike<T9>,
210-
T10 | PromiseLike<T10>
211-
]
216+
T10 | PromiseLike<T10>,
217+
],
212218
): CancellablePromise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
213219

214220
static all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
@@ -221,8 +227,8 @@ export class CancellablePromise<T> {
221227
T6 | PromiseLike<T6>,
222228
T7 | PromiseLike<T7>,
223229
T8 | PromiseLike<T8>,
224-
T9 | PromiseLike<T9>
225-
]
230+
T9 | PromiseLike<T9>,
231+
],
226232
): CancellablePromise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
227233

228234
static all<T1, T2, T3, T4, T5, T6, T7, T8>(
@@ -234,8 +240,8 @@ export class CancellablePromise<T> {
234240
T5 | PromiseLike<T5>,
235241
T6 | PromiseLike<T6>,
236242
T7 | PromiseLike<T7>,
237-
T8 | PromiseLike<T8>
238-
]
243+
T8 | PromiseLike<T8>,
244+
],
239245
): CancellablePromise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
240246

241247
static all<T1, T2, T3, T4, T5, T6, T7>(
@@ -246,8 +252,8 @@ export class CancellablePromise<T> {
246252
T4 | PromiseLike<T4>,
247253
T5 | PromiseLike<T5>,
248254
T6 | PromiseLike<T6>,
249-
T7 | PromiseLike<T7>
250-
]
255+
T7 | PromiseLike<T7>,
256+
],
251257
): CancellablePromise<[T1, T2, T3, T4, T5, T6, T7]>;
252258

253259
static all<T1, T2, T3, T4, T5, T6>(
@@ -257,8 +263,8 @@ export class CancellablePromise<T> {
257263
T3 | PromiseLike<T3>,
258264
T4 | PromiseLike<T4>,
259265
T5 | PromiseLike<T5>,
260-
T6 | PromiseLike<T6>
261-
]
266+
T6 | PromiseLike<T6>,
267+
],
262268
): CancellablePromise<[T1, T2, T3, T4, T5, T6]>;
263269

264270
static all<T1, T2, T3, T4, T5>(
@@ -267,33 +273,33 @@ export class CancellablePromise<T> {
267273
T2 | PromiseLike<T2>,
268274
T3 | PromiseLike<T3>,
269275
T4 | PromiseLike<T4>,
270-
T5 | PromiseLike<T5>
271-
]
276+
T5 | PromiseLike<T5>,
277+
],
272278
): CancellablePromise<[T1, T2, T3, T4, T5]>;
273279

274280
static all<T1, T2, T3, T4>(
275281
values: readonly [
276282
T1 | PromiseLike<T1>,
277283
T2 | PromiseLike<T2>,
278284
T3 | PromiseLike<T3>,
279-
T4 | PromiseLike<T4>
280-
]
285+
T4 | PromiseLike<T4>,
286+
],
281287
): CancellablePromise<[T1, T2, T3, T4]>;
282288

283289
static all<T1, T2, T3>(
284290
values: readonly [
285291
T1 | PromiseLike<T1>,
286292
T2 | PromiseLike<T2>,
287-
T3 | PromiseLike<T3>
288-
]
293+
T3 | PromiseLike<T3>,
294+
],
289295
): CancellablePromise<[T1, T2, T3]>;
290296

291297
static all<T1, T2>(
292-
values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]
298+
values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>],
293299
): CancellablePromise<[T1, T2]>;
294300

295301
static all<T>(
296-
values: readonly (T | PromiseLike<T>)[]
302+
values: readonly (T | PromiseLike<T>)[],
297303
): CancellablePromise<T[]>;
298304

299305
/**
@@ -319,7 +325,7 @@ export class CancellablePromise<T> {
319325
* @returns A new `CancellablePromise`.
320326
*/
321327
static allSettled<T extends readonly unknown[] | readonly [unknown]>(
322-
values: T
328+
values: T,
323329
): CancellablePromise<{
324330
-readonly [P in keyof T]: PromiseSettledResult<
325331
T[P] extends PromiseLike<infer U> ? U : T[P]
@@ -335,7 +341,7 @@ export class CancellablePromise<T> {
335341
* promises.
336342
*/
337343
static allSettled<T>(
338-
values: Iterable<T>
344+
values: Iterable<T>,
339345
): CancellablePromise<
340346
PromiseSettledResult<T extends PromiseLike<infer U> ? U : T>[]
341347
>;
@@ -375,7 +381,7 @@ export class CancellablePromise<T> {
375381
* @returns a `CancellablePromise` that resolves after `ms` milliseconds.
376382
*/
377383
static delay(ms: number): CancellablePromise<void> {
378-
let timer: NodeJS.Timer | undefined;
384+
let timer: ReturnType<typeof setTimeout> | undefined;
379385
let rejectFn: (reason?: any) => void = noop;
380386

381387
const promise = new Promise<void>((resolve, reject) => {

example/src/classes/Customer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class DeliveryCustomer extends Customer {
9999
id: number,
100100
name: string,
101101
nextOrderNumber: string | number,
102-
subscriptionType: "basic" | "enterprise"
102+
subscriptionType: "basic" | "enterprise",
103103
) {
104104
super(id, name, nextOrderNumber);
105105
this.subscriptionType = subscriptionType;
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: External Markdown
3+
category: Documents
4+
---
5+
6+
# External Markdown
7+
8+
It can be convenient to write long-form guides/tutorials outside of doc comments.
9+
To support this, TypeDoc supports including documents (like this page!) which exist
10+
as standalone `.md` files in your repository.
11+
12+
## Including Documents
13+
14+
These documents can be included in your generated documentation in a few ways.
15+
16+
1. With the [`@document`](https://typedoc.org/tags/document/) tag.
17+
2. With the [projectDocuments] option.
18+
3. As a child of another document using yaml frontmatter.
19+
20+
### The `@document` Tag
21+
22+
The `@document` tag can be placed in the comments for most types to add
23+
a child to that reflection in the generated documentation. The content of
24+
the `@document` tag should simply be a path to a markdown document to be
25+
included in the site. As an example, the [tag which caused this file](https://github.com/TypeStrong/typedoc/blob/master/example/src/index.ts#L7)
26+
to be included in the example site was formatted as:
27+
28+
```ts
29+
/**
30+
* @document documents/external-markdown.md
31+
*/
32+
```
33+
34+
The document path is relative to the file in which the comment appears in.
35+
36+
### Project Documents
37+
38+
If your project has multiple entry points, the `@document` tag cannot be used
39+
to place documents at the top level of the project as there is no comment location
40+
associated with the project. For this use case, specify the [projectDocuments]
41+
option. This option can be specified multiple times, or a glob may be specified
42+
to include multiple documents.
43+
44+
```jsonc
45+
// typedoc.json
46+
{
47+
"projectDocuments": ["documents/*.md"],
48+
}
49+
```
50+
51+
TypeDoc's default [sorting](https://typedoc.org/options/organization/#sort) options
52+
will cause project documents to be re-ordered alphabetically. If not desired, sorting
53+
for entry points can be disabled with the [sortEntryPoints](https://typedoc.org/options/organization/#sortentrypoints)
54+
option.
55+
56+
## Document Content
57+
58+
Documents may include a yaml frontmatter section which can be used to control
59+
some details about the document.
60+
61+
```yaml
62+
---
63+
title: External Markdown
64+
group: Documents
65+
category: Guides
66+
children:
67+
- ./child.md
68+
- ./child2.md
69+
---
70+
```
71+
72+
The `title` key specifies the document name, which will be used in the sidebar
73+
navigation. The `group` and `category` keys are equivalent to the
74+
[`@group`](https://typedoc.org/tags/group/)and [`@category`](https://typedoc.org/tags/category/)
75+
tags and control how the document shows up in the Index section on the page
76+
for the reflection which owns the document. The `children` key can be used to specify
77+
additional documents which should be added underneath the current document.
78+
79+
Documents may include relative links to images or other files/documents. TypeDoc
80+
will detect links within markdown `[text](link)` formatted links, `<a>` tags
81+
and `<img>` tags and automatically resolve them to other documents in the project.
82+
83+
if a path cannot be resolved to a part of the documentation, TypeDoc will copy
84+
the file found to a `media` folder in your generated documentation and update the
85+
link to point to it, so relative links to images will still work.
86+
87+
Documents may also include `{@link}` inline tags, which will be resolved as
88+
[declaration references](https://typedoc.org/guides/declaration-references/) by
89+
TypeDoc.
90+
91+
[this page]: https://github.com/TypeStrong/typedoc/blob/master/example/src/documents/external-markdown.md
92+
[projectDocuments]: https://typedoc.org/options/input/#projectdocuments

example/src/documents/markdown.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Markdown Showcase
3+
category: Documents
4+
---
5+
6+
# Markdown Showcase
7+
8+
All comments are parsed as **Markdown**. TypeDoc uses the
9+
[markdown-it](https://github.com/markdown-it/markdown-it) markdown parser to _convert
10+
comments to HTML_.
11+
12+
TypeDoc also supports including arbitrary Markdown documents in your site. These can be top level
13+
documents added with the `--projectDocuments` option or added with the `@document` tag.
14+
15+
## Symbol References
16+
17+
You can link to other classes, members or functions using an inline link tag. See the [TypeDoc
18+
documentation](https://typedoc.org/tags/link/) for
19+
details.
20+
21+
## Code in Doc Comments
22+
23+
Some inline code: `npm install --save-dev typedoc`
24+
25+
A TypeScript code block:
26+
27+
```
28+
// A fabulous variable
29+
const x: number | string = 12
30+
```
31+
32+
See {@link syntaxHighlightingShowcase | `syntaxHighlightingShowcase`} for more code blocks.
33+
34+
## A List
35+
36+
- 🥚 ~~Eggs~~
37+
- 🍞 Bread
38+
- 🧀 Swiss cheese
39+
40+
## A Table
41+
42+
| Package | Version |
43+
| ------- | ------- |
44+
| lodash | 4.17.21 |
45+
| react | 17.0.2 |
46+
| typedoc | 0.22.4 |
47+
48+
A Random Shakespeare Quote
49+
50+
---
51+
52+
> Rebellious subjects, enemies to peace, Profaners of this neighbour-stained
53+
> steel,-- Will they not hear? What, ho! you men, you beasts, That quench the
54+
> fire of your pernicious rage With purple fountains issuing from your veins
55+
56+
## An Image
57+
58+
<img src="../../media/typescript-logo.svg" width="120" />

0 commit comments

Comments
 (0)