mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Separate user and dev natspec documentation
- plus other small changes according to the spec
This commit is contained in:
parent
06998aa2d2
commit
be81981ec4
@ -123,13 +123,13 @@ string const& CompilerStack::getInterface()
|
|||||||
return m_interface;
|
return m_interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
string const& CompilerStack::getDocumentation()
|
string const& CompilerStack::getUserDocumentation()
|
||||||
{
|
{
|
||||||
Json::StyledWriter writer;
|
Json::StyledWriter writer;
|
||||||
if (!m_parseSuccessful)
|
if (!m_parseSuccessful)
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
||||||
|
|
||||||
if (m_documentation.empty())
|
if (m_userDocumentation.empty())
|
||||||
{
|
{
|
||||||
Json::Value doc;
|
Json::Value doc;
|
||||||
Json::Value methods(Json::objectValue);
|
Json::Value methods(Json::objectValue);
|
||||||
@ -140,14 +140,27 @@ string const& CompilerStack::getDocumentation()
|
|||||||
auto strPtr = f->getDocumentation();
|
auto strPtr = f->getDocumentation();
|
||||||
if (strPtr)
|
if (strPtr)
|
||||||
{
|
{
|
||||||
user["user"] = Json::Value(*strPtr);
|
user["notice"] = Json::Value(*strPtr);
|
||||||
methods[f->getName()] = user;
|
methods[f->getName()] = user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc["methods"] = methods;
|
doc["methods"] = methods;
|
||||||
m_documentation = writer.write(doc);
|
m_userDocumentation = writer.write(doc);
|
||||||
}
|
}
|
||||||
return m_documentation;
|
return m_userDocumentation;
|
||||||
|
}
|
||||||
|
|
||||||
|
string const& CompilerStack::getDevDocumentation()
|
||||||
|
{
|
||||||
|
Json::StyledWriter writer;
|
||||||
|
if (!m_parseSuccessful)
|
||||||
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
||||||
|
|
||||||
|
if (m_devDocumentation.empty())
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
return m_devDocumentation;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes CompilerStack::staticCompile(std::string const& _sourceCode, bool _optimize)
|
bytes CompilerStack::staticCompile(std::string const& _sourceCode, bool _optimize)
|
||||||
|
@ -62,9 +62,12 @@ public:
|
|||||||
/// Returns a string representing the contract interface in JSON.
|
/// Returns a string representing the contract interface in JSON.
|
||||||
/// Prerequisite: Successful call to parse or compile.
|
/// Prerequisite: Successful call to parse or compile.
|
||||||
std::string const& getInterface();
|
std::string const& getInterface();
|
||||||
/// Returns a string representing the contract documentation in JSON.
|
/// Returns a string representing the contract's user documentation in JSON.
|
||||||
/// Prerequisite: Successful call to parse or compile.
|
/// Prerequisite: Successful call to parse or compile.
|
||||||
std::string const& getDocumentation();
|
std::string const& getUserDocumentation();
|
||||||
|
/// Returns a string representing the contract's developer documentation in JSON.
|
||||||
|
/// Prerequisite: Successful call to parse or compile.
|
||||||
|
std::string const& getDevDocumentation();
|
||||||
|
|
||||||
/// Returns the previously used scanner, useful for counting lines during error reporting.
|
/// Returns the previously used scanner, useful for counting lines during error reporting.
|
||||||
Scanner const& getScanner() const { return *m_scanner; }
|
Scanner const& getScanner() const { return *m_scanner; }
|
||||||
@ -80,7 +83,8 @@ private:
|
|||||||
std::shared_ptr<ContractDefinition> m_contractASTNode;
|
std::shared_ptr<ContractDefinition> m_contractASTNode;
|
||||||
bool m_parseSuccessful;
|
bool m_parseSuccessful;
|
||||||
std::string m_interface;
|
std::string m_interface;
|
||||||
std::string m_documentation;
|
std::string m_userDocumentation;
|
||||||
|
std::string m_devDocumentation;
|
||||||
std::shared_ptr<Compiler> m_compiler;
|
std::shared_ptr<Compiler> m_compiler;
|
||||||
bytes m_bytecode;
|
bytes m_bytecode;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user