mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9163 from ethereum/issue-8922
Natspec: Output "type" and "version" in documentation
This commit is contained in:
commit
b94a00baf6
@ -4,6 +4,7 @@ Language Features:
|
||||
|
||||
|
||||
Compiler Features:
|
||||
* NatSpec: Add fields "kind" and "version" to the JSON output.
|
||||
|
||||
|
||||
Bugfixes:
|
||||
|
@ -37,6 +37,9 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef)
|
||||
Json::Value doc;
|
||||
Json::Value methods(Json::objectValue);
|
||||
|
||||
doc["version"] = Json::Value(c_natspecVersion);
|
||||
doc["kind"] = Json::Value("user");
|
||||
|
||||
auto constructorDefinition(_contractDef.constructor());
|
||||
if (constructorDefinition)
|
||||
{
|
||||
@ -87,6 +90,9 @@ Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef)
|
||||
Json::Value doc;
|
||||
Json::Value methods(Json::objectValue);
|
||||
|
||||
doc["version"] = Json::Value(c_natspecVersion);
|
||||
doc["kind"] = Json::Value("dev");
|
||||
|
||||
auto author = extractDoc(_contractDef.annotation().docTags, "author");
|
||||
if (!author.empty())
|
||||
doc["author"] = author;
|
||||
|
@ -40,6 +40,8 @@ struct DocTag;
|
||||
class Natspec
|
||||
{
|
||||
public:
|
||||
static unsigned int constexpr c_natspecVersion = 1;
|
||||
|
||||
/// Get the User documentation of the contract
|
||||
/// @param _contractDef The contract definition
|
||||
/// @return A JSON representation of the contract's user documentation
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
#include <liblangutil/Exceptions.h>
|
||||
#include <libsolutil/Exceptions.h>
|
||||
#include <libsolidity/interface/Natspec.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
@ -56,6 +57,10 @@ public:
|
||||
generatedDocumentation = m_compilerStack.natspecDev(_contractName);
|
||||
Json::Value expectedDocumentation;
|
||||
util::jsonParseStrict(_expectedDocumentationString, expectedDocumentation);
|
||||
|
||||
expectedDocumentation["version"] = Json::Value(Natspec::c_natspecVersion);
|
||||
expectedDocumentation["kind"] = Json::Value(_userDocumentation ? "user" : "dev");
|
||||
|
||||
BOOST_CHECK_MESSAGE(
|
||||
expectedDocumentation == generatedDocumentation,
|
||||
"Expected:\n" << expectedDocumentation.toStyledString() <<
|
||||
|
@ -354,9 +354,9 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
|
||||
BOOST_CHECK(contract["abi"].isArray());
|
||||
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]");
|
||||
BOOST_CHECK(contract["devdoc"].isObject());
|
||||
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["devdoc"]), "{\"methods\":{}}");
|
||||
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["devdoc"]), R"({"kind":"dev","methods":{},"version":1})");
|
||||
BOOST_CHECK(contract["userdoc"].isObject());
|
||||
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["userdoc"]), "{\"methods\":{}}");
|
||||
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["userdoc"]), R"({"kind":"user","methods":{},"version":1})");
|
||||
BOOST_CHECK(contract["evm"].isObject());
|
||||
/// @TODO check evm.methodIdentifiers, legacyAssembly, bytecode, deployedBytecode
|
||||
BOOST_CHECK(contract["evm"]["bytecode"].isObject());
|
||||
|
Loading…
Reference in New Issue
Block a user