|
1 |
| -# JSDoc |
| 1 | +# jsdoc-import-typedef |
2 | 2 |
|
3 |
| -[](http://travis-ci.org/jsdoc/jsdoc) |
| 3 | +This is a fork of [jsdoc](https://github.com/jsdoc/jsdoc) to deal with typescript type check import way - https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#import-types |
4 | 4 |
|
5 |
| -An API documentation generator for JavaScript. |
| 5 | +## Motivation |
6 | 6 |
|
7 |
| -Want to contribute to JSDoc? Please read `CONTRIBUTING.md`. |
| 7 | +There are some issues in jsdoc related to this problem and a feature is open here: https://github.com/jsdoc/jsdoc/issues/1645. But the feature will be very complex and maybe can take some time to be done. And I need this fix asap. |
8 | 8 |
|
9 |
| -Installation and Usage |
10 |
| ----------------------- |
| 9 | +## Cause |
11 | 10 |
|
12 |
| -JSDoc supports stable versions of Node.js 8.15.0 and later. You can install |
13 |
| -JSDoc globally or in your project's `node_modules` folder. |
| 11 | +jsdoc uses [catharsis](https://github.com/hegemonic/catharsis) to parse the expressions and `catharsis.parse` doesn't accept the typescript `import` expression (ex: `@param p { import("./a").Pet }`). |
14 | 12 |
|
15 |
| -To install the latest version on npm globally (might require `sudo`; |
16 |
| -[learn how to fix this](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)): |
| 13 | +This raises `Invalid type expression` like seem here https://github.com/hegemonic/catharsis/blob/master/bin/parse.js#L48 |
17 | 14 |
|
18 |
| - npm install -g jsdoc |
| 15 | +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`. |
19 | 16 |
|
20 |
| -To install the latest version on npm locally and save it in your package's |
21 |
| -`package.json` file: |
| 17 | +In this case, `@param p { import("./a").Pet }` will be interpreted like `@param p { Pet }` in jsdoc. |
22 | 18 |
|
23 |
| - npm install --save-dev jsdoc |
| 19 | +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. |
24 | 20 |
|
25 |
| -**Note**: By default, npm adds your package using the caret operator in front of |
26 |
| -the version number (for example, `^3.6.3`). We recommend using the tilde |
27 |
| -operator instead (for example, `~3.6.3`), which limits updates to the most |
28 |
| -recent patch-level version. See |
29 |
| -[this Stack Overflow answer](https://stackoverflow.com/questions/22343224) for |
30 |
| -more information about the caret and tilde operators. |
| 21 | +## Installation |
| 22 | +``` |
| 23 | +npm install jsdoc-import-typedef |
| 24 | +``` |
31 | 25 |
|
32 |
| -To install the latest development version locally, without updating your |
33 |
| -project's `package.json` file: |
| 26 | +## Usage |
34 | 27 |
|
35 |
| - npm install git+https://github.com/jsdoc/jsdoc.git |
| 28 | +This is a patched `jsdoc` and all its usage remains the same (https://github.com/jsdoc/jsdoc#installation-and-usage). |
36 | 29 |
|
37 |
| -If you installed JSDoc locally, the JSDoc command-line tool is available in |
38 |
| -`./node_modules/.bin`. To generate documentation for the file |
39 |
| -`yourJavaScriptFile.js`: |
40 |
| - |
41 |
| - ./node_modules/.bin/jsdoc yourJavaScriptFile.js |
42 |
| - |
43 |
| -If you installed JSDoc globally, run the `jsdoc` command: |
44 |
| - |
45 |
| - jsdoc yourJavaScriptFile.js |
46 |
| - |
47 |
| -By default, the generated documentation is saved in a directory named `out`. You |
48 |
| -can use the `--destination` (`-d`) option to specify another directory. |
49 |
| - |
50 |
| -Run `jsdoc --help` for a complete list of command-line options. |
51 |
| - |
52 |
| -## Templates and tools |
53 |
| - |
54 |
| -The JSDoc community has created templates and other tools to help you generate |
55 |
| -and customize your documentation. Here are a few of them: |
56 |
| - |
57 |
| -### Templates |
58 |
| - |
59 |
| -+ [jaguarjs-jsdoc](https://github.com/davidshimjs/jaguarjs-jsdoc) |
60 |
| -+ [DocStrap](https://github.com/docstrap/docstrap) |
61 |
| -([example](https://docstrap.github.io/docstrap)) |
62 |
| -+ [jsdoc3Template](https://github.com/DBCDK/jsdoc3Template) |
63 |
| - ([example](https://github.com/danyg/jsdoc3Template/wiki#wiki-screenshots)) |
64 |
| -+ [minami](https://github.com/Nijikokun/minami) |
65 |
| -+ [docdash](https://github.com/clenemt/docdash) |
66 |
| -([example](http://clenemt.github.io/docdash/)) |
67 |
| -+ [tui-jsdoc-template](https://github.com/nhnent/tui.jsdoc-template) |
68 |
| -([example](https://nhnent.github.io/tui.jsdoc-template/latest/)) |
69 |
| -+ [better-docs](https://github.com/SoftwareBrothers/better-docs) |
70 |
| -([example](https://softwarebrothers.github.io/admin-bro-dev/index.html)) |
71 |
| - |
72 |
| -### Build tools |
73 |
| - |
74 |
| -+ [JSDoc Grunt plugin](https://github.com/krampstudio/grunt-jsdoc) |
75 |
| -+ [JSDoc Gulp plugin](https://github.com/mlucool/gulp-jsdoc3) |
76 |
| - |
77 |
| -### Other tools |
78 |
| - |
79 |
| -+ [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown) |
80 |
| -+ [Integrating GitBook with |
81 |
| -JSDoc](https://medium.com/@kevinast/integrate-gitbook-jsdoc-974be8df6fb3) |
82 | 30 |
|
83 | 31 | ## For more information
|
84 | 32 |
|
|
0 commit comments