Skip to content

ricardohbin/jsdoc

 
 

Repository files navigation

jsdoc-import-typedef

This is a fork of jsdoc to deal with typescript type check import way - https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#import-types

Motivation

There are some issues in jsdoc related to this problem and a feature is open here: jsdoc#1645. But the feature will be very complex and maybe can take some time to be done. And I need this fix asap.

Cause

jsdoc uses catharsis to parse the expressions and catharsis.parse doesn't accept the typescript import expression (ex: @param p { import("./a").Pet }).

This raises Invalid type expression like seem here https://github.com/hegemonic/catharsis/blob/master/bin/parse.js#L48

Instead of patch catharsis, I apply the fix in jsdoc, using a regexp to remove this pattern before the string is parsed by catharsis.parse.

In this case, @param p { import("./a").Pet } will be interpreted like @param p { Pet } in jsdoc.

Works great if you are using Typescript to type check your jsdoc - (https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) and is compatible with all jsdoc templates.

Installation

npm install jsdoc-import-typedef

Usage

This is a patched jsdoc and all its usage remains the same (https://github.com/jsdoc/jsdoc#installation-and-usage).

For more information

License

JSDoc is copyright (c) 2011-present Michael Mathews [email protected] and the contributors to JSDoc.

JSDoc is free software, licensed under the Apache License, Version 2.0. See the LICENSE file for more details.

About

An API documentation generator for JavaScript.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.2%
  • Other 0.8%