aboutsummaryrefslogtreecommitdiffstats
path: root/CompilerStack.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-02 00:03:04 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-02 00:03:04 +0800
commit43d6726dd78e35bf79fa2da3824c2916c5e6b0a8 (patch)
tree13299ee2623a590ace54c3554156033dffa98779 /CompilerStack.cpp
parent3fc2708d657525162567b663a07cf8cb5b1c59aa (diff)
downloaddexon-solidity-43d6726dd78e35bf79fa2da3824c2916c5e6b0a8.tar
dexon-solidity-43d6726dd78e35bf79fa2da3824c2916c5e6b0a8.tar.gz
dexon-solidity-43d6726dd78e35bf79fa2da3824c2916c5e6b0a8.tar.bz2
dexon-solidity-43d6726dd78e35bf79fa2da3824c2916c5e6b0a8.tar.lz
dexon-solidity-43d6726dd78e35bf79fa2da3824c2916c5e6b0a8.tar.xz
dexon-solidity-43d6726dd78e35bf79fa2da3824c2916c5e6b0a8.tar.zst
dexon-solidity-43d6726dd78e35bf79fa2da3824c2916c5e6b0a8.zip
Exporting Natspec documentation to a JSON interface
- Adding a getDocumentation() function to solidity compiler stack so that we can obtain the natspec interface for a contract - Adding libjsoncpp as a dependency of libsolidity. This is done in a dirty way, using libjsonrpc-cpp s an intermediate dependency for the moment. Will fix soon. - Start of a test file for Natspec exporting to JSON
Diffstat (limited to 'CompilerStack.cpp')
-rw-r--r--CompilerStack.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/CompilerStack.cpp b/CompilerStack.cpp
index 6535e00d..45d3e0b8 100644
--- a/CompilerStack.cpp
+++ b/CompilerStack.cpp
@@ -28,6 +28,8 @@
#include <libsolidity/Compiler.h>
#include <libsolidity/CompilerStack.h>
+#include <jsonrpc/json/json.h>
+
using namespace std;
namespace dev
@@ -125,6 +127,30 @@ string const& CompilerStack::getInterface()
return m_interface;
}
+string const& CompilerStack::getDocumentation()
+{
+
+ Json::StyledWriter writer;
+ if (!m_parseSuccessful)
+ BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
+ if (m_documentation.empty())
+ {
+ Json::Value doc;
+ Json::Value methods;
+
+ vector<FunctionDefinition const*> exportedFunctions = m_contractASTNode->getInterfaceFunctions();
+ for (FunctionDefinition const* f: exportedFunctions)
+ {
+ Json::Value user;
+ user["user"] = Json::Value(*f->getDocumentation());
+ methods[f->getName()] = user;
+ }
+ doc["methods"] = methods;
+ m_documentation = writer.write(doc);
+ }
+ return m_documentation;
+}
+
bytes CompilerStack::staticCompile(std::string const& _sourceCode, bool _optimize)
{
CompilerStack stack;