Skip to content

Export the default blockTags to allow extending them #2640

@crycode-de

Description

@crycode-de

Search Terms

Allow extending of the blockTags (and maybe inlineTags and others too) array.

Problem

Using blockTags config option it's already possible to overwrite the default blockTags definition. But extending them is currently not possible.

Of cause you could just copy&paste the default blockTags but it doesn't feel right and needs to be checked/updated on each TypeDoc update.

I'm using TypeDoc as node module by calling

import TypeDoc from 'typedoc';
const typeDocApp = await TypeDoc.Application.bootstrapWithPlugins({
  // ...
  blockTags: [
    // ...
  ],
});
//...

The I saw that the default blockTags are defined in:

export const blockTags = [
...tsdocBlockTags,
"@author",
"@callback",
"@category",
"@categoryDescription",
"@default",
"@document",
"@group",
"@groupDescription",
"@import",
"@inheritDoc",
"@jsx",
"@license",
"@module",
"@prop",
"@property",
"@return",
"@satisfies",
"@since",
"@template", // Alias for @typeParam
"@type",
"@typedef",
] as const;

Trying to import them directly from the dist path fails with ERR_PACKAGE_PATH_NOT_EXPORTED:

import { blockTags } from 'typedoc/dist/lib/utils/options/tsdoc-defaults.js';
// Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/lib/utils/options/tsdoc-defaults.js' is not defined by "exports" in /home/[...]/node_modules/typedoc/package.json imported from /home/[...]/scripts/docs.ts

Suggested Solution

Export the default blockTags (and maybe also the other default tags) to allow to import and extend them.

Example of possible use:

import TypeDoc from 'typedoc';
const typeDocApp = await TypeDoc.Application.bootstrapWithPlugins({
  // ...
  blockTags: [
    ...TypeDoc.defaults.blockTags,
    '@myCustomTag',
  ],
});
//...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions