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

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

本文整理了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

  1. private static Tag[] getTag(Doc doc, String name, boolean check) {
  2. Tag[] tags = doc.tags(name);
  3. if (check && tags.length <= 0) {
  4. throw new IllegalStateException("api doc:Tag[@"+name+"] must requied in position: " + doc.position());
  5. }
  6. if (tags.length <= 0) {
  7. return null;
  8. } else {
  9. return tags;
  10. }
  11. }

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

  1. private ClassDoc getClassDoc(final Class<?> clazz, final List<Doc> docs)
  2. {
  3. final String qualifiedName = clazz.getName();
  4. for (Doc doc : docs)
  5. {
  6. if (doc.isClass())
  7. {
  8. final ClassDoc classDoc = (ClassDoc) doc;
  9. if (qualifiedName.equals(classDoc.qualifiedName()))
  10. {
  11. return classDoc;
  12. }
  13. }
  14. }
  15. return null;
  16. }

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

  1. /**
  2. * Add the index comment.
  3. *
  4. * @param member the member being documented
  5. * @param contentTree the content tree to which the comment will be added
  6. */
  7. protected void addIndexComment(Doc member, Content contentTree) {
  8. addIndexComment(member, member.firstSentenceTags(), contentTree);
  9. }

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

  1. /**
  2. * Renders a generic document (class, field, method, etc)
  3. *
  4. * @param doc input
  5. */
  6. @Override
  7. public void renderDoc(Doc doc) {
  8. // hide text that looks like tags (such as annotations in source code) from Javadoc
  9. doc.setRawCommentText(doc.getRawCommentText().replaceAll("@([A-Z])", "{@literal @}$1"));
  10. StringBuilder buffer = new StringBuilder();
  11. buffer.append(render(doc.commentText(), false));
  12. buffer.append('\n');
  13. for (Tag tag : doc.tags()) {
  14. renderTag(tag, buffer);
  15. buffer.append('\n');
  16. }
  17. doc.setRawCommentText(buffer.toString());
  18. }

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

  1. /**
  2. * Generates the "fragment" identifier for the given <var>doc</var>.
  3. * <dl>
  4. * <dt>{@link FieldDoc}:</dt>
  5. * <dd>{@code "#fieldName"}</dd>
  6. * <dt>{@link MethodDoc}:</dt>
  7. * <dd>{@code "#methodName(java.lang.String,int)"}</dd>
  8. * <dt>Other:</dt>
  9. * <dd>{@code ""}</dd>
  10. * </dl>
  11. */
  12. private static String
  13. fragmentIdentifier(Doc doc) {
  14. if (doc.isField()) return '#' + doc.name();
  15. if (doc.isConstructor()) {
  16. ConstructorDoc constructorDoc = (ConstructorDoc) doc;
  17. return (
  18. '#'
  19. + constructorDoc.containingClass().name()
  20. + Html.parameterListForFragmentIdentifier(constructorDoc)
  21. );
  22. }
  23. if (doc.isMethod()) {
  24. MethodDoc methodDoc = (MethodDoc) doc;
  25. return '#' + doc.name() + Html.parameterListForFragmentIdentifier(methodDoc);
  26. }
  27. return "";
  28. }

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

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

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

  1. private static Tag getSingleTagOrNull(Doc taggedDoc, String tagName)
  2. {
  3. final Tag[] tags = taggedDoc.tags(tagName);
  4. if (tags != null && tags.length > 0)
  5. {
  6. return tags[0];
  7. }
  8. return null;
  9. }

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

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

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

  1. try {
  2. StringBuilder buf = new StringBuilder();
  3. buf.append(getOptions().toHtml(doc.commentText(), fixLeadingSpaces));
  4. buf.append('\n');
  5. for ( Tag tag : doc.tags() ) {
  6. processTag(tag, buf);
  7. buf.append('\n');
  8. doc.setRawCommentText(buf.toString());
  9. printError(doc.position(), e.getMessage());

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

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

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

  1. /**
  2. * @return The "description" text for a javadoc-ish summary table; composed from the first sentence of the doc
  3. * comment and its (optional) "{@code @deprecated}" tags
  4. */
  5. public String
  6. summaryDescription(Doc doc, RootDoc rootDoc) {
  7. Tag[] dts = doc.tags("@deprecated");
  8. try {
  9. if (dts.length == 0) {
  10. return this.fromTags(doc.firstSentenceTags(), doc, rootDoc);
  11. } else {
  12. return (
  13. "<div class=\"block\"><strong>Deprecated.</strong><div class=\"block\"><i>"
  14. + this.fromTags(dts[0].inlineTags(), doc, rootDoc)
  15. + "</i></div></div>"
  16. );
  17. }
  18. } catch (Longjump e) {
  19. return "???";
  20. }
  21. }
  22. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public SourcePosition position() {
  5. return holder.position();
  6. }
  7. }

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

  1. /**
  2. * 输出格式化的注释信息
  3. *
  4. * @param doc
  5. * {@link com.sun.tools.javadoc.ClassDocImpl} 或 {@link com.sun.tools.javadoc.MethodDocImpl}实例
  6. * @param needIndent
  7. * 是否缩进
  8. * @return
  9. */
  10. public final String formatComment(Doc doc, boolean needIndent) {
  11. Preconditions.checkNotNull(doc, "doc is null");
  12. Type type = typeOfDoc(doc);
  13. StringBuffer buffer = new StringBuffer();
  14. commentText(buffer,doc.commentText(),type);
  15. for (Tag tag : doc.tags()) {
  16. if( ! type.check(excludeTags.get(tag.name())) )
  17. buffer.append(tag.name()).append(" ").append(tag.text()).append('\n');
  18. }
  19. String cmt = buffer.toString();
  20. if (!cmt.isEmpty()) {
  21. cmt = Pattern.compile("\n\\s*", Pattern.MULTILINE).matcher(cmt).replaceAll("\n");
  22. cmt = Pattern.compile("^", Pattern.MULTILINE).matcher(cmt).replaceAll(" * ");
  23. cmt = commentBody.replaceFirst("\n", "$0" + cmt);
  24. if (needIndent)
  25. cmt = Pattern.compile("^", Pattern.MULTILINE).matcher(cmt).replaceAll(indent);
  26. }
  27. return cmt;
  28. }

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

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

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

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

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

  1. + "\""
  2. + (
  3. to.isOrdinaryClass() ? " title=\"class in " + ((ClassDoc) to).containingPackage().name() + "\"" :
  4. to.isInterface() ? " title=\"interface in " + ((ClassDoc) to).containingPackage().name() + "\"" :
  5. ""

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

  1. /**
  2. * Renders all the help text required for a given name.
  3. * @param resourceText resource text properties
  4. * @param elementName element name to use as the key
  5. * @param element Doc element to process.
  6. */
  7. private void renderHelpText(final Properties resourceText, final String elementName, final Doc element) {
  8. StringBuilder summaryBuilder = new StringBuilder();
  9. for(Tag tag: element.firstSentenceTags())
  10. summaryBuilder.append(tag.text());
  11. String summary = summaryBuilder.toString();
  12. String description = element.commentText();
  13. // this might seem unnecessary, but the GATK command line program uses this tag to determine the version when running
  14. if(absoluteVersion != null)
  15. resourceText.setProperty(String.format("%s.%s",elementName,VERSION_TAGLET_NAME),absoluteVersion);
  16. // Write out an alternate element summary, if exists.
  17. resourceText.setProperty(String.format("%s.%s",elementName,SUMMARY_TAGLET_NAME),formatText(summary));
  18. // Write out an alternate description, if present.
  19. resourceText.setProperty(String.format("%s.%s",elementName,DESCRIPTION_TAGLET_NAME),formatText(description));
  20. }

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

  1. private static String getDocWithIncludes(Doc doc)
  2. {
  3. StringBuilder sb = new StringBuilder();
  4. if (!Strings.isNullOrEmpty(doc.commentText()))
  5. {
  6. for (Tag tag : doc.inlineTags())
  7. {
  8. if (tag.kind().equals(TEXT_TAG))
  9. {
  10. sb.append(P).append(tag.text());
  11. }
  12. else if (tag.kind().equals(SEE_TAG))
  13. {
  14. sb.append(getIncludeFromLink((SeeTag) tag));
  15. }
  16. }
  17. //sb.append(doc.commentText()).append(LS).append(LS);
  18. }
  19. String example = getExamples(doc);
  20. if (!Strings.isNullOrEmpty(example))
  21. {
  22. sb.append(example);
  23. }
  24. return sb.toString();
  25. }

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

  1. /**
  2. * Adds the inline comment.
  3. *
  4. * @param doc the doc for which the inline comments will be generated
  5. * @param htmltree the documentation tree to which the inline comments will be added
  6. */
  7. public void addInlineComment(Doc doc, Content htmltree) {
  8. addCommentTags(doc, doc.inlineTags(), false, false, htmltree);
  9. }

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

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

相关文章