类com.sun.javadoc.RootDoc源码实例Demo

下面列出了怎么用com.sun.javadoc.RootDoc的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: swagger-more   文件: SwaggerMoreDoclet.java
public static boolean start(RootDoc rootDoc) {
    // 插件启动入口
    DocLogger.setRootDoc(rootDoc);
    if (StringUtils.isEmpty(classDir)) {
        DocLogger.error("-classDir is not specified.");
        return false;
    }
    DocLogger.info("Writing classes to " + classDir);
    try {
        parseAndAnnotate(rootDoc);
    } catch (Exception e) {
        DocLogger.error(e.getMessage() + "\n" +
                Stream.of(e.getStackTrace()).map(StackTraceElement::toString)
                        .collect(joining("\n")));
        if (nonNull(e.getCause())) {
            DocLogger.error(e.getCause().getMessage() + "\n" +
                    Stream.of(e.getStackTrace()).map(StackTraceElement::toString)
                            .collect(joining("\n")));
        }
    }
    return true;
}
 
源代码2 项目: swagger-more   文件: SwaggerMoreDoclet.java
private static void parseAndAnnotate(RootDoc rootDoc) throws ClassNotFoundException, NotFoundException, CannotCompileException, IOException {
    for (ClassDoc classDoc : rootDoc.classes()) {
        if (StringUtils.isEmpty(classDoc.getRawCommentText())) {
            DocLogger.warn("No javadoc found in class " + classDoc.qualifiedName() + "." + classDoc.name());
        }
        Class clazz = Class.forName(classDoc.qualifiedName());
        ClassPool pool = ClassPool.getDefault();
        pool.insertClassPath(new ClassClassPath(clazz));
        CtClass ctClass = pool.get(clazz.getName());
        ApiInfo apiInfo = ApiInfo.fromClassDoc(clazz, classDoc);
        if (!apiInfo.hidden()) {
            annotateClassAnn(ctClass, apiInfo);
            for (MethodDoc methodDoc : classDoc.methods()) {
                ApiMethodInfo apiMethodInfo = ApiMethodInfo.fromMethodDoc(matchingMethod(clazz, methodDoc), methodDoc);
                if (StringUtils.isEmpty(methodDoc.getRawCommentText())) {
                    DocLogger.warn("No javadoc found in method " + classDoc.qualifiedName() + "." + methodDoc.name() + methodDoc.signature());
                }
                annotateMethodAnn(ctClass, apiMethodInfo);
            }
            DocLogger.info("Successfully annotated " + clazz.getTypeName());
        }
        ctClass.writeFile(classDir);
    }
}
 
源代码3 项目: markdown-doclet   文件: MarkdownDoclet.java
/**
 * Construct a new Markdown Doclet.
 * @param options The command line options.
 * @param rootDoc The root document.
 */
public MarkdownDoclet(Options options, RootDoc rootDoc) {
    this.options = options;
    this.rootDoc = rootDoc;
    tagRenderers.put("@author", SimpleTagRenderer.INSTANCE);
    tagRenderers.put("@version", SimpleTagRenderer.INSTANCE);
    tagRenderers.put("@return", SimpleTagRenderer.INSTANCE);
    tagRenderers.put("@deprecated", SimpleTagRenderer.INSTANCE);
    tagRenderers.put("@since", SimpleTagRenderer.INSTANCE);
    tagRenderers.put("@param", ParamTagRenderer.INSTANCE);
    tagRenderers.put("@throws", ThrowsTagRenderer.INSTANCE);
    tagRenderers.put("@see", SeeTagRenderer.INSTANCE);
    UmlTagRenderer umlTagRenderer = new UmlTagRenderer();
    tagRenderers.put("@uml", umlTagRenderer);
    tagRenderers.put("@startuml", umlTagRenderer);
    tagRenderers.put("@enduml", TagRenderer.ELIDE);
    tagRenderers.put("@todo", new TodoTagRenderer());
}
 
源代码4 项目: openjdk-jdk9   文件: T8147801.java
RootDoc getRootDoc(boolean withOption) {
    List<String> opts = new ArrayList<>();
    if (withOption)
        opts.add("-XDfileManager.deferClose=10");
    opts.add("-doclet");
    opts.add(getClass().getName());
    opts.add("-classpath");
    opts.add(jarPath.toString());
    opts.add(Paths.get(System.getProperty("test.src"), "p", "Test.java").toString());
    System.err.println("javadoc opts: " + opts);
    int rc = com.sun.tools.javadoc.Main.execute(
            "javadoc",
            // by specifying our own class loader, we get the same Class instance as this
            getClass().getClassLoader(),
            opts.toArray(new String[opts.size()]));
    if (rc != 0) {
        error("unexpected exit from javadoc or doclet: " + rc);
    }
    return cachedRoot;
}
 
源代码5 项目: tez   文件: ConfigStandardDoclet.java
public static boolean start(RootDoc root) {
  //look for debug flag
  for (String[] opts : root.options()) {
    for (String opt : opts) {
      if (opt.equals(DEBUG_SWITCH)) {
        debugMode = true;
      }
    }
  }

  logMessage("Running doclet " + ConfigStandardDoclet.class.getSimpleName());
  ClassDoc[] classes = root.classes();
  for (int i = 0; i < classes.length; ++i) {
    processDoc(classes[i]);
  }

  return true;
}
 
源代码6 项目: sarl   文件: SarlDoclet.java
@SuppressWarnings("checkstyle:all")
@Override
public boolean start(AbstractDoclet doclet, RootDoc root) {
	configuration().root = configuration().getProxyInstaller().installProxies(root);
	if (!isValidDoclet(doclet)) {
		return false;
	}
	try {
		Reflect.callProc(this, AbstractDoclet.class, "startGeneration", //$NON-NLS-1$
				new Class[] { RootDoc.class },
				configuration().root);
	} catch (DocletAbortException e) {
		final Throwable cause = Utils.getCause(e);
		if (cause.getLocalizedMessage() != null) {
			configuration().root.printError(cause.getLocalizedMessage());
		} else {
			configuration().root.printError(cause.toString());
		}
		return false;
	} catch (Throwable exc) {
		Utils.getCause(exc).printStackTrace();
		return false;
	}
	return true;
}
 
源代码7 项目: TencentKona-8   文件: Main.java
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
源代码8 项目: jdk8u60   文件: Test.java
public static boolean start(RootDoc root) {
    String text = root.commentText();
    if (text.length() < 64)
        System.err.println("text: '" + text + "'");
    else
        System.err.println("text: '"
                + text.substring(0, 20)
                + "..."
                + text.substring(text.length() - 20)
                + "'");
    return text.startsWith("ABC") && text.endsWith("XYZ");
}
 
源代码9 项目: jdk8u60   文件: Main.java
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
源代码10 项目: jdk8u60   文件: BatchEnvironment.java
/**
 * Creates a new BatchEnvironment with the specified RootDoc.
 **/
public BatchEnvironment(RootDoc rootDoc) {
    this.rootDoc = rootDoc;

    /*
     * Initialize cached ClassDoc for types used by rmic.  Note
     * that any of these could be null if the boot class path is
     * incorrect, which could cause a NullPointerException later.
     */
    docRemote = rootDoc().classNamed(REMOTE);
    docException = rootDoc().classNamed(EXCEPTION);
    docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
    docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
}
 
源代码11 项目: sarl   文件: ProgrammaticWrappingProxyInstaller.java
@Override
public RootDoc installProxies(RootDoc obj) {
	if (obj instanceof RootDocImpl) {
		return new RootDocWrapper((RootDocImpl) obj);
	}
	return obj;
}
 
源代码12 项目: openjdk-jdk8u   文件: Main.java
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
源代码13 项目: openjdk-jdk8u   文件: BatchEnvironment.java
/**
 * Creates a new BatchEnvironment with the specified RootDoc.
 **/
public BatchEnvironment(RootDoc rootDoc) {
    this.rootDoc = rootDoc;

    /*
     * Initialize cached ClassDoc for types used by rmic.  Note
     * that any of these could be null if the boot class path is
     * incorrect, which could cause a NullPointerException later.
     */
    docRemote = rootDoc().classNamed(REMOTE);
    docException = rootDoc().classNamed(EXCEPTION);
    docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
    docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
}
 
源代码14 项目: sarl   文件: ProgrammaticWrappingProxyInstaller.java
@Override
public void installProxies(SarlConfiguration configuration) {
	final RootDoc doc = configuration.root;
	if (!(doc instanceof Proxy) && (doc instanceof RootDocImpl)) {
		configuration.root = new RootDocWrapper((RootDocImpl) doc);
	}
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: Main.java
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
源代码16 项目: openjdk-jdk8u-backup   文件: BatchEnvironment.java
/**
 * Creates a new BatchEnvironment with the specified RootDoc.
 **/
public BatchEnvironment(RootDoc rootDoc) {
    this.rootDoc = rootDoc;

    /*
     * Initialize cached ClassDoc for types used by rmic.  Note
     * that any of these could be null if the boot class path is
     * incorrect, which could cause a NullPointerException later.
     */
    docRemote = rootDoc().classNamed(REMOTE);
    docException = rootDoc().classNamed(EXCEPTION);
    docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
    docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
}
 
源代码17 项目: xml-doclet   文件: Parser.java
/**
 * 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;
}
 
源代码18 项目: openjdk-8   文件: BatchEnvironment.java
/**
 * Creates a new BatchEnvironment with the specified RootDoc.
 **/
public BatchEnvironment(RootDoc rootDoc) {
    this.rootDoc = rootDoc;

    /*
     * Initialize cached ClassDoc for types used by rmic.  Note
     * that any of these could be null if the boot class path is
     * incorrect, which could cause a NullPointerException later.
     */
    docRemote = rootDoc().classNamed(REMOTE);
    docException = rootDoc().classNamed(EXCEPTION);
    docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
    docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
}
 
源代码19 项目: openjdk-jdk9   文件: BatchEnvironment.java
/**
 * Creates a new BatchEnvironment with the specified RootDoc.
 **/
public BatchEnvironment(RootDoc rootDoc) {
    this.rootDoc = rootDoc;

    /*
     * Initialize cached ClassDoc for types used by rmic.  Note
     * that any of these could be null if the boot class path is
     * incorrect, which could cause a NullPointerException later.
     */
    docRemote = rootDoc().classNamed(REMOTE);
    docException = rootDoc().classNamed(EXCEPTION);
    docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
    docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
}
 
源代码20 项目: markdown-doclet   文件: MarkdownDoclet.java
/**
 * As specified by the Doclet specification.
 *
 * @param rootDoc The root doc.
 *
 * @return `true`, if process was successful.
 *
 * @see com.sun.javadoc.Doclet#start(RootDoc)
 */
public static boolean start(RootDoc rootDoc) {
    final MarkdownTaglets markdownTaglets = MarkdownTaglets.instance();
    Options options = new Options();
    String[][] forwardedOptions = options.load(rootDoc.options(), rootDoc);
    if ( forwardedOptions == null ) {
        return false;
    }
    MarkdownDoclet doclet = new MarkdownDoclet(options, rootDoc);
    markdownTaglets.setDocErrorReporter(doclet);
    doclet.process();
    if ( doclet.isError() ) {
        return false;
    }
    RootDocWrapper rootDocWrapper = new RootDocWrapper(rootDoc, forwardedOptions);
    if ( options.isHighlightEnabled() ) {
        // find the footer option
        int i = 0;
        for ( ; i < rootDocWrapper.options().length; i++ ) {
            if ( rootDocWrapper.options()[i][0].equals("-footer") ) {
                rootDocWrapper.options()[i][1] += HIGHLIGHT_JS_HTML;
                break;
            }
        }
        if ( i >= rootDocWrapper.options().length ) {
            rootDocWrapper.appendOption("-footer", HIGHLIGHT_JS_HTML);
        }
    }
    return Standard.start(rootDocWrapper) && doclet.postProcess();
}
 
源代码21 项目: hottub   文件: Main.java
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
源代码22 项目: hottub   文件: BatchEnvironment.java
/**
 * Creates a new BatchEnvironment with the specified RootDoc.
 **/
public BatchEnvironment(RootDoc rootDoc) {
    this.rootDoc = rootDoc;

    /*
     * Initialize cached ClassDoc for types used by rmic.  Note
     * that any of these could be null if the boot class path is
     * incorrect, which could cause a NullPointerException later.
     */
    docRemote = rootDoc().classNamed(REMOTE);
    docException = rootDoc().classNamed(EXCEPTION);
    docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
    docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
}
 
public void generateDoc(Operator op, RootDoc rootDoc, PrintWriter out) {
	ClassDoc opDoc = rootDoc.classNamed(op.getClass().getName());

	// name
	out.println(op.getOperatorDescription().getName());

	// Description
	out.println(transformHTMLJavadocComment(opDoc.commentText(), op.getClass(), op.getOperatorDescription().getName()));

	out.println("#####");
}
 
源代码24 项目: openjdk-8-source   文件: Main.java
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
源代码25 项目: openjdk-8   文件: Main.java
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
源代码26 项目: jdk8u-dev-jdk   文件: BatchEnvironment.java
/**
 * Creates a new BatchEnvironment with the specified RootDoc.
 **/
public BatchEnvironment(RootDoc rootDoc) {
    this.rootDoc = rootDoc;

    /*
     * Initialize cached ClassDoc for types used by rmic.  Note
     * that any of these could be null if the boot class path is
     * incorrect, which could cause a NullPointerException later.
     */
    docRemote = rootDoc().classNamed(REMOTE);
    docException = rootDoc().classNamed(EXCEPTION);
    docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
    docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
}
 
源代码27 项目: jdk8u_jdk   文件: BatchEnvironment.java
/**
 * Creates a new BatchEnvironment with the specified RootDoc.
 **/
public BatchEnvironment(RootDoc rootDoc) {
    this.rootDoc = rootDoc;

    /*
     * Initialize cached ClassDoc for types used by rmic.  Note
     * that any of these could be null if the boot class path is
     * incorrect, which could cause a NullPointerException later.
     */
    docRemote = rootDoc().classNamed(REMOTE);
    docException = rootDoc().classNamed(EXCEPTION);
    docRemoteException = rootDoc().classNamed(REMOTE_EXCEPTION);
    docRuntimeException = rootDoc().classNamed(RUNTIME_EXCEPTION);
}
 
源代码28 项目: swagger-more   文件: DocLogger.java
public static void setRootDoc(RootDoc rootDoc) {
    DocLogger.rootDoc = rootDoc;
}
 
源代码29 项目: dragonwell8_jdk   文件: Main.java
/**
 * Doclet class entry point.
 **/
public static boolean start(RootDoc rootDoc) {

    /*
     * Find batch ID among javadoc options, and retrieve
     * corresponding batch data from global table.
     */
    long batchID = -1;
    for (String[] option : rootDoc.options()) {
        if (option[0].equals("-batchID")) {
            try {
                batchID = Long.parseLong(option[1]);
            } catch (NumberFormatException e) {
                throw new AssertionError(e);
            }
        }
    }
    Batch batch = batchTable.get(batchID);
    assert batch != null;

    /*
     * Construct batch environment using class agreed upon by
     * generator implementations.
     */
    BatchEnvironment env;
    try {
        Constructor<? extends BatchEnvironment> cons =
            batch.envClass.getConstructor(new Class<?>[] { RootDoc.class });
        env = cons.newInstance(rootDoc);
    } catch (NoSuchMethodException e) {
        throw new AssertionError(e);
    } catch (IllegalAccessException e) {
        throw new AssertionError(e);
    } catch (InstantiationException e) {
        throw new AssertionError(e);
    } catch (InvocationTargetException e) {
        throw new AssertionError(e);
    }

    env.setVerbose(batch.verbose);

    /*
     * Determine the destination directory (the top of the package
     * hierarchy) for the output of this batch; if no destination
     * directory was specified on the command line, then the
     * default is the current working directory.
     */
    File destDir = batch.destDir;
    if (destDir == null) {
        destDir = new File(System.getProperty("user.dir"));
    }

    /*
     * Run each input class through each generator.
     */
    for (String inputClassName : batch.classes) {
        ClassDoc inputClass = rootDoc.classNamed(inputClassName);
        try {
            for (Generator gen : batch.generators) {
                gen.generate(env, inputClass, destDir);
            }
        } catch (NullPointerException e) {
            /*
             * We assume that this means that some class that was
             * needed (perhaps even a bootstrap class) was not
             * found, and that javadoc has already reported this
             * as an error.  There is nothing for us to do here
             * but try to continue with the next input class.
             *
             * REMIND: More explicit error checking throughout
             * would be preferable, however.
             */
        }
    }

    /*
     * Compile any generated source files, if configured to do so.
     */
    boolean status = true;
    List<File> generatedFiles = env.generatedFiles();
    if (!batch.noCompile && !batch.noWrite && !generatedFiles.isEmpty()) {
        status = batch.enclosingMain().invokeJavac(batch, generatedFiles);
    }

    /*
     * Delete any generated source files, if configured to do so.
     */
    if (!batch.keepGenerated) {
        for (File file : generatedFiles) {
            file.delete();
        }
    }

    return status;
}
 
源代码30 项目: TencentKona-8   文件: GetTask_DocletClassTest.java
public static boolean start(RootDoc root) {
    lastCaller = root.classNamed("pkg.C").commentText().trim();
    return true;
}