com.sun.javadoc.Tag Java Examples

The following examples show how to use com.sun.javadoc.Tag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLExampleTaglet.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
public String toString(Tag tag) {
	String[] splitted = split(tag);
	if (splitted == null)
		return "";
	File file = resolve(splitted[0], tag.position());
	String contents = null;
	if (file.exists()) {
		try {
			contents = Tools.readTextFile(file);
			contents = contents.replaceAll("<", "&lt;");
			contents = contents.replaceAll(">", "&gt;");
		} catch (IOException e) {
			contents = "Cannot read file '" + file + "': " + e;
			System.err.println(tag.position() + ": cannot read file '" + file + "'!");
		}
	} else {
		contents = "File '" + file + "' does not exist!";
		System.err.println(tag.position() + ": File '" + file + "' does not exist!");
	}
	return "<pre>" + contents + "</pre><br><center><i>Figure:</i> " + splitted[2] + "</center>";
}
 
Example #2
Source File: SpecificationTaglet.java    From kodkod with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Content getTagletOutput(Doc doc, TagletWriter writer) throws IllegalArgumentException {
	Tag[] tags = doc.tags(getName());
	if (tags.length==0 && doc instanceof MethodDoc) { // inherit if necessary and possible
		final DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) doc, this));
		tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
	}
	if (tags.length==0)
		return null;
	final StringBuilder out = writeHeader(new StringBuilder());
	for(Tag tag : tags) { 
		writeTag(out, tag, writer);
	}
	return new RawHtml(out.toString());
}
 
Example #3
Source File: SpecificationTaglet.java    From org.alloytools.alloy with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#getTagletOutput(com.sun.javadoc.Doc, com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter)
 */
@Override
public TagletOutput getTagletOutput(Doc doc, TagletWriter writer) throws IllegalArgumentException {
	Tag[] tags = doc.tags(getName());
	if (tags.length==0 && doc instanceof MethodDoc) { // inherit if necessary and possible
		final DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) doc, this));
		tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
	}
	if (tags.length==0)
		return null;
	final StringBuilder out = writeHeader(new StringBuilder());
	for(Tag tag : tags) { 
		writeTag(out, tag, writer);
	}
	return new TagletOutputImpl(out.toString());
}
 
Example #4
Source File: DocTestSuite.java    From joinery with GNU General Public License v3.0 6 votes vote down vote up
public static boolean start(final RootDoc root) {
    for (final ClassDoc cls : root.classes()) {
        final List<ProgramElementDoc> elements = new LinkedList<>();
        elements.add(cls);
        elements.addAll(Arrays.asList(cls.constructors()));
        elements.addAll(Arrays.asList(cls.methods()));
        for (final ProgramElementDoc elem : elements) {
            for (final Tag tag : elem.inlineTags()) {
                final String name = tag.name();
                if (name.equals("@code") && tag.text().trim().startsWith(">")) {
                    generateRunner(cls, elem, tag);
                }
            }
        }
    }
    return true;
}
 
Example #5
Source File: Parser.java    From xml-doclet with Apache License 2.0 6 votes vote down vote up
/**
 * Parses an enum type definition
 * 
 * @param fieldDoc
 * @return
 */
protected EnumConstant parseEnumConstant(FieldDoc fieldDoc) {
	EnumConstant enumConstant = objectFactory.createEnumConstant();
	enumConstant.setName(fieldDoc.name());
	String comment = fieldDoc.commentText();
	if (comment.length() > 0) {
		enumConstant.setComment(comment);
	}

	for (AnnotationDesc annotationDesc : fieldDoc.annotations()) {
		enumConstant.getAnnotation().add(parseAnnotationDesc(annotationDesc, fieldDoc.qualifiedName()));
	}

	for (Tag tag : fieldDoc.tags()) {
		enumConstant.getTag().add(parseTag(tag));
	}

	return enumConstant;
}
 
Example #6
Source File: Parser.java    From xml-doclet with Apache License 2.0 6 votes vote down vote up
protected Field parseField(FieldDoc fieldDoc) {
	Field fieldNode = objectFactory.createField();
	fieldNode.setType(parseTypeInfo(fieldDoc.type()));
	fieldNode.setName(fieldDoc.name());
	fieldNode.setQualified(fieldDoc.qualifiedName());
	String comment = fieldDoc.commentText();
	if (comment.length() > 0) {
		fieldNode.setComment(comment);
	}
	fieldNode.setScope(parseScope(fieldDoc));
	fieldNode.setFinal(fieldDoc.isFinal());
	fieldNode.setStatic(fieldDoc.isStatic());
	fieldNode.setVolatile(fieldDoc.isVolatile());
	fieldNode.setTransient(fieldDoc.isTransient());
	fieldNode.setConstant(fieldDoc.constantValueExpression());

	for (AnnotationDesc annotationDesc : fieldDoc.annotations()) {
		fieldNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, fieldDoc.qualifiedName()));
	}

	for (Tag tag : fieldDoc.tags()) {
		fieldNode.getTag().add(parseTag(tag));
	}

	return fieldNode;
}
 
Example #7
Source File: BaleenJavadoc.java    From baleen with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(Tag[] tags) {
  if (tags.length == 0) {
    return null;
  }

  ClassDoc classDoc = (ClassDoc) tags[0].holder();

  return processExternalResources(classDoc) + processConfigurationParameters(classDoc);
}
 
Example #8
Source File: MarkdownDoclet.java    From markdown-doclet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Default processing of any documentation node.
 *
 * @param doc              The documentation.
 * @param fixLeadingSpaces `true` if leading spaces should be fixed.
 *
 * @see Options#toHtml(String, boolean)
 */
protected void defaultProcess(Doc doc, boolean fixLeadingSpaces) {
    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());
    }
    catch ( final ParserRuntimeException e ) {
        if ( doc instanceof RootDoc ) {
            printError(new SourcePosition() {
                @Override
                public File file() {
                    return options.getOverviewFile();
                }
                @Override
                public int line() {
                    return 0;
                }
                @Override
                public int column() {
                    return 0;
                }
            }, e.getMessage());
        }
        else {
            printError(doc.position(), e.getMessage());
        }
    }
}
 
Example #9
Source File: FieldDocumentation.java    From spring-auto-restdocs with Apache License 2.0 5 votes vote down vote up
public static FieldDocumentation fromFieldDoc(FieldDoc fieldDoc) {
    FieldDocumentation fd = new FieldDocumentation();
    fd.comment = fieldDoc.commentText();

    for (Tag tag : fieldDoc.tags()) {
        fd.tags.put(cleanupTagName(tag.name()), tag.text());
    }

    return fd;
}
 
Example #10
Source File: ReferenceTaglet.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
public String toString(Tag[] tags) {
	if (tags.length == 0) {
		return null;
	}
	String result = "<dt><b>Bibliography:</b></dt><dd>";
	result += "<ul>";
	for (int i = 0; i < tags.length; i++) {
		String key = tags[i].text().trim();
		String entry = getBibEntry(key);
		result += "<li>" + ((entry != null) ? entry : key) + "</li>";
	}
	result += "</ul></dd>";
	return result;
}
 
Example #11
Source File: SpecificationTaglet.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void inherit(DocFinder.Input input, DocFinder.Output output) {
	if (input.element != null && input.element.isMethod()) {
		final Tag[] tags = input.element.tags(tagName);
		if (tags.length > 0) {
			output.holder = input.element;
			output.holderTag = tags[0];
			output.inlineTags = input.isFirstSentence ?
					tags[0].firstSentenceTags() : tags[0].inlineTags();
		} 
	} 
}
 
Example #12
Source File: DumpJavaDoc.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static boolean start(RootDoc root) throws IOException {
    String dumpFileName = readOptions(root.options());
    OutputStream os = Files.newOutputStream(Paths.get(dumpFileName));
    Properties javaDocMap = new Properties();
    for (ClassDoc classDoc : root.classes()) {
        javaDocMap.put(classDoc.toString(), classDoc.commentText());
        for (MethodDoc method : classDoc.methods()) {
            javaDocMap.put(method.qualifiedName(), method.commentText());
            for (ParamTag paramTag : method.paramTags()) {
                Parameter[] parameters = method.parameters();
                for (int i = 0; i < parameters.length; ++i) {
                    if (parameters[i].name().equals(paramTag.parameterName())) {
                        javaDocMap.put(method.qualifiedName() + ".paramCommentTag." + i,
                               paramTag.parameterComment());
                    }
                }
            }
            Tag[] retTags = method.tags("return");
            if (retTags != null && retTags.length == 1) {
                Tag retTag = method.tags("return")[0];
                javaDocMap.put(method.qualifiedName() + "." + "returnCommentTag",
                               retTag.text());
            }
        }

    }
    javaDocMap.store(os, "");
    os.flush();
    os.close();
    return true;
}
 
Example #13
Source File: Parser.java    From xml-doclet with Apache License 2.0 5 votes vote down vote up
protected Package parsePackage(PackageDoc packageDoc) {
	Package packageNode = objectFactory.createPackage();
	packageNode.setName(packageDoc.name());
	String comment = packageDoc.commentText();
	if (comment.length() > 0) {
		packageNode.setComment(comment);
	}

	for (Tag tag : packageDoc.tags()) {
		packageNode.getTag().add(parseTag(tag));
	}

	return packageNode;
}
 
Example #14
Source File: DocTaglet.java    From mongo-java-driver-reactivestreams with Apache License 2.0 5 votes vote down vote up
public String toString(final Tag[] tags) {
    if (tags.length == 0) {
        return null;
    }

    StringBuilder buf = new StringBuilder(String.format("\n<dl><dt><span class=\"strong\">%s</span></dt>\n", getHeader()));
    for (Tag t : tags) {
        buf.append("   <dd>").append(genLink(t.text())).append("</dd>\n");
    }
    return buf.toString();
}
 
Example #15
Source File: MarkdownDoclet.java    From markdown-doclet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Process a tag.
 *
 * @param tag      The tag.
 * @param target   The target string builder.
 */
@SuppressWarnings("unchecked")
protected void processTag(Tag tag, StringBuilder target) {
    TagRenderer<Tag> renderer = (TagRenderer<Tag>)tagRenderers.get(tag.kind());
    if ( renderer == null ) {
        renderer = TagRenderer.VERBATIM;
    }
    renderer.render(tag, target, this);
}
 
Example #16
Source File: XMLExampleTaglet.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
public String toTex(Tag tag) {
	String[] splitted = split(tag);
	if (splitted == null)
		return "";
	File file = resolve(splitted[0], tag.position());
	if (!file.exists()) {
		System.err.println(tag.position() + ": File '" + file + "' does not exist!");
		return "";
	} else {
		return "\\examplefile{" + file.getAbsolutePath() + "}{" + splitted[1] + "}{" + splitted[2] + "}";
	}
}
 
Example #17
Source File: AbstractBaleenTaglet.java    From baleen with Apache License 2.0 5 votes vote down vote up
@Override
public String toString(Tag tag) {
  Tag[] tags = new Tag[1];
  tags[0] = tag;

  return toString(tags);
}
 
Example #18
Source File: MethodDocumentation.java    From spring-auto-restdocs with Apache License 2.0 5 votes vote down vote up
public static MethodDocumentation fromMethodDoc(MethodDoc methodDoc) {
    MethodDocumentation md = new MethodDocumentation();
    md.comment = methodDoc.commentText();

    for (Tag tag : methodDoc.tags()) {
        if (tag instanceof ParamTag) {
            ParamTag paramTag = (ParamTag) tag;
            md.parameters.put(paramTag.parameterName(), paramTag.parameterComment());
        } else {
            md.tags.put(cleanupTagName(tag.name()), tag.text());
        }
    }

    return md;
}
 
Example #19
Source File: SpecificationTaglet.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Appends the formatted definition tag to the given buffer.
 * @return out
 */
private StringBuilder writeTag(StringBuilder out, Tag tag, TagletWriter writer) {
	return out.append(DocletConstants.NL)
			.append("<DD><CODE>")
			.append(writer.commentTagsToOutput(tag, null, tag.inlineTags(), false))
			.append("</CODE></DD>");
}
 
Example #20
Source File: SpecificationTaglet.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @see com.sun.tools.doclets.internal.toolkit.taglets.InheritableTaglet#inherit(com.sun.tools.doclets.internal.toolkit.util.DocFinder.Input, com.sun.tools.doclets.internal.toolkit.util.DocFinder.Output)
 */
@Override
public void inherit(Input input, Output output) {
	if (input.method != null) {
		final Tag[] tags = input.method.tags(tagName);
		if (tags.length > 0) {
			output.holder = input.method;
			output.holderTag = tags[0];
			output.inlineTags = input.isFirstSentence ?
					tags[0].firstSentenceTags() : tags[0].inlineTags();
		} 
	} 
}
 
Example #21
Source File: PSOperatorDoc.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
private PSOperatorDoc(ClassDoc classDoc, MethodDoc methodDoc) {
        this.declaringClassDoc = classDoc;
        this.methodDoc = methodDoc;
        this.description = methodDoc.commentText().replace('\n', ' ');
        this.paramDesc = "";

        Tag[] paramTags = methodDoc.tags("param");
        for (Tag paramTag : paramTags) {
            String paraStr = paramTag.text();
            String paraName = paraStr.substring(0, paraStr.indexOf(' ')).replace('\n', ' ');;
            String paraDesc = paraStr.substring(paraStr.indexOf(' ') + 1).replace('\n', ' ');;
            this.paramDesc += "<br> - `" + paraName + "`: " + paraDesc;
        }

        this.returnType = methodDoc.returnType();
//        ParameterizedType returnType = methodDoc.returnType().asParameterizedType();
//        this.inputType = returnType.typeArguments()[0];
//        this.outputType = returnType.typeArguments()[1];
//        this.completeSignature = "Function<" + this.inputType + ", " + this.outputType + "> " + methodDoc.toString();

        String shortSignature = classDoc.name() + "." + methodDoc.name() + "(";
        boolean firstParameter = true;
        for (Parameter parameter : methodDoc.parameters()) {
            if (firstParameter) {
                shortSignature += Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
                firstParameter = false;
            } else {
                shortSignature += ", " + Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
            }
        }
        shortSignature += ")";
        this.shortSignature = shortSignature;
    }
 
Example #22
Source File: Parser.java    From xml-doclet with Apache License 2.0 5 votes vote down vote up
protected Constructor parseConstructor(ConstructorDoc constructorDoc) {
	Constructor constructorNode = objectFactory.createConstructor();

	constructorNode.setName(constructorDoc.name());
	constructorNode.setQualified(constructorDoc.qualifiedName());
	String comment = constructorDoc.commentText();
	if (comment.length() > 0) {
		constructorNode.setComment(comment);
	}
	constructorNode.setScope(parseScope(constructorDoc));
	constructorNode.setIncluded(constructorDoc.isIncluded());
	constructorNode.setFinal(constructorDoc.isFinal());
	constructorNode.setNative(constructorDoc.isNative());
	constructorNode.setStatic(constructorDoc.isStatic());
	constructorNode.setSynchronized(constructorDoc.isSynchronized());
	constructorNode.setVarArgs(constructorDoc.isVarArgs());
	constructorNode.setSignature(constructorDoc.signature());

	for (Parameter parameter : constructorDoc.parameters()) {
		constructorNode.getParameter().add(parseMethodParameter(parameter));
	}

	for (Type exceptionType : constructorDoc.thrownExceptionTypes()) {
		constructorNode.getException().add(parseTypeInfo(exceptionType));
	}

	for (AnnotationDesc annotationDesc : constructorDoc.annotations()) {
		constructorNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, constructorDoc.qualifiedName()));
	}

	for (Tag tag : constructorDoc.tags()) {
		constructorNode.getTag().add(parseTag(tag));
	}

	return constructorNode;
}
 
Example #23
Source File: Parser.java    From xml-doclet with Apache License 2.0 5 votes vote down vote up
protected Interface parseInterface(ClassDoc classDoc) {

		Interface interfaceNode = objectFactory.createInterface();
		interfaceNode.setName(classDoc.name());
		interfaceNode.setQualified(classDoc.qualifiedName());
		String comment = classDoc.commentText();
		if (comment.length() > 0) {
			interfaceNode.setComment(comment);
		}
		interfaceNode.setIncluded(classDoc.isIncluded());
		interfaceNode.setScope(parseScope(classDoc));

		for (TypeVariable typeVariable : classDoc.typeParameters()) {
			interfaceNode.getGeneric().add(parseTypeParameter(typeVariable));
		}

		for (Type interfaceType : classDoc.interfaceTypes()) {
			interfaceNode.getInterface().add(parseTypeInfo(interfaceType));
		}

		for (MethodDoc method : classDoc.methods()) {
			interfaceNode.getMethod().add(parseMethod(method));
		}

		for (AnnotationDesc annotationDesc : classDoc.annotations()) {
			interfaceNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, classDoc.qualifiedName()));
		}

		for (Tag tag : classDoc.tags()) {
			interfaceNode.getTag().add(parseTag(tag));
		}

		for (FieldDoc field : classDoc.fields()) {
			interfaceNode.getField().add(parseField(field));
		}

		return interfaceNode;
	}
 
Example #24
Source File: XMLExampleTaglet.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private String[] split(Tag tag) {
	String[] result = tag.text().split("\\|");
	if (result.length != 3) {
		System.err.println("Usage: {@" + getName() + " filename|label|caption} (was: " + tag.text() + ") (" + tag.position() + ")");
		return null;
	}
	return result;
}
 
Example #25
Source File: RootDocWrapper.java    From markdown-doclet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Tag[] tags(String tagname) {
    return delegate.tags(tagname);
}
 
Example #26
Source File: CiteTaglet.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
public String toTex(Tag tag) {
	return "\\cite{" + tag.text() + "}";
}
 
Example #27
Source File: XMLExampleTaglet.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
public String toTex(Tag[] tag) {
	return null;
}
 
Example #28
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public Tag[] tags() {
	return this.delegate.tags();
}
 
Example #29
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public Tag[] tags(String arg0) {
	return this.delegate.tags(arg0);
}
 
Example #30
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public Tag[] tags(String arg0) {
	return this.delegate.tags(arg0);
}