com.sun.javadoc.PackageDoc Java Examples

The following examples show how to use com.sun.javadoc.PackageDoc. 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: MarkdownDoclet.java    From markdown-doclet with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a prefix for relative URLs from a documentation element relative to the
 * given package. This prefix can be used to refer to the root URL of the
 * documentation:
 *
 * ```java
 * doc = "<script type=\"text/javascript\" src=\""
 *     + rootUrlPrefix(classDoc.containingPackage()) + "highlight.js"
 *     + "\"></script>";
 * ```
 *
 * @param doc    The package containing the element from where to reference the root.
 *
 * @return A URL prefix for URLs referring to the doc root.
 */
public String rootUrlPrefix(PackageDoc doc) {
    if ( doc == null || doc.name().isEmpty() ) {
        return "";
    }
    else {
        StringBuilder buf = new StringBuilder();
        buf.append("../");
        for ( int i = 0; i < doc.name().length(); i++ ) {
            if ( doc.name().charAt(i) == '.' ) {
                buf.append("../");
            }
        }
        return buf.toString();
    }
}
 
Example #2
Source File: MarkdownDoclet.java    From markdown-doclet with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Process the package documentation.
 *
 * @param doc    The package documentation.
 */
protected void processPackage(PackageDoc doc) {
    // (#1) Set foundDoc to false if possible.
    // foundDoc will be set to true when setRawCommentText() is called, if the method
    // is called again, JavaDoc will issue a warning about multiple sources for the
    // package documentation. If there actually *are* multiple sources, the warning
    // has already been issued at this point, we will, however, use it to set the
    // resulting HTML. So, we're setting it back to false here, to suppress the
    // warning.
    try {
        Field foundDoc = doc.getClass().getDeclaredField("foundDoc");
        foundDoc.setAccessible(true);
        foundDoc.set(doc, false);
    }
    catch ( Exception e ) {
        printWarning(doc.position(), "Cannot suppress warning about multiple package sources: " + e + "\n"
                + "Please report this at https://github.com/Abnaxos/markdown-doclet/issues with the exact JavaDoc version you're using");
    }
    defaultProcess(doc, true);
}
 
Example #3
Source File: RootDocProcessor.java    From pom-manipulation-ext with Apache License 2.0 6 votes vote down vote up
private static boolean exclude( Doc doc )
{
    AnnotationDesc[] annotations = null;
    if ( doc instanceof ProgramElementDoc )
    {
        annotations = ( (ProgramElementDoc) doc ).annotations();
    }
    else if ( doc instanceof PackageDoc )
    {
        annotations = ( (PackageDoc) doc ).annotations();
    }
    if ( annotations != null )
    {
        for ( AnnotationDesc annotation : annotations )
        {
            String qualifiedTypeName = annotation.annotationType().qualifiedTypeName();
            if ( qualifiedTypeName.equals( JavadocExclude.class.getCanonicalName() ) )
            {
                return true;
            }
        }
    }
    // nothing above found a reason to exclude
    return false;
}
 
Example #4
Source File: DocPath.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the inverse path for a package.
 * For example, if the package is java.lang,
 * the inverse path is ../...
 */
public static DocPath forRoot(PackageDoc pd) {
    String name = (pd == null) ? "" : pd.name();
    if (name.isEmpty())
        return empty;
    return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
}
 
Example #5
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 #6
Source File: Parser.java    From xml-doclet with Apache License 2.0 5 votes vote down vote up
/**
 * The entry point into parsing the javadoc.
 * 
 * @param rootDoc
 *            The RootDoc intstance obtained via the doclet API
 * @return The root node, containing everything parsed from javadoc doclet
 */
public Root parseRootDoc(RootDoc rootDoc) {
	Root rootNode = objectFactory.createRoot();

	for (ClassDoc classDoc : rootDoc.classes()) {
		PackageDoc packageDoc = classDoc.containingPackage();

		Package packageNode = packages.get(packageDoc.name());
		if (packageNode == null) {
			packageNode = parsePackage(packageDoc);
			packages.put(packageDoc.name(), packageNode);
			rootNode.getPackage().add(packageNode);
		}

		if (classDoc instanceof AnnotationTypeDoc) {
			packageNode.getAnnotation().add(parseAnnotationTypeDoc((AnnotationTypeDoc) classDoc));
		} else if (classDoc.isEnum()) {
			packageNode.getEnum().add(parseEnum(classDoc));
		} else if (classDoc.isInterface()) {
			packageNode.getInterface().add(parseInterface(classDoc));
		} else {
			packageNode.getClazz().add(parseClass(classDoc));
		}
	}

	return rootNode;
}
 
Example #7
Source File: SarlConfiguration.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Reset the list of packages for avoiding duplicates.
 *
 * <p>The inherited implementation uses a HashSet that allow
 * the same package to be stored multiple times. Here,
 * we uses a TreeSet for using the "compareTo" mechanism.
 */
private void resetPackageList() {
	final Set<PackageDoc> set = new TreeSet<>();
       for (final PackageDoc pack : this.root.specifiedPackages()) {
           set.add(pack);
       }
       for (final ClassDoc clazz : this.root.specifiedClasses()) {
           set.add(clazz.containingPackage());
       }
       this.packages = Utils.toArray(this.packages, set);
}
 
Example #8
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Wrap a package doc.
 *
 * @param source the source
 * @return the wrapper.
 */
public PackageDoc[] wrap(PackageDoc[] source) {
	if (source == null) {
		return null;
	}
	final List<PackageDoc> list = new ArrayList<>();
	for (final PackageDoc element : source) {
		if (isIncluded(element)) {
			list.add(wrap(element));
		}
	}
	return Utils.toArray(source, list);
}
 
Example #9
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Wrap a package doc.
 *
 * @param source the source
 * @return the wrapper.
 */
public PackageDoc wrap(PackageDoc source) {
	if (source == null || source instanceof Proxy<?> || !(source instanceof PackageDocImpl)) {
		return source;
	}
	return new PackageDocWrapper((PackageDocImpl) source);
}
 
Example #10
Source File: SarlDoclet.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generatePackageFiles(ClassTree classtree) throws Exception {
	final PackageDoc[] packages = configuration().packages;
	if (packages.length > 1) {
           PackageIndexFrameWriter.generate(configuration());
       }
	PackageDoc prev = null;
	PackageDoc next;
	for (int i = 0; i < packages.length; i++) {
		// if -nodeprecated option is set and the package is marked as
		// deprecated, do not generate the package-summary.html, package-frame.html
		// and package-tree.html pages for that package.
		if (!(configuration().nodeprecated && Util.isDeprecated(packages[i]))) {
			PackageFrameWriter.generate(configuration(), packages[i]);
			next = (i + 1 < packages.length) && (packages[i + 1].name().length() > 0) ? packages[i + 1] : null;
			//If the next package is unnamed package, skip 2 ahead if possible
			next = (i + 2) < packages.length && (next == null) ? packages[i + 2] : next;
			final AbstractBuilder packageSummaryBuilder = configuration()
					.getBuilderFactory().getPackageSummaryBuilder(packages[i], prev, next);
			packageSummaryBuilder.build();
			if (configuration().createtree) {
				PackageTreeWriter.generate(configuration(),
						packages[i], prev, next,
						configuration().nodeprecated);
			}
			prev = packages[i];
		}
	}
}
 
Example #11
Source File: DocPath.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the inverse path for a package.
 * For example, if the package is java.lang,
 * the inverse path is ../...
 */
public static DocPath forRoot(PackageDoc pd) {
    String name = (pd == null) ? "" : pd.name();
    if (name.isEmpty())
        return empty;
    return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
}
 
Example #12
Source File: DocPath.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the inverse path for a package.
 * For example, if the package is java.lang,
 * the inverse path is ../...
 */
public static DocPath forRoot(PackageDoc pd) {
    String name = (pd == null) ? "" : pd.name();
    if (name.isEmpty())
        return empty;
    return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
}
 
Example #13
Source File: DocPath.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the inverse path for a package.
 * For example, if the package is java.lang,
 * the inverse path is ../...
 */
public static DocPath forRoot(PackageDoc pd) {
    String name = (pd == null) ? "" : pd.name();
    if (name.isEmpty())
        return empty;
    return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
}
 
Example #14
Source File: AbstractBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Context(Configuration configuration,
        Set<PackageDoc> containingPackagesSeen,
        LayoutParser layoutParser) {
    this.configuration = configuration;
    this.containingPackagesSeen = containingPackagesSeen;
    this.layoutParser = layoutParser;
}
 
Example #15
Source File: DocPath.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the inverse path for a package.
 * For example, if the package is java.lang,
 * the inverse path is ../...
 */
public static DocPath forRoot(PackageDoc pd) {
    String name = (pd == null) ? "" : pd.name();
    if (name.isEmpty())
        return empty;
    return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
}
 
Example #16
Source File: DocPath.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the inverse path for a package.
 * For example, if the package is java.lang,
 * the inverse path is ../...
 */
public static DocPath forRoot(PackageDoc pd) {
    String name = (pd == null) ? "" : pd.name();
    if (name.isEmpty())
        return empty;
    return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
}
 
Example #17
Source File: DocPath.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the inverse path for a package.
 * For example, if the package is java.lang,
 * the inverse path is ../...
 */
public static DocPath forRoot(PackageDoc pd) {
    String name = (pd == null) ? "" : pd.name();
    if (name.isEmpty())
        return empty;
    return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
}
 
Example #18
Source File: DocPath.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the inverse path for a package.
 * For example, if the package is java.lang,
 * the inverse path is ../...
 */
public static DocPath forRoot(PackageDoc pd) {
    String name = (pd == null) ? "" : pd.name();
    if (name.isEmpty())
        return empty;
    return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
}
 
Example #19
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public PackageDoc containingPackage() {
	return wrap(this.delegate.containingPackage());
}
 
Example #20
Source File: DocCommentProcessor.java    From markdown-doclet with GNU General Public License v3.0 4 votes vote down vote up
private void renderSeeTag(MarkdownDoclet doclet, StringBuilder tagBlock, PsiDocTag docTag) {
    final String seeText = toString(docTag, false);
    if ( seeText.startsWith("\"") ) {
        SeeTag tag = new SeeTag() {
            @Override
            public String label() {
                return null;
            }
            @Override
            public PackageDoc referencedPackage() {
                return null;
            }
            @Override
            public String referencedClassName() {
                return null;
            }
            @Override
            public ClassDoc referencedClass() {
                return null;
            }
            @Override
            public String referencedMemberName() {
                return null;
            }
            @Override
            public MemberDoc referencedMember() {
                return null;
            }
            @Override
            public String name() {
                return "@see";
            }
            @Override
            public Doc holder() {
                return null;
            }
            @Override
            public String kind() {
                return "@see";
            }
            @Override
            public String text() {
                return seeText;
            }
            @Override
            public Tag[] inlineTags() {
                return new Tag[0];
            }
            @Override
            public Tag[] firstSentenceTags() {
                return new Tag[0];
            }
            @Override
            public SourcePosition position() {
                return null;
            }
        };
        SeeTagRenderer.INSTANCE.render(tag, tagBlock, doclet);
    }
    else {
        tagBlock.append("\n@").append(docTag.getName());
        tagBlock.append(' ').append(seeText);
    }
}
 
Example #21
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}.
 * @deprecated no info
 */
@Override
@Deprecated
public PackageDoc[] importedPackages() {
	return wrap(this.delegate.importedPackages());
}
 
Example #22
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc}.
 * @deprecated noinfo
 */
@Override
@Deprecated
public PackageDoc[] importedPackages() {
	return wrap(this.delegate.importedPackages());
}
 
Example #23
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public PackageDoc containingPackage() {
	return wrap(this.delegate.containingPackage());
}
 
Example #24
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public PackageDoc containingPackage() {
	return wrap(this.delegate.containingPackage());
}
 
Example #25
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public PackageDoc containingPackage() {
	return wrap(this.delegate.containingPackage());
}
 
Example #26
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public PackageDoc containingPackage() {
	return wrap(this.delegate.containingPackage());
}
 
Example #27
Source File: ProgrammaticWrappingProxyInstaller.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public PackageDoc containingPackage() {
	return wrap(this.delegate.containingPackage());
}
 
Example #28
Source File: DocPath.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the relative path from one package to another.
 */
public static DocPath relativePath(PackageDoc from, PackageDoc to) {
    return forRoot(from).resolve(forPackage(to));
}
 
Example #29
Source File: DocPath.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the relative path from one package to another.
 */
public static DocPath relativePath(PackageDoc from, PackageDoc to) {
    return forRoot(from).resolve(forPackage(to));
}
 
Example #30
Source File: RootDocWrapper.java    From markdown-doclet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PackageDoc[] specifiedPackages() {
    return delegate.specifiedPackages();
}