JSDocs can't parse some njs-types

Open
#664 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale

Research direction

Start by running npm run docs with the reported jsdoc.json configuration and inspect node_modules/njs-types/ngx_core.d.ts around line 60 and njs_core.d.ts around line 154. Determine why these declarations produce the reported parsing errors, then verify that documentation generation completes without those errors.

Written by the indexing model from the issue text.

Description

njs

We were experimenting with adding JSDocs for nginx-s3-gateway project in this PR https://github.com/nginxinc/nginx-s3-gateway/issues/165. After adding a such configuration:

package.json:

{
  "scripts": {
    "prettier": "prettier --check --write common/etc/nginx/include",
    "eslint": "npx eslint .",
    "docs": "jsdoc -c 'jsdoc.json'"
  },
  "devDependencies": {
    "better-docs": "^2.7.2",
    "jsdoc": "^4.0.2",
    "njs-types": "^0.8",
    "taffydb": "^2.7.3",
    "eslint": "^7.32.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-prettier": "^4.2.1",
    "prettier": "^2.8.8"
  }
}

jsdocs.json looks like:

{
    "plugins": [
        "node_modules/better-docs/typescript"
    ],
    "source": {
        "include": ["./common/etc/nginx/include", "./node_modules/njs-types"],
        "includePattern": "\\.(jsx|js|ts|tsx)$",
        "excludePattern": "(^|\\/|\\\\)_"
    },
    "opts": {
        "template": "./node_modules/better-docs",
        "readme": "README.md",
        "verbose": true
    }
}
npm run docs

> docs
> jsdoc -c 'jsdoc.json'

Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/common/etc/nginx/include/awscredentials.js ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/common/etc/nginx/include/awssig2.js ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/common/etc/nginx/include/awssig4.js ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/common/etc/nginx/include/s3gateway.js ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/common/etc/nginx/include/utils.js ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/index.d.ts ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/ngx_core.d.ts ...
ERROR: Unable to parse a tag's type expression for source file /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/ngx_core.d.ts in line 60 with tag title "type" and text "{V extends number,      ? (key: string, delta: V, init?: number) => number,      : never}": Invalid type expression "V extends number,      ? (key: string, delta: V, init?: number) => number,      : never": Expected "|" but "e" found.
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/ngx_http_js_module.d.ts ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/ngx_stream_js_module.d.ts ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/njs_core.d.ts ...
ERROR: Unable to parse /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/njs_core.d.ts: Missing semicolon. (154:22)
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/njs_shell.d.ts ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/njs_webapi.d.ts ...
Parsing /Users/ivanitskiy/go/src/github.com/nginxinc/nginx-s3-gateway/node_modules/njs-types/njs_webcrypto.d.ts ...
Generating output files...
Finished running in 1.07 seconds.

Not sure where the issue is, but creating a topic here to track it.

Dominant language
C
Stars
1.6k
Forks
245
Avg merge
2d 5h
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nginx/njs

All issues in nginx/njs

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.