@ -11,6 +11,10 @@
# include "google/protobuf/compiler/java/doc_comment.h"
# include <stddef.h>
# include <algorithm>
# include <cctype>
# include <string>
# include <vector>
@ -142,14 +146,20 @@ static void WriteDocCommentBodyForLocation(io::Printer* printer,
printer - > Print ( " * <pre> \n " ) ;
}
for ( int i = 0 ; i < lines . size ( ) ; i + + ) {
// Most lines should start with a space. Watch out for lines that start
// with a /, since putting that right after the leading asterisk will
// close the comment.
if ( ! lines [ i ] . empty ( ) & & lines [ i ] [ 0 ] = = ' / ' ) {
printer - > Print ( " * $line$ \n " , " line " , lines [ i ] ) ;
for ( size_t i = 0 ; i < lines . size ( ) ; i + + ) {
// Lines should start with a single space and any extraneous leading
// spaces should be stripped. For lines starting with a /, the leading
// space will prevent putting it right after the leading asterick from
// closing the comment.
std : : string line = lines [ i ] ;
line . erase ( line . begin ( ) ,
std : : find_if ( line . begin ( ) , line . end ( ) , [ ] ( unsigned char ch ) {
return ! std : : isspace ( ch ) ;
} ) ) ;
if ( ! line . empty ( ) ) {
printer - > Print ( " * $line$ \n " , " line " , line ) ;
} else {
printer - > Print ( " *$line$ \n " , " line " , lines [ i ] ) ;
printer - > Print ( " * \n " ) ;
}
}