/** * Renders all the help text required for a given name. * @param resourceText resource text properties * @param elementName element name to use as the key * @param element Doc element to process. */ private void renderHelpText(final Properties resourceText, final String elementName, final Doc element) { StringBuilder summaryBuilder = new StringBuilder(); for(Tag tag: element.firstSentenceTags()) summaryBuilder.append(tag.text()); String summary = summaryBuilder.toString(); String description = element.commentText(); // this might seem unnecessary, but the GATK command line program uses this tag to determine the version when running if(absoluteVersion != null) resourceText.setProperty(String.format("%s.%s",elementName,VERSION_TAGLET_NAME),absoluteVersion); // Write out an alternate element summary, if exists. resourceText.setProperty(String.format("%s.%s",elementName,SUMMARY_TAGLET_NAME),formatText(summary)); // Write out an alternate description, if present. resourceText.setProperty(String.format("%s.%s",elementName,DESCRIPTION_TAGLET_NAME),formatText(description)); }
/** * 输出格式化的注释信息 * * @param doc * {@link com.sun.tools.javadoc.ClassDocImpl} 或 {@link com.sun.tools.javadoc.MethodDocImpl}实例 * @param needIndent * 是否缩进 * @return */ public final String formatComment(Doc doc, boolean needIndent) { Preconditions.checkNotNull(doc, "doc is null"); Type type = typeOfDoc(doc); StringBuffer buffer = new StringBuffer(); commentText(buffer,doc.commentText(),type); for (Tag tag : doc.tags()) { if( ! type.check(excludeTags.get(tag.name())) ) buffer.append(tag.name()).append(" ").append(tag.text()).append('\n'); } String cmt = buffer.toString(); if (!cmt.isEmpty()) { cmt = Pattern.compile("\n\\s*", Pattern.MULTILINE).matcher(cmt).replaceAll("\n"); cmt = Pattern.compile("^", Pattern.MULTILINE).matcher(cmt).replaceAll(" * "); cmt = commentBody.replaceFirst("\n", "$0" + cmt); if (needIndent) cmt = Pattern.compile("^", Pattern.MULTILINE).matcher(cmt).replaceAll(indent); } return cmt; }
private static String getDocWithIncludes(Doc doc) { StringBuilder sb = new StringBuilder(); if (!Strings.isNullOrEmpty(doc.commentText())) { for (Tag tag : doc.inlineTags()) { if (tag.kind().equals(TEXT_TAG)) { sb.append(P).append(tag.text()); } else if (tag.kind().equals(SEE_TAG)) { sb.append(getIncludeFromLink((SeeTag) tag)); } } //sb.append(doc.commentText()).append(LS).append(LS); } String example = getExamples(doc); if (!Strings.isNullOrEmpty(example)) { sb.append(example); } return sb.toString(); }
/** * Renders a generic document (class, field, method, etc) * * @param doc input */ @Override public void renderDoc(Doc doc) { // hide text that looks like tags (such as annotations in source code) from Javadoc doc.setRawCommentText(doc.getRawCommentText().replaceAll("@([A-Z])", "{@literal @}$1")); StringBuilder buffer = new StringBuilder(); buffer.append(render(doc.commentText(), false)); buffer.append('\n'); for (Tag tag : doc.tags()) { renderTag(tag, buffer); buffer.append('\n'); } doc.setRawCommentText(buffer.toString()); }
try { StringBuilder buf = new StringBuilder(); buf.append(getOptions().toHtml(doc.commentText(), fixLeadingSpaces)); buf.append('\n'); for ( Tag tag : doc.tags() ) {