summaryrefslogtreecommitdiffhomepage
path: root/typedoc-plugin-external-module-name/index.js
blob: d59e36c5d4a8bc61836db3ee2989cde613c8b37f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//@ts-check

/* eslint-disable @typescript-eslint/no-var-requires */
const { ReflectionKind } = require('typedoc');
const { Converter } = require('typedoc/dist/lib/converter');

/** @param {import("typedoc/dist/lib/utils/plugins").PluginHost} host */
exports.load = function (host) {
  host.application.converter.on(Converter.EVENT_RESOLVE_BEGIN, context => {
    /** @type {import("typedoc").ProjectReflection} */
    const project = context.project;

    for (const mod of (project.children || []).filter(
      child => child.kind === ReflectionKind.Module,
    )) {
      const tag = mod.comment ? mod.comment.getTag('module') : void 0;
      if (!tag) continue;
      mod.name = tag.text;
      mod.comment.removeTags('module');
    }
  });
};