1.0.9 • Published 2 years ago
@wanderqing/dts2md v1.0.9
dts2md
Convert your .d.ts
files to markdown files.
List all function and function's comment from your .d.ts
.
install
npm install @wanderqing/dts2md
or
yarn add @wanderqing/dts2md
Usage
- support JSDoc comment
- support function declaration and arrow function
Get Function name rule
- If function has jsDoc
- Then get function's jsdoc first line text
- Else get function's name
Example
Code1
// index.ts
import { generate } from '@wanderqing/dts2md';
generate({
src: './src',
out: './docs'
})
# If you installed ts-node
ts-node index.ts
Create a typescript definition file src/example.d.ts
.
How to generate definition file
- Pass
-d
option totsc
command. - set
declaration: true
in yourtsconfig.json
.
.example.d.ts
/**
* Get sum of two numbers
* @param a a number
* @param b anthoer number
*/
declare function add(a: number, b: number): number;
Run Code1
you will get Some markdown files in your out
dir
docs/example.md
## Get sum of two Numbers
```typescript
/**
* Get sum of two numbers
* @param a a number
* @param b anthoer number
*/
declare function add(a: number, b: number): number;
```