-
-
Notifications
You must be signed in to change notification settings - Fork 788
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
NatSpec parser #1898
NatSpec parser #1898
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
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 |
What I did
Add NatSpec parsing functionality. Closes #1863
How I did it
ast/natspec.py
ast/__init__.py
andast/nodes.py
to avoid typing issuesuserdoc
anddevdoc
as compiler output options and enable invyper-compile
andvyper-json
.The output format is identical to that of Solidity
>=0.6.0
:@notice
.@param
fields.@return
values are supported, each value is assigned a name_[n]
withn
incrementing from0
.How to verify it
Run tests.
TODO
Cute Animal Picture