|
|
@ -124,6 +124,7 @@ static std::string EscapeKdoc(const std::string& input) { |
|
|
|
|
|
|
|
|
|
|
|
static void WriteDocCommentBodyForLocation(io::Printer* printer, |
|
|
|
static void WriteDocCommentBodyForLocation(io::Printer* printer, |
|
|
|
const SourceLocation& location, |
|
|
|
const SourceLocation& location, |
|
|
|
|
|
|
|
const Options options, |
|
|
|
const bool kdoc) { |
|
|
|
const bool kdoc) { |
|
|
|
std::string comments = location.leading_comments.empty() |
|
|
|
std::string comments = location.leading_comments.empty() |
|
|
|
? location.trailing_comments |
|
|
|
? location.trailing_comments |
|
|
@ -146,20 +147,24 @@ static void WriteDocCommentBodyForLocation(io::Printer* printer, |
|
|
|
printer->Print(" * <pre>\n"); |
|
|
|
printer->Print(" * <pre>\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < lines.size(); i++) { |
|
|
|
// TODO: Remove once prototiller can avoid making
|
|
|
|
// Lines should start with a single space and any extraneous leading
|
|
|
|
// extraneous formatting changes to comments.
|
|
|
|
// spaces should be stripped. For lines starting with a /, the leading
|
|
|
|
if (!options.strip_nonfunctional_codegen) { |
|
|
|
// space will prevent putting it right after the leading asterick from
|
|
|
|
for (size_t i = 0; i < lines.size(); i++) { |
|
|
|
// closing the comment.
|
|
|
|
// Lines should start with a single space and any extraneous leading
|
|
|
|
std::string line = lines[i]; |
|
|
|
// spaces should be stripped. For lines starting with a /, the leading
|
|
|
|
line.erase(line.begin(), |
|
|
|
// space will prevent putting it right after the leading asterick from
|
|
|
|
std::find_if(line.begin(), line.end(), [](unsigned char ch) { |
|
|
|
// closing the comment.
|
|
|
|
return !std::isspace(ch); |
|
|
|
std::string line = lines[i]; |
|
|
|
})); |
|
|
|
line.erase(line.begin(), |
|
|
|
if (!line.empty()) { |
|
|
|
std::find_if(line.begin(), line.end(), [](unsigned char ch) { |
|
|
|
printer->Print(" * $line$\n", "line", line); |
|
|
|
return !std::isspace(ch); |
|
|
|
} else { |
|
|
|
})); |
|
|
|
printer->Print(" *\n"); |
|
|
|
if (!line.empty()) { |
|
|
|
|
|
|
|
printer->Print(" * $line$\n", "line", line); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
printer->Print(" *\n"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -175,10 +180,10 @@ static void WriteDocCommentBodyForLocation(io::Printer* printer, |
|
|
|
template <typename DescriptorType> |
|
|
|
template <typename DescriptorType> |
|
|
|
static void WriteDocCommentBody(io::Printer* printer, |
|
|
|
static void WriteDocCommentBody(io::Printer* printer, |
|
|
|
const DescriptorType* descriptor, |
|
|
|
const DescriptorType* descriptor, |
|
|
|
const bool kdoc) { |
|
|
|
const Options options, const bool kdoc) { |
|
|
|
SourceLocation location; |
|
|
|
SourceLocation location; |
|
|
|
if (descriptor->GetSourceLocation(&location)) { |
|
|
|
if (descriptor->GetSourceLocation(&location)) { |
|
|
|
WriteDocCommentBodyForLocation(printer, location, kdoc); |
|
|
|
WriteDocCommentBodyForLocation(printer, location, options, kdoc); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -213,9 +218,9 @@ static void WriteDebugString(io::Printer* printer, const FieldDescriptor* field, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void WriteMessageDocComment(io::Printer* printer, const Descriptor* message, |
|
|
|
void WriteMessageDocComment(io::Printer* printer, const Descriptor* message, |
|
|
|
const bool kdoc) { |
|
|
|
const Options options, const bool kdoc) { |
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, message, kdoc); |
|
|
|
WriteDocCommentBody(printer, message, options, kdoc); |
|
|
|
if (kdoc) { |
|
|
|
if (kdoc) { |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
" * Protobuf type `$fullname$`\n" |
|
|
|
" * Protobuf type `$fullname$`\n" |
|
|
@ -238,7 +243,7 @@ void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field, |
|
|
|
// And then we end with the javadoc tags if applicable.
|
|
|
|
// And then we end with the javadoc tags if applicable.
|
|
|
|
// If the field is a group, the debug string might end with {.
|
|
|
|
// If the field is a group, the debug string might end with {.
|
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, field, kdoc); |
|
|
|
WriteDocCommentBody(printer, field, options, kdoc); |
|
|
|
WriteDebugString(printer, field, options, kdoc); |
|
|
|
WriteDebugString(printer, field, options, kdoc); |
|
|
|
printer->Print(" */\n"); |
|
|
|
printer->Print(" */\n"); |
|
|
|
} |
|
|
|
} |
|
|
@ -276,7 +281,7 @@ void WriteFieldAccessorDocComment(io::Printer* printer, |
|
|
|
const Options options, const bool builder, |
|
|
|
const Options options, const bool builder, |
|
|
|
const bool kdoc) { |
|
|
|
const bool kdoc) { |
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, field, kdoc); |
|
|
|
WriteDocCommentBody(printer, field, options, kdoc); |
|
|
|
WriteDebugString(printer, field, options, kdoc); |
|
|
|
WriteDebugString(printer, field, options, kdoc); |
|
|
|
if (!kdoc) WriteDeprecatedJavadoc(printer, field, type, options); |
|
|
|
if (!kdoc) WriteDeprecatedJavadoc(printer, field, type, options); |
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
@ -336,7 +341,7 @@ void WriteFieldEnumValueAccessorDocComment(io::Printer* printer, |
|
|
|
const bool builder, |
|
|
|
const bool builder, |
|
|
|
const bool kdoc) { |
|
|
|
const bool kdoc) { |
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, field, kdoc); |
|
|
|
WriteDocCommentBody(printer, field, options, kdoc); |
|
|
|
WriteDebugString(printer, field, options, kdoc); |
|
|
|
WriteDebugString(printer, field, options, kdoc); |
|
|
|
if (!kdoc) WriteDeprecatedJavadoc(printer, field, type, options); |
|
|
|
if (!kdoc) WriteDeprecatedJavadoc(printer, field, type, options); |
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
@ -407,7 +412,7 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, |
|
|
|
const bool builder, |
|
|
|
const bool builder, |
|
|
|
const bool kdoc) { |
|
|
|
const bool kdoc) { |
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, field, kdoc); |
|
|
|
WriteDocCommentBody(printer, field, options, kdoc); |
|
|
|
WriteDebugString(printer, field, options, kdoc); |
|
|
|
WriteDebugString(printer, field, options, kdoc); |
|
|
|
if (!kdoc) WriteDeprecatedJavadoc(printer, field, type, options); |
|
|
|
if (!kdoc) WriteDeprecatedJavadoc(printer, field, type, options); |
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
@ -461,9 +466,9 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, |
|
|
|
// Enum
|
|
|
|
// Enum
|
|
|
|
|
|
|
|
|
|
|
|
void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, |
|
|
|
void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, |
|
|
|
const bool kdoc) { |
|
|
|
const Options options, const bool kdoc) { |
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, enum_, kdoc); |
|
|
|
WriteDocCommentBody(printer, enum_, options, kdoc); |
|
|
|
if (kdoc) { |
|
|
|
if (kdoc) { |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
" * Protobuf enum `$fullname$`\n" |
|
|
|
" * Protobuf enum `$fullname$`\n" |
|
|
@ -478,9 +483,10 @@ void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void WriteEnumValueDocComment(io::Printer* printer, |
|
|
|
void WriteEnumValueDocComment(io::Printer* printer, |
|
|
|
const EnumValueDescriptor* value) { |
|
|
|
const EnumValueDescriptor* value, |
|
|
|
|
|
|
|
const Options options) { |
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, value, /* kdoc */ false); |
|
|
|
WriteDocCommentBody(printer, value, options, /* kdoc */ false); |
|
|
|
|
|
|
|
|
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
" * <code>$def$</code>\n" |
|
|
|
" * <code>$def$</code>\n" |
|
|
@ -489,19 +495,20 @@ void WriteEnumValueDocComment(io::Printer* printer, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void WriteServiceDocComment(io::Printer* printer, |
|
|
|
void WriteServiceDocComment(io::Printer* printer, |
|
|
|
const ServiceDescriptor* service) { |
|
|
|
const ServiceDescriptor* service, |
|
|
|
|
|
|
|
const Options options) { |
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, service, /* kdoc */ false); |
|
|
|
WriteDocCommentBody(printer, service, options, /* kdoc */ false); |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
" * Protobuf service {@code $fullname$}\n" |
|
|
|
" * Protobuf service {@code $fullname$}\n" |
|
|
|
" */\n", |
|
|
|
" */\n", |
|
|
|
"fullname", EscapeJavadoc(service->full_name())); |
|
|
|
"fullname", EscapeJavadoc(service->full_name())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void WriteMethodDocComment(io::Printer* printer, |
|
|
|
void WriteMethodDocComment(io::Printer* printer, const MethodDescriptor* method, |
|
|
|
const MethodDescriptor* method) { |
|
|
|
const Options options) { |
|
|
|
printer->Print("/**\n"); |
|
|
|
printer->Print("/**\n"); |
|
|
|
WriteDocCommentBody(printer, method, /* kdoc */ false); |
|
|
|
WriteDocCommentBody(printer, method, options, /* kdoc */ false); |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
" * <code>$def$</code>\n" |
|
|
|
" * <code>$def$</code>\n" |
|
|
|
" */\n", |
|
|
|
" */\n", |
|
|
|