本文整理汇总了Java中com.sun.javadoc.RootDoc类的典型用法代码示例。如果您正苦于以下问题:Java RootDoc类的具体用法?Java RootDoc怎么用?Java RootDoc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RootDoc类属于com.sun.javadoc包,在下文中一共展示了RootDoc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRootDoc
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
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;
}
示例2: startDoc
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
private boolean startDoc(RootDoc root) throws IOException {
ClassDoc[] classes = root.classes();
String[][] options = root.options();
for (String[] op : options) {
if (op[0].equals("destdir")) {
destDir = op[1];
}
}
for (ClassDoc clazz : classes) {
processClass(clazz);
}
if (errorCount > 0) {
throw new IOException("FAILED: " + errorCount + " errors found");
}
return true;
}
示例3: startGeneration
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
/**
* Start the generation of files. Call generate methods in the individual
* writers, which will in turn genrate the documentation files. Call the
* TreeWriter generation first to ensure the Class Hierarchy is built first
* and then can be used in the later generation.
*
* @see com.sun.javadoc.RootDoc
*/
private void startGeneration(RootDoc root) throws Exception {
if (root.classes().length == 0) {
configuration.message.error("doclet.No_Public_Classes_To_Document");
return;
}
configuration.setOptions();
configuration.getDocletSpecificMsg().notice("doclet.build_version",
configuration.getDocletSpecificBuildDate());
WRDoc wrDoc = new WRDoc(configuration);
generateWRDocFiles(root, wrDoc);
configuration.tagletManager.printReport();
}
示例4: generateIndexFile
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
protected void generateIndexFile(RootDoc root, WRDoc wrDoc)
throws Exception {
List<String> tagList = new ArrayList<String>(wrDoc.getWRTags());
Collator cmp = Collator.getInstance(java.util.Locale.CHINA);
Collections.sort(tagList, cmp);
Map<String, Object> tagMap = new HashMap<String, Object>();
DocData bean = this.generateDocData(wrDoc);
Gson gson = new Gson();
tagMap.put("response", gson.toJson(bean));
tagMap.put("searchengine", this.configurationEx.searchengine);
this.configurationEx
.getWriterFactory()
.getFreemarkerWriter()
.generateHtmlFile("index.ftl", tagMap,
this.configurationEx.destDirName, null);
}
示例5: test
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
void test(boolean withOption) {
System.err.println("Testing " + (withOption ? "with" : "without") + " option");
try {
String dump = "";
RootDoc root = getRootDoc(withOption);
for (ClassDoc cd: root.specifiedClasses()) {
dump += dump(cd);
}
if (dump.contains("lib.Lib2.i")) {
if (!withOption) {
error("control case failed: Lib2 class file was read, unexpectedly, without using option");
}
} else {
if (withOption) {
error("test case failed: could not read Lib2 class file, using option");
}
}
} catch (ClosedFileSystemException e) {
error("Unexpected exception: " + e);
}
System.err.println();
}
示例6: test
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
void test(boolean withOption) {
System.err.println("Testing " + (withOption ? "with" : "without") + " option");
try {
RootDoc root = getRootDoc(withOption);
for (ClassDoc cd: root.specifiedClasses()) {
dump("", cd);
}
if (!withOption) {
error("expected option did not occur");
}
} catch (ClosedFileSystemException e) {
if (withOption) {
error("Unexpected exception: " + e);
} else {
System.err.println("Exception received as expected: " + e);
}
}
System.err.println();
}
示例7: start
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
public static boolean start(final RootDoc root) throws IOException, ClassNotFoundException {
final Options opt = new Options(root.options());
final Map<String, Factory> factories = new HashMap<>();
final Map<String, String> typeAliases = new HashMap<>();
final Map<String, ObjectType> types = loadBuiltInTypes(typeAliases);
final Set<String> builtIns = new HashSet<>(types.keySet());
for(final String factoryName: opt.factoryNames) {
factories.put(factoryName, parseFactory(factoryName, root, types));
}
if(opt.json) { writeJson(opt.outputPath, types, builtIns); }
if(opt.html) { writeHtml(opt.outputPath, types, factories); }
return true;
}
示例8: loadAsResource
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
private static ObjectType loadAsResource(final Class type,
final RootDoc root,
final Map<String, ObjectType> types) {
final String resource = type.getName().replace(".", "/") + ".scripting.json";
System.out.println("LOAD: " + resource);
if(type.getClassLoader() == null) { return null; }
try (final InputStream json = type.getClassLoader().getResourceAsStream(resource)) {
if(json == null) { return null; }
final JsonObject obj =
JsonObject.read(new InputStreamReader(json, java.nio.charset.StandardCharsets.UTF_8));
final ObjectType struct = codec.toStruct(obj);
types.put(type.getName(), struct);
loadImplicitTypes(struct, root, types);
return struct;
} catch (final IOException ioe) {
ioe.printStackTrace();
return null;
}
}
示例9: collectDomainModels
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
@NotNull
private Set<SubDomain> collectDomainModels(final RootDoc root) {
final Set<SubDomain> result = Arrays.stream(root.specifiedPackages())
.map(SubDomain::makeBy)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toSet());
result.forEach(
sd -> {
Arrays.stream(root.specifiedPackages()).forEach(
sd::add
);
}
);
return result;
}
示例10: testNotConstants
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
@Test
public void testNotConstants() throws Exception {
// Token types must be public int constants, which means that they must have
// modifiers public, static, final and type int, because they are referenced statically in
// a lot of different places, must not be changed and an int value is used to encrypt
// a token type.
final ListBuffer<String[]> options = new ListBuffer<String[]>();
options.add(new String[] {"-doclet", "TokenTypesDoclet"});
options.add(new String[] {"-destfile", "target/tokentypes.properties"});
final ListBuffer<String> names = new ListBuffer<String>();
names.add(getPath("InputTokenTypesDocletNotConstants.java"));
final Context context = new Context();
final TestMessager test = new TestMessager(context);
assertNotNull("should be able to create TestMessager without issue", test);
final JavadocTool javadocTool = JavadocTool.make0(context);
final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
assertTrue("Should process valid root doc", TokenTypesDoclet.start(rootDoc));
}
示例11: testEmptyJavadoc
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
@Test
public void testEmptyJavadoc() throws Exception {
final ListBuffer<String[]> options = new ListBuffer<String[]>();
options.add(new String[] {"-destfile", "target/tokentypes.properties"});
final ListBuffer<String> names = new ListBuffer<String>();
names.add(getPath("InputTokenTypesDocletEmptyJavadoc.java"));
final Context context = new Context();
final TestMessager test = new TestMessager(context);
assertNotNull("should be able to create TestMessager without issue", test);
final JavadocTool javadocTool = JavadocTool.make0(context);
final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
try {
TokenTypesDoclet.start(rootDoc);
fail("IllegalArgumentException is expected");
}
catch (IllegalArgumentException expected) {
// Token types must have first sentence of Javadoc summary
// so that a brief description could be provided. Otherwise,
// an IllegalArgumentException is thrown.
}
}
示例12: testCorrect
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
@Test
public void testCorrect() throws Exception {
final ListBuffer<String[]> options = new ListBuffer<String[]>();
options.add(new String[] {"-destfile", "target/tokentypes.properties"});
final ListBuffer<String> names = new ListBuffer<String>();
names.add(getPath("InputTokenTypesDocletCorrect.java"));
final Context context = new Context();
final TestMessager test = new TestMessager(context);
assertNotNull("should be able to create TestMessager without issue", test);
final JavadocTool javadocTool = JavadocTool.make0(context);
final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
assertTrue("Should process valid root doc", TokenTypesDoclet.start(rootDoc));
final String fileContent =
FileUtils.readFileToString(new File("target/tokentypes.properties"),
StandardCharsets.UTF_8);
assertTrue("File content is not expected",
fileContent.startsWith("EOF=The end of file token."));
}
示例13: testJavadocTagPassValidation
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
@Test
public void testJavadocTagPassValidation() throws Exception {
final ListBuffer<String[]> options = new ListBuffer<String[]>();
options.add(new String[] {"-destfile", "target/tokentypes.properties"});
final ListBuffer<String> names = new ListBuffer<String>();
names.add(getPath("InputTokenTypesDocletJavadocParseError.java"));
final Context context = new Context();
final TestMessager test = new TestMessager(context);
assertNotNull("should be able to create TestMessager without issue", test);
final JavadocTool javadocTool = JavadocTool.make0(context);
final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
assertTrue("Should process valid root doc", TokenTypesDoclet.start(rootDoc));
}
示例14: start
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
public static boolean start(RootDoc doc) throws FileNotFoundException, IOException {
if(out == null) out = System.out;
for (ClassDoc cls : doc.classes()) {
Map<String, MethodDoc> allProps = getPropNames(cls);
for (MethodDoc m : cls.methods()) {
String propName = getPropName(m, true);
if (propName != null) {
MethodDoc mDeclaring = allProps.get(propName);
if (mDeclaring != null) {
boolean supported = false;
if (m.name().startsWith("get") || m.name().startsWith("is")) {
supported = m.returnType().equals(mDeclaring.returnType());
} else if (m.name().startsWith("set")) {
supported = m.parameters()[0].type().equals(mDeclaring.returnType());
}
if (supported) {
out.println(cls.qualifiedName() + "." + propName);
}
}
}
}
}
return true;
}
示例15: start
import com.sun.javadoc.RootDoc; //导入依赖的package包/类
/** Specified for the Doclet API */
public static boolean start(RootDoc root) {
PluginConfigDoclet doclet = new PluginConfigDoclet(root);
boolean ok = true;
for (String[] optionArr : root.options()) {
String name = optionArr[0];
OptionName on = OPTION_NAMES.get(name);
if (on != null) {
ImmutableList<String> values = ImmutableList.copyOf(
Arrays.asList(optionArr).subList(1, optionArr.length));
ok &= on.configure(doclet, values);
}
}
doclet.run();
ok &= doclet.okSoFar;
return ok;
}