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

📝 Feat: Add natspec comments to contract imports #1380

Merged

Conversation

roninjin10
Copy link
Collaborator

@roninjin10 roninjin10 commented Aug 14, 2024

Description

Closes #1344

Testing

Explain the quality checks that have been done on the code changes

Additional Information

Your ENS/address:

Summary by CodeRabbit

  • New Features

    • Enhanced documentation for smart contracts with Natspec comments, providing direct links to external resources.
    • Improved clarity and usability of generated documentation for contract types, with clear distinctions regarding bytecode presence.
  • Documentation

    • Added standardized references to external contract documentation in various functionalities to aid user understanding.
    • Updated documentation comments for multiple contracts, clarifying bytecode status and providing compilation instructions.

Copy link

changeset-bot bot commented Aug 14, 2024

🦋 Changeset detected

Latest commit: 38a30bd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
@tevm/runtime Patch
@tevm/base-bundler Patch
@tevm/bun-plugin Patch
@tevm/unplugin Patch
@tevm/ts-plugin Patch
tevm Patch
tevm-run Patch
@tevm/precompiles Patch
@tevm/esbuild-plugin Patch
@tevm/rollup-plugin Patch
@tevm/rspack-plugin Patch
@tevm/vite-plugin Patch
@tevm/webpack-plugin Patch
@tevm/test-utils Patch
@tevm/ethers Patch
@tevm/viem Patch
@tevm/actions Patch
@tevm/http-client Patch
@tevm/memory-client Patch
@tevm/node Patch
@tevm/procedures Patch
@tevm/server Patch
@tevm/state Patch
@tevm/decorators Patch
@tevm/evm Patch
@tevm/sync-storage-persister Patch
@tevm/txpool Patch
@tevm/vm Patch
@tevm/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 14, 2024

Warning

Rate limit exceeded

@roninjin10 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 29 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between f06ff2b and 38a30bd.

Walkthrough

This update enhances the documentation of various smart contract files by introducing Natspec comments and improving the construction of generated documentation. The changes provide clearer context for developers, ensuring better usability and understanding of contract functionalities without altering the core control flow.

Changes

Files Change Summary
.changeset/tidy-pans-melt.md Added Natspec comments for improved contract documentation and links to external resources.
bundler-packages/runtime/src/generateTevmBody.js Modified generateTevmBody to always prepend a comment block to Natspec, plus added a link to external documentation.
bundler-packages/runtime/src/generateTevmBodyDts.js Updated comments in generateDtsBody for clarity, removed type-specific comments, and included new documentation references.
bundler-packages/runtime/src/generateRuntime.spec.ts Enhanced documentation for MyContract with links and clarifications on bytecode absence.
bundler-packages/runtime/src/generateTevmBody.spec.ts Improved documentation for MyContract and AnotherContract, including links and bytecode instructions.
bundler-packages/runtime/src/generateTevmBodyDts.spec.ts Updated documentation for MyContract, AnotherContract, and MissingContract, focusing on bytecode absence.
lsp/ts-plugin/src/decorators/getScriptSnapshot.spec.ts Modified documentation for HelloWorld and HelloWorld2 to clarify bytecode absence and include documentation links.

Assessment against linked issues

Objective Addressed Explanation
Enhance documentation for tevm contracts (#1344)

🐇 In the meadow, the contracts bloom,
With comments clear, dispelling the gloom.
Natspec shines bright, guiding our way,
Understanding grows, come join the play!
In lines of code, our joy will reside,
As clarity blossoms, let knowledge abide. ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vercel bot commented Aug 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
tevm-monorepo-tevm ⬜️ Ignored (Inspect) Aug 15, 2024 4:06am

Copy link
Collaborator Author

roninjin10 commented Aug 14, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @roninjin10 and the rest of your teammates on Graphite Graphite

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eec8690 and fcee84a.

Files selected for processing (3)
  • .changeset/tidy-pans-melt.md (1 hunks)
  • bundler-packages/runtime/src/generateTevmBody.js (1 hunks)
  • bundler-packages/runtime/src/generateTevmBodyDts.js (2 hunks)
Files skipped from review due to trivial changes (1)
  • .changeset/tidy-pans-melt.md
Additional context used
Biome
bundler-packages/runtime/src/generateTevmBody.js

[error] 38-38: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

bundler-packages/runtime/src/generateTevmBodyDts.js

[error] 30-30: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)


[error] 48-48: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

Additional comments not posted (2)
bundler-packages/runtime/src/generateTevmBody.js (1)

39-40: Consistent comment block wrapping.

The change ensures that the natspec array is always wrapped in comment blocks, improving consistency and readability.

bundler-packages/runtime/src/generateTevmBodyDts.js (1)

28-28: Improved documentation clarity.

The updated comments provide clearer context about the contract's bytecode status and include a reference to external documentation, enhancing usability.

Also applies to: 46-47

@roninjin10 roninjin10 force-pushed the 08-14-_memo_feat_add_natspec_comments_to_contract_imports branch from fcee84a to 56e1553 Compare August 15, 2024 03:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fcee84a and 56e1553.

Files selected for processing (3)
  • .changeset/tidy-pans-melt.md (1 hunks)
  • bundler-packages/runtime/src/generateTevmBody.js (1 hunks)
  • bundler-packages/runtime/src/generateTevmBodyDts.js (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .changeset/tidy-pans-melt.md
Additional context used
Biome
bundler-packages/runtime/src/generateTevmBody.js

[error] 38-38: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

bundler-packages/runtime/src/generateTevmBodyDts.js

[error] 30-30: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)


[error] 48-48: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

Additional comments not posted (3)
bundler-packages/runtime/src/generateTevmBody.js (1)

39-40: LGTM! Improved documentation structure.

The changes to always include a comment block around the natspec content enhance the consistency and usability of the generated documentation.

bundler-packages/runtime/src/generateTevmBodyDts.js (2)

Line range hint 28-48:
LGTM! Enhanced documentation clarity.

The updated comments and inclusion of documentation references improve the clarity and usability of the generated TypeScript definitions.

Tools
Biome

[error] 30-30: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)


30-30: Replace template literal with string literal.

The use of a template literal is unnecessary here. Replace it with a regular string literal.

- ` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`
+ ' * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation'

Likely invalid or redundant comment.

Tools
Biome

[error] 30-30: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

natspec.unshift('/**')
natspec.push(' */')
}
natspec.push(` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace template literal with string literal.

The use of a template literal is unnecessary here. Replace it with a regular string literal.

- natspec.push(` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`)
+ natspec.push(' * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation')
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
natspec.push(` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`)
natspec.push(' * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation')
Tools
Biome

[error] 38-38: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

@roninjin10 roninjin10 force-pushed the 08-14-_memo_feat_add_natspec_comments_to_contract_imports branch from 56e1553 to f06ff2b Compare August 15, 2024 04:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 56e1553 and f06ff2b.

Files selected for processing (7)
  • .changeset/tidy-pans-melt.md (1 hunks)
  • bundler-packages/runtime/src/generateRuntime.spec.ts (4 hunks)
  • bundler-packages/runtime/src/generateTevmBody.js (1 hunks)
  • bundler-packages/runtime/src/generateTevmBody.spec.ts (7 hunks)
  • bundler-packages/runtime/src/generateTevmBodyDts.js (2 hunks)
  • bundler-packages/runtime/src/generateTevmBodyDts.spec.ts (1 hunks)
  • lsp/ts-plugin/src/decorators/getScriptSnapshot.spec.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • bundler-packages/runtime/src/generateRuntime.spec.ts
  • bundler-packages/runtime/src/generateTevmBodyDts.spec.ts
  • lsp/ts-plugin/src/decorators/getScriptSnapshot.spec.ts
Files skipped from review as they are similar to previous changes (1)
  • .changeset/tidy-pans-melt.md
Additional context used
Biome
bundler-packages/runtime/src/generateTevmBody.js

[error] 38-38: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

bundler-packages/runtime/src/generateTevmBodyDts.js

[error] 30-30: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)


[error] 48-48: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

Additional comments not posted (9)
bundler-packages/runtime/src/generateTevmBody.js (1)

38-38: Replace template literal with string literal.

The use of a template literal is unnecessary here. Replace it with a regular string literal.

- natspec.push(` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`)
+ natspec.push(' * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation')

Likely invalid or redundant comment.

Tools
Biome

[error] 38-38: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

bundler-packages/runtime/src/generateTevmBody.spec.ts (8)

48-48: Enhance documentation clarity.

The addition of the @see tag improves the documentation by providing a reference to external resources. This change enhances the usability and understanding of the contract documentation.


57-57: Enhance documentation clarity.

The addition of the @see tag improves the documentation by providing a reference to external resources. This change enhances the usability and understanding of the contract documentation.


73-73: Enhance documentation clarity.

The addition of the @see tag improves the documentation by providing a reference to external resources. This change enhances the usability and understanding of the contract documentation.


82-82: Enhance documentation clarity.

The addition of the @see tag improves the documentation by providing a reference to external resources. This change enhances the usability and understanding of the contract documentation.


98-98: Enhance documentation clarity.

The addition of the @see tag improves the documentation by providing a reference to external resources. This change enhances the usability and understanding of the contract documentation.


107-107: Enhance documentation clarity.

The addition of the @see tag improves the documentation by providing a reference to external resources. This change enhances the usability and understanding of the contract documentation.


119-121: Enhance documentation clarity.

The addition of the @see tag and the improved comments about bytecode compilation provide clearer guidance for developers. This change enhances the usability and understanding of the contract documentation.


129-131: Enhance documentation clarity.

The addition of the @see tag and the improved comments about bytecode compilation provide clearer guidance for developers. This change enhances the usability and understanding of the contract documentation.

` * ${contractName} Contract`,
` * ${contractName} Contract (no bytecode)`,
` * change file name or add file that ends in '.s.sol' extension if you wish to compile the bytecode`,
` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace template literal with string literal.

The use of a template literal is unnecessary here. Replace it with a regular string literal.

- ` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`
+ ' * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation'
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`,
' * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation',
Tools
Biome

[error] 48-48: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

...natspec,
` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace template literal with string literal.

The use of a template literal is unnecessary here. Replace it with a regular string literal.

- ` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`
+ ' * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation'
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
` * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation`,
' * @see [contract docs](https://tevm.sh/learn/contracts/) for more documentation',
Tools
Biome

[error] 30-30: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

@roninjin10 roninjin10 force-pushed the 08-14-_memo_feat_add_natspec_comments_to_contract_imports branch from f06ff2b to 38a30bd Compare August 15, 2024 04:06
@roninjin10 roninjin10 merged commit 35f2d5e into main Aug 15, 2024
9 checks passed
@roninjin10 roninjin10 deleted the 08-14-_memo_feat_add_natspec_comments_to_contract_imports branch August 15, 2024 04:23
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

Successfully merging this pull request may close these issues.

Enhancement: Add better jsdoc for tevm contracts
1 participant