mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2590 from ethereum/natspec-cleanup
Remove unneccesary interface from Natspec
This commit is contained in:
commit
46d31f7179
@ -451,18 +451,20 @@ Json::Value const& CompilerStack::natspec(Contract const& _contract, Documentati
|
||||
{
|
||||
case DocumentationType::NatspecUser:
|
||||
doc = &_contract.userDocumentation;
|
||||
// caches the result
|
||||
if (!*doc)
|
||||
doc->reset(new Json::Value(Natspec::userDocumentation(*_contract.contract)));
|
||||
break;
|
||||
case DocumentationType::NatspecDev:
|
||||
doc = &_contract.devDocumentation;
|
||||
// caches the result
|
||||
if (!*doc)
|
||||
doc->reset(new Json::Value(Natspec::devDocumentation(*_contract.contract)));
|
||||
break;
|
||||
default:
|
||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal documentation type."));
|
||||
}
|
||||
|
||||
// caches the result
|
||||
if (!*doc)
|
||||
doc->reset(new Json::Value(Natspec::documentation(*_contract.contract, _type)));
|
||||
|
||||
return *(*doc);
|
||||
}
|
||||
|
||||
|
@ -26,28 +26,11 @@
|
||||
#include <libsolidity/interface/Natspec.h>
|
||||
#include <boost/range/irange.hpp>
|
||||
#include <libsolidity/ast/AST.h>
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace dev::solidity;
|
||||
|
||||
Json::Value Natspec::documentation(
|
||||
ContractDefinition const& _contractDef,
|
||||
DocumentationType _type
|
||||
)
|
||||
{
|
||||
switch(_type)
|
||||
{
|
||||
case DocumentationType::NatspecUser:
|
||||
return userDocumentation(_contractDef);
|
||||
case DocumentationType::NatspecDev:
|
||||
return devDocumentation(_contractDef);
|
||||
}
|
||||
|
||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown documentation type"));
|
||||
}
|
||||
|
||||
Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef)
|
||||
{
|
||||
Json::Value doc;
|
||||
|
@ -39,7 +39,6 @@ class ContractDefinition;
|
||||
class Type;
|
||||
using TypePointer = std::shared_ptr<Type const>;
|
||||
struct DocTag;
|
||||
enum class DocumentationType: uint8_t;
|
||||
|
||||
enum class DocTagType: uint8_t
|
||||
{
|
||||
@ -61,15 +60,6 @@ enum class CommentOwner
|
||||
class Natspec
|
||||
{
|
||||
public:
|
||||
/// Get the given type of documentation
|
||||
/// @param _contractDef The contract definition
|
||||
/// @param _type The type of the documentation. Can be one of the
|
||||
/// types provided by @c DocumentationType
|
||||
/// @return A JSON representation of provided type
|
||||
static Json::Value documentation(
|
||||
ContractDefinition const& _contractDef,
|
||||
DocumentationType _type
|
||||
);
|
||||
/// Get the User documentation of the contract
|
||||
/// @param _contractDef The contract definition
|
||||
/// @return A JSON representation of the contract's user documentation
|
||||
|
Loading…
Reference in New Issue
Block a user