|
|
@ -166,9 +166,12 @@ static inline std::string::const_iterator skipLineOrEOS(std::string::const_itera |
|
|
|
std::string::const_iterator InterfaceHandler::parseDocTagLine(std::string::const_iterator _pos, |
|
|
|
std::string::const_iterator _end, |
|
|
|
std::string& _tagString, |
|
|
|
DocTagType _tagType) |
|
|
|
DocTagType _tagType, |
|
|
|
bool _appending) |
|
|
|
{ |
|
|
|
auto nlPos = std::find(_pos, _end, '\n'); |
|
|
|
if (_appending && _pos < _end && *_pos != ' ') |
|
|
|
_tagString += " "; |
|
|
|
std::copy(_pos, nlPos, back_inserter(_tagString)); |
|
|
|
m_lastTag = _tagType; |
|
|
|
return skipLineOrEOS(nlPos, _end); |
|
|
@ -201,7 +204,8 @@ std::string::const_iterator InterfaceHandler::appendDocTagParam(std::string::con |
|
|
|
solAssert(!m_params.empty(), "Internal: Tried to append to empty parameter"); |
|
|
|
|
|
|
|
auto pair = m_params.back(); |
|
|
|
pair.second += " "; |
|
|
|
if (_pos < _end && *_pos != ' ') |
|
|
|
pair.second += " "; |
|
|
|
auto nlPos = std::find(_pos, _end, '\n'); |
|
|
|
std::copy(_pos, nlPos, back_inserter(pair.second)); |
|
|
|
|
|
|
@ -221,17 +225,17 @@ std::string::const_iterator InterfaceHandler::parseDocTag(std::string::const_ite |
|
|
|
if (m_lastTag == DocTagType::NONE || _tag != "") |
|
|
|
{ |
|
|
|
if (_tag == "dev") |
|
|
|
return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV); |
|
|
|
return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV, false); |
|
|
|
else if (_tag == "notice") |
|
|
|
return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE); |
|
|
|
return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE, false); |
|
|
|
else if (_tag == "return") |
|
|
|
return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN); |
|
|
|
return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN, false); |
|
|
|
else if (_tag == "author") |
|
|
|
{ |
|
|
|
if (_owner == CommentOwner::CONTRACT) |
|
|
|
return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR); |
|
|
|
return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR, false); |
|
|
|
else if (_owner == CommentOwner::FUNCTION) |
|
|
|
return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR); |
|
|
|
return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR, false); |
|
|
|
else |
|
|
|
// LTODO: for now this else makes no sense but later comments will go to more language constructs
|
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@author tag is legal only for contracts")); |
|
|
@ -239,7 +243,7 @@ std::string::const_iterator InterfaceHandler::parseDocTag(std::string::const_ite |
|
|
|
else if (_tag == "title") |
|
|
|
{ |
|
|
|
if (_owner == CommentOwner::CONTRACT) |
|
|
|
return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE); |
|
|
|
return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE, false); |
|
|
|
else |
|
|
|
// LTODO: Unknown tag, throw some form of warning and not just an exception
|
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@title tag is legal only for contracts")); |
|
|
@ -261,34 +265,22 @@ std::string::const_iterator InterfaceHandler::appendDocTag(std::string::const_it |
|
|
|
switch (m_lastTag) |
|
|
|
{ |
|
|
|
case DocTagType::DEV: |
|
|
|
m_dev += " "; |
|
|
|
return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV); |
|
|
|
return parseDocTagLine(_pos, _end, m_dev, DocTagType::DEV, true); |
|
|
|
case DocTagType::NOTICE: |
|
|
|
m_notice += " "; |
|
|
|
return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE); |
|
|
|
return parseDocTagLine(_pos, _end, m_notice, DocTagType::NOTICE, true); |
|
|
|
case DocTagType::RETURN: |
|
|
|
m_return += " "; |
|
|
|
return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN); |
|
|
|
return parseDocTagLine(_pos, _end, m_return, DocTagType::RETURN, true); |
|
|
|
case DocTagType::AUTHOR: |
|
|
|
if (_owner == CommentOwner::CONTRACT) |
|
|
|
{ |
|
|
|
m_contractAuthor += " "; |
|
|
|
return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR); |
|
|
|
} |
|
|
|
return parseDocTagLine(_pos, _end, m_contractAuthor, DocTagType::AUTHOR, true); |
|
|
|
else if (_owner == CommentOwner::FUNCTION) |
|
|
|
{ |
|
|
|
m_author += " "; |
|
|
|
return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR); |
|
|
|
} |
|
|
|
return parseDocTagLine(_pos, _end, m_author, DocTagType::AUTHOR, true); |
|
|
|
else |
|
|
|
// LTODO: Unknown tag, throw some form of warning and not just an exception
|
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@author tag in illegal comment")); |
|
|
|
case DocTagType::TITLE: |
|
|
|
if (_owner == CommentOwner::CONTRACT) |
|
|
|
{ |
|
|
|
m_title += " "; |
|
|
|
return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE); |
|
|
|
} |
|
|
|
return parseDocTagLine(_pos, _end, m_title, DocTagType::TITLE, true); |
|
|
|
else |
|
|
|
// LTODO: Unknown tag, throw some form of warning and not just an exception
|
|
|
|
BOOST_THROW_EXCEPTION(DocstringParsingError() << errinfo_comment("@title tag in illegal comment")); |
|
|
@ -329,7 +321,7 @@ void InterfaceHandler::parseDocString(std::string const& _string, CommentOwner _ |
|
|
|
currPos = parseDocTag(tagNameEndPos + 1, end, std::string(tagPos + 1, tagNameEndPos), _owner); |
|
|
|
} |
|
|
|
else if (m_lastTag != DocTagType::NONE) // continuation of the previous tag
|
|
|
|
currPos = appendDocTag(currPos + 1, end, _owner); |
|
|
|
currPos = appendDocTag(currPos, end, _owner); |
|
|
|
else if (currPos != end) // skip the line if a newline was found
|
|
|
|
currPos = nlPos + 1; |
|
|
|
} |
|
|
|