Introduction of @external/@ext natspec tags#3630
Introduction of @external/@ext natspec tags#3630aarlt wants to merge 5 commits intoargotorg:developfrom
Conversation
|
I think this is a very good proposal. Could you explain your reasons for introducing a third category? Why not just allow arbitrary tag names? |
|
@chriseth The introduction of that category will somehow open a new namespace for natspec tags that are not supported by solidity itself. Contract code that uses |
|
Forgot that some tools may use |
|
While it is probably a good idea to add a "user defined namespace", we will also have clashes inside that namespace. Apart from that, I'm not sure we should pull out data from that namespace into its own section. extdoc should be part of the developer docs, shouldn't they? |
|
Yeah sure, inside that "user defined namespace" clashes will be still possible, but they will not effect the solidity natspec tag integrity. Sure, |
|
Probably there is no need to have an designated Furthermore, I realised that adding line number information could be from importance: so a mapping of each |
|
Btw, it looks like that natspecs doesn't work for constructors. |
|
I removed I didn't implement the line information yet. It seem to be more complex to do correctly, the only thing I currently see is to extract the line of the contract/constructor/method definition - that is not accurate enough. It would be nice to create a mapping of each |
|
Can you please extract your fix about natspec concerning constructors into a separate pull request? |
|
Created a separate PR for the constructor natspec issue, see PR #3666. |
|
@chriseth after doing a rebase, the test It's also failing on |
|
This was a failing test that made it into the develop branch. It should be fixed now, so please just rebase. |
700d335 to
4a692db
Compare
|
External natspec tags will also provide the line information now. I also grouped the external tags into a node "external", where for all its members the "external:" prefix is already removed, this may simplify the usage of external tags. So basically from the example contract /// @external:ModuleA fancy moduleA annotation
/// multiline annotation for moduleA
contract Contract {
uint256 stateVar;
/// @external:ModuleB awesome moduleB annotation
/// fancy multiline annotation for moduleB
/// @external:ModuleC moduleC
function functionName1(bytes32 input) returns (bytes32 out) {}
/// @ext:ModuleD fancy annotation for moduleD
function functionName2(bytes32 input) returns (bytes32 out) {}
}the resulting devdoc json looks like that: {
"external" :
{
"ModuleA" :
{
"content" : " fancy moduleA annotation\n multiline annotation for moduleA\n",
"line" : 0
}
},
"methods" :
{
"functionName1(bytes32)" :
{
"external" :
{
"ModuleB" :
{
"content" : " awesome moduleB annotation\n fancy multiline annotation for moduleB\n",
"line" : 4
},
"ModuleC" :
{
"content" : " moduleC\n",
"line" : 6
}
}
},
"functionName2(bytes32)" :
{
"external" :
{
"ModuleD" :
{
"content" : " fancy annotation for moduleD\n",
"line" : 8
}
}
}
}
} |
- removed external natspec api, external natspecs are now place within the dev documentation.
- external natspec tags provide now line information of there appearance in source-code. - external natspec tags need now to be defined atomically - appending is not supported anymore and will result in parse error. - in devdoc now an "external" subnode will be created, that holds the content and the line information per external tag. - removed methods from libsolidity/parsing/DocStringParser.h that didn't provide any implementation.
|
@chriseth Any news on this? |
|
This needs to be discussed in the next weekly meeting, I think. |
|
@chriseth ok, i think i could make it next week. |
|
I think we can close this PR. If we allow arbitrary tags during the redesign of natspecs, we should discuss whether it makes sense to allow the user to specify somehow that newlines should be preserved. We should also think about adding positioning information to the natspec. It might also be useful if we add comments to the However, this is for sure a different discussion. |
|
@aarlt in that case can you create an issue describing the proposal? |
|
Will close that PR now. |
This PR introduces new
@externaland@extnatspec tags. This will give third-party applications the possibility to parse contracts and/or contract-methods annotations in a generic way.The tag is named
@externalbecause it's semantic is not defined by solidity, the semantic is defined by the third-party application that uses specific@externaltags.The main problem is that the class
dev::solidity::CompilerStackcurrently only provide access to two types of natspec comments related toUserandDeveloperdocumentation. The natspec comments are strictly defined and not extensible. So contracts only allow@author,@title,@devand@noticeannotations, where contract-methods can be annotated with@author,@dev,@notice,@returnand@param. Furthermore all new-lines will be discarded.Third-party applications will benefit from the possibility to parse application-specific contract/contract-method annotations. The
@external, short@exttag can be extracted easily withdev::solidity::CompilerStack::natspecExternal(...)methods. In general,@external:<name>defines an external natspec comment for the modulename, this will ensure extensibility, and will prevent potential conflicts of different@externalannotations. In contrast to other natspec tags, new-lines will be preserved, where multiple definitions of the same@externaltags will result in appending. Multi-line annotations are supported.