com.sun.javadoc.Doc.firstSentenceTags()方法的使用及代码示例

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

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

Doc.firstSentenceTags介绍

[英]Return the first sentence of the comment as an array of tags. Includes inline tags (i.e. {@link reference} tags) but not block tags. Each section of plain text is represented as a Tagof Tag#kind() "Text". Inline tags are represented as a SeeTag of kind "@see" and name "@link".

If the locale is English language, the first sentence is determined by the rules described in the Java Language Specification (first version): "This sentence ends at the first period that is followed by a blank, tab, or line terminator or at the first tagline.", in addition a line will be terminated by block HTML tags: <p> </p> <h1> <h2> <h3> <h4> <h5> <h6> <hr> <pre> or </pre>. If the locale is not English, the sentence end will be determined by BreakIterator#getSentenceInstance(Locale).
[中]将注释的第一句作为标记数组返回。包括内联标记(即{@link reference}标记),但不包括块标记。纯文本的每一部分都表示为Tagof标记#kind()“text”。内联标记表示为类型为“@see”和名称为“@link”的SeeTag。
如果语言环境是英语,则第一句话由Java语言规范(第一版)中描述的规则确定:“此句在第一个句点结束,后面是空白、制表符或行结束符,或在第一个标记行结束。”,此外,一行将由块HTML标记终止:<p><p><h1><h2><h3><h4><h5><h6><hr><pre>或</pre>。如果语言环境不是英语,句子的结尾将由BreakIterator#getSentenceInstance(语言环境)确定。

代码示例

代码示例来源: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: konsoletyper/teavm-javac

/**
 * Adds the summary content.
 *
 * @param doc the doc for which the summary will be generated
 * @param htmltree the documentation tree to which the summary will be added
 */
public void addSummaryComment(Doc doc, Content htmltree) {
  addSummaryComment(doc, doc.firstSentenceTags(), htmltree);
}

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

public void printSummaryComment( Doc doc )
{
  printSummaryComment( doc, doc.firstSentenceTags() );
}

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

public void printSummaryDeprecatedComment( Doc doc )
{
  printCommentTags( doc, doc.firstSentenceTags(), true, true );
}

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

protected void printIndexComment(Doc member) {
  printIndexComment(member, member.firstSentenceTags());
}

代码示例来源:origin: org.apache.axis2/axis2-transport-testkit

private static String getFirstSentence(Doc doc) {
  Tag[] tags = doc.firstSentenceTags();
  if (tags.length == 0) {
    return null;
  }
  StringBuilder buffer = new StringBuilder();
  for (Tag tag : tags) {
    if (tag instanceof SeeTag) {
      buffer.append("{");
      buffer.append(tag.name());
      buffer.append(" ");
      buffer.append(((SeeTag)tag).referencedClassName());
      buffer.append("}");
    } else {
      buffer.append(tag.text());
    }
  }
  return buffer.toString();
}

代码示例来源:origin: org.apache.axis2.transport/axis2-transport-testkit

private static String getFirstSentence(Doc doc) {
  Tag[] tags = doc.firstSentenceTags();
  if (tags.length == 0) {
    return null;
  }
  StringBuilder buffer = new StringBuilder();
  for (Tag tag : tags) {
    if (tag instanceof SeeTag) {
      buffer.append("{");
      buffer.append(tag.name());
      buffer.append(" ");
      buffer.append(((SeeTag)tag).referencedClassName());
      buffer.append("}");
    } else {
      buffer.append(tag.text());
    }
  }
  return buffer.toString();
}

代码示例来源:origin: apache/axis2-java

private static String getFirstSentence(Doc doc) {
  Tag[] tags = doc.firstSentenceTags();
  if (tags.length == 0) {
    return null;
  }
  StringBuilder buffer = new StringBuilder();
  for (Tag tag : tags) {
    if (tag instanceof SeeTag) {
      buffer.append("{");
      buffer.append(tag.name());
      buffer.append(" ");
      buffer.append(((SeeTag)tag).referencedClassName());
      buffer.append("}");
    } else {
      buffer.append(tag.text());
    }
  }
  return buffer.toString();
}

代码示例来源: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: uk.org.retep.doclet/core

DocFinder.search(new DocFinder.Input((MethodDoc) member));
if (inheritedDoc.holder != null &&
    inheritedDoc.holder.firstSentenceTags().length > 0) {
  firstSentenceTags = inheritedDoc.holder.firstSentenceTags();

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

DocFinder.search(new DocFinder.Input((MethodDoc) member));
if (inheritedDoc.holder != null
    && inheritedDoc.holder.firstSentenceTags().length > 0) {
  firstSentenceTags = inheritedDoc.holder.firstSentenceTags();

代码示例来源: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: de.unkrig.commons/commons-doclet

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

相关文章