パッケージの詳細

typedoc-plugin-external-module-name

christopherthielen61.8kMIT4.0.6

Specify the Typedoc Module of a file using @module annotation

typedocplugin, typedoc

readme

typedoc-plugin-external-module-name

What

A Typedoc plugin which allows code documentation to be organized into custom Modules.

Note: In Typedoc 0.17.0 and above, Module refers to an ES6 Module. In Typedoc 0.16.x and below, an ES6 Module was called an External Module. Although the plugin's name includes "External Module", it modifies Modules (ES6 Modules)

By default, Typedoc creates a Module for each ES6 Module (each file).

This plugin allows documentation to be moved to arbitrary modules. It also supports merging multiple modules into a single module. By default, all Modules in a given directory will be merged into a single module.

Suppose your source files are organized like this:

thing1/foo.ts
thing1/bar.ts
thing2/baz.ts
thing2/qux.ts

By default, Typedoc would create four Modules:

  • thing1/foo: contains foo documentation
  • thing1/bar: contains bar documentation
  • thing2/baz: contains baz documentation
  • thing2/qux: contains qux documentation

With this plugin, Typedoc creates two Modules:

  • thing1: contains foo and bar documentation
  • thing2: contains baz and qux documentation

Installing

Typedoc has the ability to discover and load typedoc plugins found in node_modules. Simply install the package usng your package manager and run typedoc.

npm install -D typedoc-plugin-external-module-name
typedoc

Using

Directory Based

This plugin will combine documentation from the files in each given directory into a new Module. The new module name is generated from the directory's location in the source tree.

Explicit via Annotation

You can explicitly specify a Module name using the @module annotation. Add a comment block at the top of a Typescript file with @module modulename. Mark the comment block as @packageDocumentation to let typedoc know that this is documentation for the file (Module) itself (see: Typedoc Docs).

/**
 * @packageDocumentation
 * @module module1
 */

Top level module comments

When multiple modules are merged, the merged module summary is chosen arbitrarily from the first file processed. To use a specific file's comment block as the Module page summary, use @preferred.

/**
 * This comment will be used as the summary for the "thing2" module.

 * @packageDocumentation
 * @module thing2
 * @preferred
 */

Custom Module Name Generation

Create a file named .typedoc-plugin-external-module-name.js in the folder you launch typedoc from. Create a custom mapping function in that file and export it using CommonJS. For each Module, the plugin will call your function and use the return value as the Module Name.

module.exports = function customMappingFunction() {
  return "custom" // everything goes into "custom"
}

The Function should have the following signature:

type CustomModuleNameMappingFn = (
  explicitModuleAnnotation: string,
  implicitFromDirectory: string,
  path: string,
  reflection: Reflection,
  context: Context,
) => string;

The arguments are:

  • moduleAnnotation: If the module has an explicit annotation, i.e., @module explicit
  • implicitFromDirectory: The plugin's default mapping
  • path: The path to the file
  • reflection: The Module ContainerReflection
  • context: The typedoc Context

Example:

const subpackage = new RegExp("packages/([^/]+)/");
module.exports = function customMappingFunction(explicit, implicit, path, reflection, context) {
  // extract the monorepo package from the path
  const package = subpackage.match(path)[1];
  // build the module name
  return `${package}/${implicit}`;
}

更新履歴

4.0.6 (2021-01-04)

Compare typedoc-plugin-external-module-name versions 4.0.5 and 4.0.6

Bug Fixes

  • preferred: Fix preferred flag on modules (83a3281), closes #554

4.0.5 (2020-12-20)

Compare typedoc-plugin-external-module-name versions 4.0.4 and 4.0.5

Bug Fixes

  • Do not crash when typedoc "disableSources" option is true (this turns off automatic module name feature) (8cfb30c), closes #507

4.0.4 (2020-12-17)

Compare typedoc-plugin-external-module-name versions 4.0.3 and 4.0.4

Bug Fixes

  • If automatic name guesses '.', rename to 'root' instead. (52bb52c)
  • rootFileNames can be an empty array. Use current dir as the base path instead of blowing up. (f3c75dd), closes #548

Features

  • allow .cjs and .mjs extensions for custom mapping function file to accomodate "type": "module" in package.json (f47f8ec)
  • support typedoc 0.19 (f787640)

4.0.3 (2020-06-06)

Compare typedoc-plugin-external-module-name versions 4.0.2 and 4.0.3

Bug Fixes

  • windows: when calculating the common prefix, always use path.resolve() to map to native path separator, i.e. "\" (09b2090)

4.0.2 (2020-06-06)

Compare typedoc-plugin-external-module-name versions 4.0.1 and 4.0.2

Bug Fixes

  • Use the common parent directory of all entrypoints as the relative path to guess module names (f790eee)

4.0.1 (2020-06-05)

Compare typedoc-plugin-external-module-name versions 4.0.0 and 4.0.1

Features

  • Add a --disableAutoModuleName flag (a8561e0)

4.0.0 (2020-05-31)

Compare typedoc-plugin-external-module-name versions 3.1.0 and 4.0.0

Bug Fixes

  • fix createChildReflection ReflectionKind for typedoc < 0.17 (now creates a 0.17 Module, not a Namespace) (fc6b2b4)

Features

  • Bump package to 4.0.0 (aec9638)
  • merge modules from the same directory into a single module by default (fd03f0b)
  • Support a .typedoc-plugin-external-module-name.js file for custom generation of module names based on the reflection itself (ca0a9c7), closes #423

BREAKING CHANGES

  • This plugin now automatically applies a Module Name based on the file path.

3.1.0 (2020-04-27)

Compare typedoc-plugin-external-module-name versions 3.0.0 and 3.1.0

Bug Fixes

  • < 0.17.0 fix isModuleOrNamespace compat (1ef1ad3)
  • Re-add compatibility for typedoc < 0.17.0 (c255f1e)

Features

  • build with typedoc 0.17 and expand peerDependency semver range to include 0.17.x (00f0f96)

3.0.0 (2020-01-16)

Compare typedoc-plugin-external-module-name versions 2.2.1 and 3.0.0

Bug Fixes

  • emptycomment: Remove empty comments on source reflections that are being merged, just in case.. not sure if this is even necessary! (bd9b5cd)
  • typedoc0.16: Some fixes for 0.16.x (WIP) (0089d19)

Features

  • typedoc0.16.4: Support typedoc 0.16.4 (02aa15a)

2.2.1 (2020-01-15)

Compare typedoc-plugin-external-module-name versions 2.1.0 and 2.2.1

Bug Fixes

  • module: Remove empty comment blocks of merge target modules (c800a22), closes #142
  • reflections: Update symbol mappings for merged modules (248b806), closes #313 #193
  • typedoc-0.14: Improve typedoc 0.14.0 compatibility to account for api change (68fc6e1)

2.2.0 (2020-01-15)

Compare typedoc-plugin-external-module-name versions 2.1.0 and 2.2.0

Bug Fixes

  • module: Remove empty comment blocks of merge target modules (c800a22), closes #142
  • reflections: Update symbol mappings for merged modules (248b806), closes #313 #193
  • typedoc-0.14: Improve typedoc 0.14.0 compatibility to account for api change (68fc6e1)

2.1.0 (2019-05-06)

Compare typedoc-plugin-external-module-name versions 2.0.0 and 2.1.0

Features

  • Support submodules (modules are separated by '.') (793d0ae)

2.0.0 (2019-01-09)

Compare typedoc-plugin-external-module-name versions 1.1.3 and 2.0.0

Bug Fixes

1.1.3 (2018-07-21)

Compare typedoc-plugin-external-module-name versions 1.1.1 and 1.1.3

Features

  • module: Allow . (dot) in module names. (26af2af)

1.1.2 (2018-04-13)

Compare typedoc-plugin-external-module-name versions 1.1.1 and 1.1.2

Features

  • module: Allow . (dot) in module names. (26af2af)

1.1.1 (2018-02-07)

Compare typedoc-plugin-external-module-name versions 1.1.0 and 1.1.1

Bug Fixes

  • doublecomment: Null check 'result' (2b51576)

1.1.0 (2018-02-07)

Compare typedoc-plugin-external-module-name versions 1.0.10 and 1.1.0

Bug Fixes

  • doublecomment: Monkey patch getJSDocCommentRanges instead of duplicating all of getRawComment (c39c924)

1.0.10 (2017-10-27)

Compare typedoc-plugin-external-module-name versions 1.0.9 and 1.0.10

Bug Fixes

  • doublecomment: Do not use 'getRawComment': better fix for not requiring a second comment block. (a469ed4), closes #6
  • peerDependencies: Fix node v4 (edaa68f)

1.0.9 (2017-03-21)

Compare typedoc-plugin-external-module-name versions 1.0.8 and 1.0.9

1.0.8 (2017-01-17)

Compare typedoc-plugin-external-module-name versions 1.0.7 and 1.0.8

Bug Fixes

  • regexp: Fix the module match regexp. (db4232d)

1.0.7 (2017-01-01)

Compare typedoc-plugin-external-module-name versions 1.0.6 and 1.0.7

1.0.6 (2017-01-01)

Compare typedoc-plugin-external-module-name versions 1.0.5 and 1.0.6

1.0.5 (2016-12-11)

Compare typedoc-plugin-external-module-name versions 1.0.4 and 1.0.5

Features

  • Remove tags from docs after processing (ec6892c)

1.0.4 (2016-10-16)

Compare typedoc-plugin-external-module-name versions 1.0.3 and 1.0.4

1.0.3 (2016-10-16)

Compare typedoc-plugin-external-module-name versions 1.0.2 and 1.0.3

1.0.2 (2016-07-13)