/** * Helper to get the documentation backed up by this proto file for the given * element. */ public String getDocumentation(ProtoElement element) { if (element instanceof ProtoFile) { // For files themselves, comments from multiple locations are composed. StringBuilder result = new StringBuilder(); for (String path : FILE_DOC_LOCATIONS) { String comment = getDocumentation(path); if (Strings.isNullOrEmpty(comment)) { continue; } if (result.length() > 0) { result.append('\n'); } result.append(comment); } return result.toString(); } else { return getDocumentation(element.getPath()); } }
/** * Helper to get the documentation backed up by this proto file for the given * element. */ public String getDocumentation(ProtoElement element) { if (element instanceof ProtoFile) { // For files themselves, comments from multiple locations are composed. StringBuilder result = new StringBuilder(); for (String path : FILE_DOC_LOCATIONS) { String comment = getDocumentation(path); if (Strings.isNullOrEmpty(comment)) { continue; } if (result.length() > 0) { result.append('\n'); } result.append(comment); } return result.toString(); } else { return getDocumentation(element.getPath()); } }
private String getIdlDocumentation(ProtoElement element) { return element.getFile().getDocumentation(element); }
@Override @Nullable protected DocumentationRule fromIdlLayer(ProtoElement element) { // For the case there is no documentation rule, synthesize one from the comment // in the proto. String description = element.getFile().getDocumentation(element); if (inlineAllMessages && (element instanceof MessageType || element instanceof EnumType)) { description = description + "\n(== inline_message ==)"; } if (Strings.isNullOrEmpty(description)) { return null; } return DocumentationRule.newBuilder() .setSelector(element.getFullName()) .setDescription(trimCommentIndentation(description)) .build(); }
@Override @Nullable protected DocumentationRule fromIdlLayer(ProtoElement element) { // For the case there is no documentation rule, synthesize one from the comment // in the proto. String description = element.getFile().getDocumentation(element); if (inlineAllMessages && (element instanceof MessageType || element instanceof EnumType)) { description = description + "\n(== inline_message ==)"; } if (Strings.isNullOrEmpty(description)) { return null; } return DocumentationRule.newBuilder() .setSelector(element.getFullName()) .setDescription(trimCommentIndentation(description)) .build(); }