Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Documenting external types with TypeDoc

I have two files, file A and file B. File A uses a class from file B. My goal is to reference the TypeDoc output for a class used in file B in the TypeDoc output for file A. I can't seem to do this.

I know you can reference a symbol contained in the same file with TypeDoc with double brackets, like [[Foo]], but this didn't work for an external type like this.

/** Trying to reference [[FileB.InnerClass]] like this doesn't work. */
// This here is what I want to include
export type InnerClass = FileB.InnerClass;

// More code...

Is this possible to achieve?

like image 323
Erik Macik Avatar asked Jul 25 '19 23:07

Erik Macik


People also ask

What does TypeDoc do?

TypeDoc converts comments in TypeScript source code into rendered HTML documentation or a JSON model. It is extensible and supports a variety of configurations. Available as a CLI or Node module.

What is TSDoc?

What is TSDoc? TSDoc is a proposal to standardize the doc comments used in TypeScript code, so that different tools can extract content without getting confused by each other's markup. The TSDoc notation looks pretty familiar: export class Statistics { /** * Returns the average of two numbers.

How do I install TypeDoc?

By saving TypeDoc to the project package. json file with the previous command, anyone who runs npm install on the project will have typedoc installed at the specific version required for the project.


1 Answers

yes, it's possible.

  1. correct the comment.
  2. You don't have to enter the file name but you have to import object from file using import
import { InnerClass } from './FileB';

/**
 * See the [[InnerClass]] for more details.
 */
export type innerClass = InnerClass;
  1. To generate docs, run the following command.

when typedef it's global use this command:

typedoc --out ./docs --target ES6 ./src/

or this when it's local:

npx typedoc --out ./docs --target ES6 ./src/

  • ./docs is folder where generate documentation.

  • ./src/ is folder where your code is.

  • --target ES6 version of JavaScript.

If you want to show only classes without different modules, use this flag --mode file:

npx typedoc --out ./docs --mode file --target ES6 ./src/

for more info, see documentation.

like image 62
Aymen Avatar answered Sep 17 '22 07:09

Aymen