Skip to content

docs: add NatSpec to StdMath and StdError - #845

Merged
zerosnacks merged 1 commit into
foundry-rs:masterfrom
sylvarissolutions-max:docs-natspec-stdmath-stderr
Apr 13, 2026
Merged

docs: add NatSpec to StdMath and StdError#845
zerosnacks merged 1 commit into
foundry-rs:masterfrom
sylvarissolutions-max:docs-natspec-stdmath-stderr

Conversation

@sylvarissolutions-max

Copy link
Copy Markdown
Contributor

Part of #653. Two more of the files listed in the NatSpec docs checklist.

StdMath.sol

Added `@notice`, `@param`, and `@return` tags to the library and all five internal functions:

  • `abs(int256)`
  • `delta(uint256, uint256)`
  • `delta(int256, int256)`
  • `percentDelta(uint256, uint256)`
  • `percentDelta(int256, int256)`

I did not rename `INT256_MIN` to `_INT256_MIN` even though the issue mentions the underscore-prefix convention for private variables. The already-merged StdAssertions.sol work (PR #666 / StdInvariant) left its private constants without the underscore prefix (for example `FAILED_SLOT`), so I matched that pattern to keep this PR purely additive. Happy to apply the rename in a follow-up or in this PR if you prefer the underscore convention going forward. Let me know which way you want to settle it.

StdError.sol

Added `@notice` to each of the nine public panic-code constants describing what Solidity panic it corresponds to. Panic codes cross-checked against the Solidity docs.

What is not in this PR

Testing

I do not have Foundry set up on this machine so I have not run `forge fmt --check` or `forge test` locally. The diff is 38 insertions and 0 deletions, all inside NatSpec comment blocks above existing declarations, so behavior is unchanged. CI should cover the formatting and test pass. If CI flags anything I will fix it in this branch.

Happy to split this into two PRs (one per file) if that is easier to review.

@zerosnacks zerosnacks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@zerosnacks
zerosnacks merged commit 6466ada into foundry-rs:master Apr 13, 2026
22 checks passed
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.

2 participants