npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@reside-ic/typedoc-plugin-copy-doc

v1.1.2

Published

Plugin for Typedoc that copies relevant documentation

Readme

TypeDoc Copy Doc Plugin

This plugin will allow you to reuse documentation between class and function declarations. It will automatically match parameters and type parameters and copy and paste their descriptions over. Also it will fill in a summary from the first @copyDoc tag source it finds if none is specified on the target reflection of the tag.

This plugin was born out of this discussion where I wanted to do partial inheritance of documentation between classes that have the same @typeParam.

Credit to Gerrit0 who suggested the name and the typedoc contributors who developed the InheritDocPlugin that this plugin is heavily based on.

Installation

npm i --save-dev @reside-ic/typedoc-plugin-copy-doc

and add to TypeDoc config

"plugin": ["typedoc-plugin-copy-doc"]

Examples

Note, in all these examples, the parameter or type parameter name must match exactly between the source of the documentation and the target, otherwise this will not work.

Simple example with classes

Before (duplicate documentation):

/**
 * This is the Foo class
 *
 * @typeParam A foo variable type
 */
export class Foo<A> {
  constructor(public foo: A) {}
}

/*
 * This is the Bar class
 *
 * @typeParam A foo variable type
 */
export class Bar<A> extends Foo<A> {}

After:

/**
 * This is the Foo class
 *
 * @typeParam A foo variable type
 */
export class Foo<A> {
  constructor(public foo: A) {}
}

/*
 * This is the Bar class
 *
 * @copyDoc Foo
 */
export class Bar<A> extends Foo<A> {}

Compilcated example with classes

Before:

/**
 * Summary 1
 *
 * @typeParam A foo type generic 1
 * @typeParam B foo type generic 2
 */
export class Foo<A, B> {
  constructor(public foo: A & B) {}
}

/*
 * Summary 2
 *
 * @typeParam C bar type generic 1
 * @typeParam D bar type generic 2
 */
export class Bar<C, D> {
  constructor(public bar: C & D) {}
}

/*
 * Summary 1
 *
 * @typeParam A foo type generic 1
 * @typeParam C bar type generic 1
 * @typeParam E baz type generic 1
 */
export class Baz<A, C, E> {
  constructor(public baz: A & C & E) {}
}

After:

/**
 * Summary 1
 *
 * @typeParam A foo type generic 1
 * @typeParam B foo type generic 2
 */
export class Foo<A, B> {
  constructor(public foo: A & B) {}
}

/*
 * Summary 2
 *
 * @typeParam C bar type generic 1
 * @typeParam D bar type generic 2
 */
export class Bar<C, D> {
  constructor(public bar: C & D) {}
}

/*
 * @copyDoc Foo
 * @copyDoc Bar
 * @typeParam E baz type generic 1
 */
export class Baz<A, C, E> {
  constructor(public baz: A & C & E) {}
}

Here we have:

  • picked a subset of type parameters from Foo and Bar to get documentation for
  • copied and pasted the first class's summary (Foo) into the summary for Baz
  • extended the type parameters for Baz by including E

Compilcated example with functions

You can do the same for parameters in functions, the function bodies are not important here:

/**
 * Summary 1
 *
 * @typeParam T fun1 generic 1
 * @typeParam U fun1 generic 2
 * @param x fun1 number
 * @param y fun1 string
 */
export const fun1 = <T, U>(x: number, y: string) => {
  return x * y.length;
};

/**
 * Summary 2
 *
 * @typeParam V fun2 generic 1
 * @typeParam W fun2 generic 2
 * @param z fun2 number
 * @param a fun2 string
 * @param b fun2 boolean
 */
export const fun2 = <V, W>(z: number, a: string, b: boolean) => {
  return b ? z * a.length : 0;
};

/**
 * Merges fun1 and fun2
 *
 * @typeParam T fun1 generic 1
 * @typeParam W fun2 generic 2
 * @param x fun1 number
 * @param y fun1 string
 * @param z fun2 number
 * @param a fun2 string
 * @param t funmerge number
 */
export const funmerge = <T, W>(
  x: number,
  y: string,
  z: number,
  a: string
  t: number
) => {
  const res1 = fun1<T, null>(x, y);
  const res2 = fun2<null, W>(z, a, true);
  return res1 * res2 * t;
}; 

After:

/**
 * Summary 1
 *
 * @typeParam T fun1 generic 1
 * @typeParam U fun1 generic 2
 * @param x fun1 number
 * @param y fun1 string
 */
export const fun1 = <T, U>(x: number, y: string) => {
  return x * y.length;
};

/**
 * Summary 2
 *
 * @typeParam V fun2 generic 1
 * @typeParam W fun2 generic 2
 * @param z fun2 number
 * @param a fun2 string
 * @param b fun2 boolean
 */
export const fun2 = <V, W>(z: number, a: string, b: boolean) => {
  return b ? z * a.length : 0;
};

/**
 * Merges fun1 and fun2
 *
 * @copyDoc fun1
 * @copyDoc fun2
 * @param t funmerge number
 */
export const funmerge = <T, W>(
  x: number,
  y: string,
  z: number,
  a: string
  t: number
) => {
  const res1 = fun1<T, null>(x, y);
  const res2 = fun2<null, W>(z, a, true);
  return res1 * res2 * t;
}; 

Member functions of class example

You can also copy documentation for member functions of classes from classes or member functions themselves.

Before:

/**
 * Summary 1
 *
 * @typeParam A foo type generic 1
 * @typeParam B foo type generic 2
 */
export class Foo<A, B> {
  constructor() {};

  /**
   * fooFunction summary
   *
   * @param x first arg of fooFunction
   * @param y second arg of fooFunction
   */
  fooFunction(x: A, y: B): A & B {
    return {...x, ...y};
  };
}

/**
 * Summary 2
 *
 * @typeParam C bar type generic 1
 * @typeParam D bar type generic 2
 */
export class Bar<C, D> {
  constructor(public bar: C & D) {}

  /**
   * barFunction summary
   *
   * @typeParam A foo type generic 1
   * @typeParam B foo type generic 2
   * @param x first arg of fooFunction
   * @param y second arg of fooFunction
   */
  barFunction<A, B>(x: A, y: B): A & B {
    const foo = new Foo<A, B>();
    return foo.fooFunction(x, y);
  };
}

After:

/**
 * Summary 1
 *
 * @typeParam A foo type generic 1
 * @typeParam B foo type generic 2
 */
export class Foo<A, B> {
  constructor() {};

  /**
   * fooFunction summary
   *
   * @param x first arg of fooFunction
   * @param y second arg of fooFunction
   */
  fooFunction(x: A, y: B): A & B {
    return {...x, ...y};
  };
}

/**
 * Summary 2
 *
 * @typeParam C bar type generic 1
 * @typeParam D bar type generic 2
 */
export class Bar<C, D> {
  constructor(public bar: C & D) {}

  /**
   * barFunction summary
   *
   * @copyDoc Foo
   * @copyDoc Foo.fooFunction
   */
  barFunction<A, B>(x: A, y: B): A & B {
    const foo = new Foo<A, B>();
    return foo.fooFunction(x, y);
  };
}

Here the documentation for the type parameters comes from Foo and documentation for the function parameters comes from Foo.fooFunction. Please note only the . delimiter works right now.