Preserve relative indentation when parsing Doxygen comments.

This is important to preserve the structure of the lists which appear
correctly in Python output without any additional effort if the indentation is
lost.

It is also makes the behaviour consistent for

	/**
	 *
	 *
	 */

comments and those without the asterisks in the middle lines, as now the
indentation is preserved in both cases while it was only preserved when the
asterisks were present previously.
This commit is contained in:
Vadim Zeitlin 2014-07-14 02:29:49 +02:00
commit 14ba3b8dd4
4 changed files with 56 additions and 11 deletions

View file

@ -1338,19 +1338,23 @@ void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
// line[pos] may be ' \t' or start of word, it there was no '*', '/' or '!'
// at beginning of the line. Make sure it points to start of the first word
// in the line.
size_t firstWordPos = line.find_first_not_of(" \t", pos);
if (firstWordPos == string::npos) {
m_tokenList.push_back(Token(END_LINE, "\n"));
continue;
}
if (isStartOfCommentLineCharFound) {
size_t firstWordPos = line.find_first_not_of(" \t", pos);
if (firstWordPos == string::npos) {
m_tokenList.push_back(Token(END_LINE, "\n"));
continue;
}
if (isStartOfCommentLineCharFound && firstWordPos > pos) {
m_tokenList.push_back(
Token(PLAINSTRING, line.substr(pos, firstWordPos - pos)));
if (firstWordPos > pos) {
m_tokenList.push_back(
Token(PLAINSTRING, line.substr(pos, firstWordPos - pos)));
pos = firstWordPos;
}
} else {
m_tokenList.push_back(
Token(PLAINSTRING, line.substr(0, pos)));
}
pos = firstWordPos;
while (pos != string::npos) {
// find the end of the word
size_t doxyCmdOrHtmlTagPos = line.find_first_of("\\@<>&\" \t", pos);