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

Convert type comments to JSDoc format #32

Open
tojump opened this issue Aug 7, 2022 · 2 comments
Open

Convert type comments to JSDoc format #32

tojump opened this issue Aug 7, 2022 · 2 comments

Comments

@tojump
Copy link

tojump commented Aug 7, 2022

Many code editors support JSDoc comments, displaying their content while showing suggestions.

For example in src/api/chia/consensus/block_record.ts, if we replace:

export type BlockRecord = {
  header_hash: bytes32; // bytes32
  prev_hash: bytes32; // bytes32  # Header hash of the previous block
  ...

with

export type BlockRecord = {
  header_hash: bytes32; // bytes32
  /**
   * Header hash of the previous block
   */
  prev_hash: bytes32; // bytes32
  ...

or

export type BlockRecord = {
  header_hash: bytes32; // bytes32
  /** Header hash of the previous block */
  prev_hash: bytes32; // bytes32
  ...

Then the emitted declaration file will retain the JSDoc comment and we will get in-editor suggestions.

suggestion

Since I don't know whether you extract the types from the chia code base manually or with a script, I am posting this as an issue first, but I will gladly contribute a PR in either case.

@ChiaMineJP
Copy link
Member

I manually check the chia code one by one.
JSDoc comments are good if what they say are correct and easy to understand.
What do you think should be a good source of those JSDocs?

@tojump
Copy link
Author

tojump commented Aug 8, 2022

To begin with, I was thinking to use the existing single-line comments appended after the data type property names in the chia-blockchain source code, which you helpfully copied over along with names of the original python types (which would also be helpful).

Then if we want to add docs to the API endpoint functions and their parameters, we can parse the descriptions in chia-docs:
https://github.com/Chia-Network/chia-docs/blob/main/docs/12rpcs/full_node_api.md
https://github.com/Chia-Network/chia-docs/blob/main/docs/12rpcs/did_rpcs.mdx
https://github.com/Chia-Network/chia-docs/blob/main/docs/12rpcs/nft_rpcs.mdx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants