NatSpec parser#1898
Merged
Merged
Conversation
d608aa3 to
37a44b7
Compare
Codecov Report
@@ Coverage Diff @@
## master #1898 +/- ##
==========================================
+ Coverage 87% 87.01% +<.01%
==========================================
Files 53 54 +1
Lines 6187 6275 +88
Branches 1600 1622 +22
==========================================
+ Hits 5383 5460 +77
- Misses 514 519 +5
- Partials 290 296 +6
Continue to review full report at Codecov.
|
d522395 to
54b9648
Compare
54b9648 to
3ef84d7
Compare
3ef84d7 to
0162fb7
Compare
Contributor
Author
|
This test verifies that the natspec output is identical between solidity and vyper. I'm not including it in our test suite because I don't want to introduce import json
import solcx
import vyper
solcx.set_solc_version('0.6.3')
solc_output = solcx.compile_source("""
/// @title A simulator for trees
/// @author Larry A. Gardner
/// @notice You can use this contract for only the most basic simulation
/// @dev All function calls are currently implemented without side effects
contract Tree {
/// @author Mary A. Botanist
/// @notice Calculate tree age in years, rounded up, for live trees
/// @dev The Alexandr N. Tetearing algorithm could increase precision
/// @param rings The number of rings from dendrochronological sample
/// @return age in years, rounded up for partial years
function age(uint256 rings) external pure returns (uint256) {
return rings + 1;
}
}
""", output_values=['devdoc', 'userdoc'])['<stdin>:Tree']
solc_output = {k: json.loads(v) for k, v in solc_output.items()}
vyper_output = vyper.compile_code("""
'''
@title A simulator for trees
@author Larry A. Gardner
@notice You can use this contract for only the most basic simulation
@dev All function calls are currently implemented without side effects
'''
@public
@constant
def age(rings: uint256) -> uint256:
'''
@author Mary A. Botanist
@notice Calculate tree age in years, rounded up, for live trees
@dev The Alexandr N. Tetearing algorithm could increase precision
@param rings The number of rings from dendrochronological sample
@return age in years, rounded up for partial years
'''
return rings + 1
""", output_formats=['devdoc', 'userdoc'])
assert solc_output == vyper_output |
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.
What I did
Add NatSpec parsing functionality. Closes #1863
How I did it
ast/natspec.pyast/__init__.pyandast/nodes.pyto avoid typing issuesuserdocanddevdocas compiler output options and enable invyper-compileandvyper-json.The output format is identical to that of Solidity
>=0.6.0:@notice.@paramfields.@returnvalues are supported, each value is assigned a name_[n]withnincrementing from0.How to verify it
Run tests.
TODO
Cute Animal Picture