Skip to content

Generate document block(JsDoc, EsDoc, TsDoc) from source code

License

Notifications You must be signed in to change notification settings

heavenshell/ts-lehre

Repository files navigation

Lehre

build

Lehre is document block generator.

Generate JsDoc style document from source code.

Install

yarn add -D -E lehre

Usage

cat src/app.ts | lehre --stdin

Specify directory and ignore patterns.

lehre --target-dir=./src --ignore-patterns="spec.ts"

Formatters

You can choose document block formatter from JsDoc,ESDoc,TSDoc and your custom formatter.

JsDoc(default)

cat src/app.ts | lehre --stdin

EsDoc

cat src/app.ts | lehre --stdin --formatter=esdoc

TsDoc

cat src/app.ts | lehre --stdin --formatter=tsdoc

Coustom formatter

cat src/app/ts | lehre --template-path=./examples/template.js

Custom formatter

You can create your own cutom document block formatter.

Return string value and it insert above to signature automatically.

examples/template.js is sample formatter.

Formatter api

generateClassDoc

generateClassDoc: (
  name: string,
  type: string,
  start: { line: number, charactor: number },
  end: { line: number, charactor: number },
  methods: [
    name: string,
    type: string,
    start: { line: number, charactor: number },
    end: { line: number, charactor: number },
    params: ParamProps[
      name: string,
      type: string,
      default: string,
      alias: string,
    ],
    returnType: string,
  ],
  heritageClauses: [{ type: string, value: string }],
) => string

generateInterfaceDoc