Include code examples in your typedoc documentations with powerful bracket syntax for line selection.
$ npm install --save-dev typedoc-plugin-include-example
Write your example in a *.example.ts
file.
// greet.example.ts
import { greet } from "./greet.js";
greet(); // Prints greetings
Add the @includeExample tag to the actual code.
// greet.ts
/**
* Says hello !
*
* @includeExample
*/
export function greet() {
console.log("Hello there.");
}
Then generate your documentation using typedoc using this plugin.
$ npx typedoc --plugin typedoc-plugin-include-example
Control which lines to include with bracket syntax:
/**
* @includeExample greet.example.ts // Include entire file
* @includeExample greet.example.ts[5] // Include line 5 only
* @includeExample greet.example.ts[2:8] // Include lines 2-8
* @includeExample greet.example.ts[2:5,10,15:20] // Multiple selections
*/
See the Documentation for full usage including advanced bracket syntax, exclusions, negative indexing, and troubleshooting.
- Typedoc's website.
- Package on Npm.
- Demonsration of what examples looks like.
- Documentation detailling specific features.
- Coverage testing report to visualise unit testing efficiency.