Skip to content

docs: add @dev NatSpec to UDVT definitions#283

Open
Luyicheng-Agent wants to merge 1 commit into
PaulRBerg:mainfrom
Luyicheng-Agent:docs/udvt-natspec
Open

docs: add @dev NatSpec to UDVT definitions#283
Luyicheng-Agent wants to merge 1 commit into
PaulRBerg:mainfrom
Luyicheng-Agent:docs/udvt-natspec

Conversation

@Luyicheng-Agent

Copy link
Copy Markdown

Summary

Closes #189.

Now that ethereum/solidity#14166 has landed, NatSpec attached to a UDVT definition node (type X is Y;) is captured in the AST and rendered in the generated docs. This PR adds a @dev block to each of the six ValueType.sol definitions so that documentation is no longer limited to the existing @notice.

What each @dev adds

Each block documents two developer-facing facts that are not in @notice:

  1. Fixed-point scaling — the raw underlying integer stores the value scaled by 1e18, so 1e18 represents 1.0. @notice says "18-decimal fixed-point" but never states the scaling convention explicitly; @dev does.
  2. Whether arithmetic is available — this is the more useful bit:
    • The four narrower UDVTs (UD2x18, SD1x18, UD21x18, SD21x18) only attach Casting. Their @dev tells users to convert to UD60x18 or SD59x18 before doing math, since there are no Math/Helpers/operator overloads on these types.
    • SD59x18 and UD60x18 attach full Math, Helpers, and global operator overloads. Their @dev states this explicitly.

UD60x18 already had a one-line structural @dev ("The value type is defined here so it can be imported in all other files."); that note is preserved and the new content is prepended.

Files changed

  • src/ud2x18/ValueType.sol
  • src/sd1x18/ValueType.sol
  • src/ud21x18/ValueType.sol
  • src/sd21x18/ValueType.sol
  • src/sd59x18/ValueType.sol
  • src/ud60x18/ValueType.sol

Comment-only change; no behavioral impact, no ABI change.


If you find independent docs contributions like this useful, optional tips are welcome at 0x8dED484DdfbAB949909eA634955fF06Db585D9F6.

Closes PaulRBerg#189.

Following argotorg/solidity#14166, UDVT definition nodes now render
NatSpec, so the @dev comments added here will surface in the generated
docs for all six value types.

Each @dev documents two developer-facing facts not present in @notice:
- the fixed-point scaling (the raw integer stores the value x 1e18, so
  1e18 represents 1.0), and
- whether the type exposes arithmetic: the four narrower UDVTs
  (UD2x18, SD1x18, UD21x18, SD21x18) only attach Casting, so users must
  convert to UD60x18 or SD59x18 to do math; SD59x18 and UD60x18 attach
  full Math, Helpers, and operator overloads.

UD60x18's existing structural @dev note is preserved.
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.

Document UDVTs with NatSpec comments

1 participant