Skip to content

Commit 7d3f326

Browse files
committed
feat: Automatically add @source tag
Resolves #15
1 parent 590dabd commit 7d3f326

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Block tags are output as "title case" headings in the final output. If you would
7676

7777
### Handling "unknown block tag" warning
7878

79+
If you specify custom tags for TypeDoc via a `tsdoc.json` file or through TypeDoc's
80+
`blockTags` options, then you will need to add `@source` to the block tags list.
7981
When using the tag, TypeDoc (since 0.26) will generate the following warning:
8082

8183
```shell

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ import {
88
} from 'typedoc';
99
import ts from 'typescript';
1010
import plugin from './plugin.js';
11+
import { TAG_NAME } from './constants.js';
1112

1213
export function load(app: Application) {
14+
app.on(Application.EVENT_BOOTSTRAP_END, () => {
15+
if (!app.options.isSet('blockTags')) {
16+
app.options.setValue('blockTags', [
17+
...app.options.getValue('blockTags'),
18+
TAG_NAME
19+
]);
20+
}
21+
});
1322
app.converter.on(
1423
Converter.EVENT_CREATE_DECLARATION,
1524
(context: Context, reflection: DeclarationReflection) => {

src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Context, Reflection } from 'typedoc';
22
import ts from 'typescript';
33
import { getValueDeclaration, parseTag } from './helpers.js';
4+
import { TAG_NAME } from './constants.js';
45

56
export default (
67
context: Context,
78
reflection: Reflection,
89
sig?: ts.SignatureDeclaration,
910
) => {
10-
const TAG_NAME = '@source';
1111

1212
// ignore projects
1313
if (reflection.isProject()) return;

0 commit comments

Comments
 (0)