private ClassDoc getClassDoc(final Class<?> clazz, final List<Doc> docs) { final String qualifiedName = clazz.getName(); for (Doc doc : docs) { if (doc.isClass()) { final ClassDoc classDoc = (ClassDoc) doc; if (qualifiedName.equals(classDoc.qualifiedName())) { return classDoc; } } } return null; }
/** * Add the index comment. * * @param member the member being documented * @param contentTree the content tree to which the comment will be added */ protected void addIndexComment(Doc member, Content contentTree) { addIndexComment(member, member.firstSentenceTags(), contentTree); }
/** * 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()); }
/** * Generates the "fragment" identifier for the given <var>doc</var>. * <dl> * <dt>{@link FieldDoc}:</dt> * <dd>{@code "#fieldName"}</dd> * <dt>{@link MethodDoc}:</dt> * <dd>{@code "#methodName(java.lang.String,int)"}</dd> * <dt>Other:</dt> * <dd>{@code ""}</dd> * </dl> */ private static String fragmentIdentifier(Doc doc) { if (doc.isField()) return '#' + doc.name(); if (doc.isConstructor()) { ConstructorDoc constructorDoc = (ConstructorDoc) doc; return ( '#' + constructorDoc.containingClass().name() + Html.parameterListForFragmentIdentifier(constructorDoc) ); } if (doc.isMethod()) { MethodDoc methodDoc = (MethodDoc) doc; return '#' + doc.name() + Html.parameterListForFragmentIdentifier(methodDoc); } return ""; }
return doc.isClass() || doc.isInterface() || doc.isAnnotationType();
private static Tag getSingleTagOrNull(Doc taggedDoc, String tagName) { final Tag[] tags = taggedDoc.tags(tagName); if (tags != null && tags.length > 0) { return tags[0]; } return null; }
for (Tag dt : doc.tags("@deprecated")) { htmlText += ( "<div class=\"block\"><span class=\"strong\">Deprecated.</span> <i>" htmlText += this.fromTags(doc.inlineTags(), doc, rootDoc); Tag[] seeTags = doc.tags("@see"); if (seeTags.length == 0) return htmlText;
try { StringBuilder buf = new StringBuilder(); buf.append(getOptions().toHtml(doc.commentText(), fixLeadingSpaces)); buf.append('\n'); for ( Tag tag : doc.tags() ) { processTag(tag, buf); buf.append('\n'); doc.setRawCommentText(buf.toString()); printError(doc.position(), e.getMessage());
if (methodName.equals("isIncluded")) { Doc doc = (Doc) target; return !exclude(doc) && doc.isIncluded();
/** * @return The "description" text for a javadoc-ish summary table; composed from the first sentence of the doc * comment and its (optional) "{@code @deprecated}" tags */ public String summaryDescription(Doc doc, RootDoc rootDoc) { Tag[] dts = doc.tags("@deprecated"); try { if (dts.length == 0) { return this.fromTags(doc.firstSentenceTags(), doc, rootDoc); } else { return ( "<div class=\"block\"><strong>Deprecated.</strong><div class=\"block\"><i>" + this.fromTags(dts[0].inlineTags(), doc, rootDoc) + "</i></div></div>" ); } } catch (Longjump e) { return "???"; } } }
/** * {@inheritDoc} */ public SourcePosition position() { return holder.position(); } }
/** * 输出格式化的注释信息 * * @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; }
+ "\"" + ( to.isOrdinaryClass() ? " title=\"class in " + ((ClassDoc) to).containingPackage().name() + "\"" : to.isInterface() ? " title=\"interface in " + ((ClassDoc) to).containingPackage().name() + "\"" : ""
/** * 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)); }
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(); }
/** * Adds the inline comment. * * @param doc the doc for which the inline comments will be generated * @param htmltree the documentation tree to which the inline comments will be added */ public void addInlineComment(Doc doc, Content htmltree) { addCommentTags(doc, doc.inlineTags(), false, false, htmltree); }
return doc.isClass() || doc.isInterface() || doc.isAnnotationType();