com.sun.javadoc.Doc类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中com.sun.javadoc.Doc类的一些代码示例,展示了Doc类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Doc类的具体详情如下:
包路径:com.sun.javadoc.Doc
类名称:Doc

Doc介绍

[英]Represents Java language constructs (package, class, constructor, method, field) which have comments and have been processed by this run of javadoc. All Doc objects are unique, that is, they are == comparable.
[中]表示Java语言构造(包、类、构造函数、方法、字段),这些构造包含注释,并已由这次运行的javadoc处理。所有文档对象都是唯一的,即它们是==可比较的。

代码示例

代码示例来源:origin: com.github.linkeer8802/api-resolver-core

private static Tag[] getTag(Doc doc, String name, boolean check) {
  
  Tag[] tags = doc.tags(name);
  
  if (check && tags.length <= 0) {
    throw new IllegalStateException("api doc:Tag[@"+name+"] must requied in position: " + doc.position());
  } 
  
  if (tags.length <= 0) {
    return null;
  } else {
    return tags;
  }
}

代码示例来源:origin: de.smartics.util/project-analysis-javadoc

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;
}

代码示例来源:origin: konsoletyper/teavm-javac

/**
 * 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);
}

代码示例来源:origin: org.asciidoctor/asciidoclet

/**
 * 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());
}

代码示例来源:origin: de.unkrig/de-unkrig-commons

/**
 * 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 "";
}

代码示例来源:origin: ch.cern.hadoop/hadoop-annotations

return doc.isClass() || doc.isInterface() || doc.isAnnotationType();

代码示例来源:origin: io.atlassian.json-schemagen/json-schemagen-scanner

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;
}

代码示例来源:origin: de.unkrig.commons/commons-doclet

for (Tag dt : doc.tags("@deprecated")) {
  htmlText += (
    "<div class=\"block\"><span class=\"strong\">Deprecated.</span>&nbsp;<i>"
htmlText += this.fromTags(doc.inlineTags(), doc, rootDoc);
Tag[] seeTags = doc.tags("@see");
if (seeTags.length == 0) return htmlText;

代码示例来源:origin: ch.raffael.pegdown-doclet/pegdown-doclet

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());

代码示例来源:origin: harbby/presto-connectors

if (methodName.equals("isIncluded")) {
 Doc doc = (Doc) target;
 return !exclude(doc) && doc.isIncluded();

代码示例来源:origin: de.unkrig/de-unkrig-commons

/**
   * @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 "???";
    }
  }
}

代码示例来源:origin: konsoletyper/teavm-javac

/**
   * {@inheritDoc}
   */
  public SourcePosition position() {
    return holder.position();
  }
}

代码示例来源:origin: com.gitee.l0km/swift-service-parser

/**
 * 输出格式化的注释信息
 * 
 * @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;
}

代码示例来源:origin: de.unkrig/de-unkrig-commons

@Override public int
  compare(@Nullable Doc d1, @Nullable Doc d2) {
    if (d1 == null) return d2 == null ? 0 : 1;
    if (d2 == null) return -1;
    return d1.name().compareToIgnoreCase(d2.name());
  }
};

代码示例来源:origin: uk.org.retep.doclet/core

if( holder.isField() && ((FieldDoc) holder).constantValue() != null && htmlWriter instanceof ClassWriterImpl )
      htmlWriter.configuration.getText( "doclet.Constants_Summary" ) ) );
if( holder.isClass() && ((ClassDoc) holder).isSerializable() )

代码示例来源:origin: de.unkrig/de-unkrig-commons

+ "\""
+ (
  to.isOrdinaryClass() ? " title=\"class in "     + ((ClassDoc) to).containingPackage().name() + "\"" :
  to.isInterface()     ? " title=\"interface in " + ((ClassDoc) to).containingPackage().name() + "\"" :
  ""

代码示例来源:origin: broadgsa/gatk

/**
 * 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));
}

代码示例来源:origin: io.atlassian.json-schemagen/json-schemagen-scanner

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();
}

代码示例来源:origin: konsoletyper/teavm-javac

/**
 * 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);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-annotations

return doc.isClass() || doc.isInterface() || doc.isAnnotationType();

相关文章