Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect JSDoc for a variety of methods #345

Closed
ipotuzhnov opened this issue Sep 27, 2018 · 2 comments
Closed

Incorrect JSDoc for a variety of methods #345

ipotuzhnov opened this issue Sep 27, 2018 · 2 comments
Assignees
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. type: docs Improvement to the documentation for an API.

Comments

@ipotuzhnov
Copy link

I found some discrepancies between implementation and documentation when I've tried to generate a .d.ts file based on JSDoc with @otris/jsdoc-tsd npm module.

Here are some of the issues:

  • Table#read method is not documented (or implemented?) correctly. When the example is consistent with the current behavior there is some discrepancy with the documentation. The documentation says that the returned promise resolves to an array containing an instance of a Table and an array of rows (objects) TableReadResponse, but in fact that array only contains rows.
  • BatchTransaction#execute method's callback argument should be optional
  • Instance#setMetadata object should start with capital O for metadata argument
  • Database#run method takes string or object as the first argument, so probably there should be a separate @typedef for that object, but I'm not sure.
  • For some methods that return promises the type of the resolved value is not specified
  • Some types are misspelled. Should be Error instead of error and Date instead of date, unless I've missed typedefs for those types.

Environment details

  • OS: N/A
  • Node.js version: N/A
  • npm version: N/A
  • @google-cloud/spanner version: 2.0.0

Steps to reproduce

git checkout v2.0.0
npm install
npm install --no-save @otris/jsdoc-tsd typescript
# Convert the `.jsdoc.js` file into JSON
node -e "console.log(JSON.stringify(require('./.jsdoc'),null,2))" > .jsdoc-dts.json
# Generate a `.d.ts` file 
$(npm bin)/jsdoc -c .jsdoc-dts.json -t ./node_modules/@otris/jsdoc-tsd -d spanner.d.ts
$(npm bin)/tsc --noEmit spanner.d.ts

Following these steps will guarantee the quickest resolution possible.

Map the errors returned by TypeScript compiler to the actual code and fix the documentation.

There is a way to configure TypeScript compiler to check JavaScript files (it will also pick up JSDoc comments as type annotations), but that could result in too much noise if you only want to check that the documentation is valid.
I'm pretty sure there are some other means to validate JSDoc as well.

Thanks!

PS.: I'd be glad to submit a PR(s) to fix some of this issues.

@JustinBeckwith JustinBeckwith added the triage me I really want to be triaged. label Sep 27, 2018
@callmehiphop callmehiphop added priority: p2 Moderately-important priority. Fix may not be included in next release. type: docs Improvement to the documentation for an API. and removed triage me I really want to be triaged. labels Oct 1, 2018
@ghost ghost assigned callmehiphop Oct 2, 2018
@callmehiphop
Copy link
Contributor

@ipotuzhnov thanks for reporting! I went ahead and made a PR (#352) with a number of JSDoc fixes. I ended up going with eslint's valid-jsdoc rule, so I'm not 100% sure that this will entirely fix the issues you're seeing, but if you get a chance to test it out that would be super appreciated!

@ghost ghost removed the priority: p2 Moderately-important priority. Fix may not be included in next release. label Oct 2, 2018
@ipotuzhnov
Copy link
Author

ipotuzhnov commented Oct 2, 2018

@callmehiphop Thank you for looking into it! I think using valid-jsdoc eslint rule is a great idea. Probably it doesn't check if all the types exist and are valid, but that's a good start.

Unfortunately, @otris/jsdoc-tsd fails to parse jsdoc on master, so I'll need to figure out what's causing it to crash before I can test it.

@google-cloud-label-sync google-cloud-label-sync bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. type: docs Improvement to the documentation for an API.
Projects
None yet
Development

No branches or pull requests

3 participants