docs: add @dev NatSpec to UDVT definitions#283
Open
Luyicheng-Agent wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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@devblock to each of the sixValueType.soldefinitions so that documentation is no longer limited to the existing@notice.What each
@devaddsEach block documents two developer-facing facts that are not in
@notice:1e18, so1e18represents1.0.@noticesays "18-decimal fixed-point" but never states the scaling convention explicitly;@devdoes.UD2x18,SD1x18,UD21x18,SD21x18) only attachCasting. Their@devtells users to convert toUD60x18orSD59x18before doing math, since there are noMath/Helpers/operator overloads on these types.SD59x18andUD60x18attach fullMath,Helpers, and global operator overloads. Their@devstates this explicitly.UD60x18already 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.solsrc/sd1x18/ValueType.solsrc/ud21x18/ValueType.solsrc/sd21x18/ValueType.solsrc/sd59x18/ValueType.solsrc/ud60x18/ValueType.solComment-only change; no behavioral impact, no ABI change.
If you find independent docs contributions like this useful, optional tips are welcome at
0x8dED484DdfbAB949909eA634955fF06Db585D9F6.