public static void writeModules(String filename) { Data data = makeHDF(); int i = 0; for (PackageInfo pkg : chooseModulePackages()) { data.setValue("reference", "1"); data.setValue("reference.apilevels", sinceTagger.hasVersions() ? "1" : "0"); data.setValue("docs.packages." + i + ".name", pkg.name()); makeModuleListHDF(data, "docs.packages." + i + ".modules", pkg.modules()); for (int j = 0; j < pkg.modules().length; j++) { Data classData = makeHDF(); ClassInfo mod = pkg.modules()[j]; writeModule(mod, classData); } i++; } setPageTitle(data, "Module Index"); TagInfo.makeHDF(data, "root.descr", Converter.convertTags(root.inlineTags(), null)); ClearPage.write(data, "modules.cs", filename); Proofread.writePackages(filename, Converter.convertTags(root.inlineTags(), null)); }
public static PackageInfo[] chooseModulePackages() { ClassInfo[] classes = Converter.rootClasses(); SortedMap<String, PackageInfo> sorted = new TreeMap<String, PackageInfo>(); for (ClassInfo cl : classes) { if (!cl.isModule()) { continue; } PackageInfo pkg = cl.containingPackage(); String name; if (pkg == null) { name = ""; } else { name = pkg.name(); } sorted.put(name, pkg); } ArrayList<PackageInfo> result = new ArrayList<PackageInfo>(); for (String s : sorted.keySet()) { PackageInfo pkg = sorted.get(s); result.add(pkg); } return result.toArray(new PackageInfo[result.size()]); }
public boolean isConsistent(PackageInfo pInfo) { boolean consistent = true; for (ClassInfo cInfo : mClasses.values()) { if (pInfo.mClasses.containsKey(cInfo.name())) { if (!cInfo.isConsistent(pInfo.mClasses.get(cInfo.name()))) { consistent = false; } } else { Errors.error( Errors.REMOVED_CLASS, cInfo.position(), "Removed public class " + cInfo.qualifiedName()); consistent = false; } } for (ClassInfo cInfo : pInfo.mClasses.values()) { if (!mClasses.containsKey(cInfo.name())) { Errors.error( Errors.ADDED_CLASS, cInfo.position(), "Added class " + cInfo.name() + " to package " + pInfo.name()); consistent = false; } } return consistent; }
public static void writeLists() { Data data = makeHDF(); ClassInfo[] classes = Converter.rootClasses(); SortedMap<String, Object> sorted = new TreeMap<String, Object>(); for (ClassInfo cl : classes) { if (cl.isHidden()) { continue; } sorted.put(cl.qualifiedName(), cl); PackageInfo pkg = cl.containingPackage(); String name; if (pkg == null) { name = ""; } else { name = pkg.name(); } sorted.put(name, pkg); for (MethodInfo method : cl.methods()) { if (method.isProcessor() || method.isSource() || method.isTransformer()) { sorted.put(method.elementName(), method); } } } int i = 0; for (String s : sorted.keySet()) { data.setValue("docs.pages." + i + ".id", "" + i); data.setValue("docs.pages." + i + ".label", s); Object o = sorted.get(s); if (o instanceof PackageInfo) { PackageInfo pkg = (PackageInfo) o; data.setValue("docs.pages." + i + ".link", "java/" + pkg.htmlPage()); data.setValue("docs.pages." + i + ".type", "package"); } else if (o instanceof ClassInfo) { ClassInfo cl = (ClassInfo) o; data.setValue("docs.pages." + i + ".link", "java/" + cl.htmlPage()); data.setValue("docs.pages." + i + ".type", "class"); } else if (o instanceof MethodInfo) { MethodInfo mi = (MethodInfo) o; data.setValue("docs.pages." + i + ".id", "" + i); data.setValue("docs.pages." + i + ".link", "mule/" + mi.relativeModulePath()); data.setValue("docs.pages." + i + ".type", "method"); } i++; } ClearPage.write(data, "lists.cs", javadocDir + "lists.js"); }
public static void writeClassLists() { int i; Data data = makePackageHDF(); ClassInfo[] classes = PackageInfo.filterHidden(Converter.convertClasses(root.classes())); if (classes.length == 0) { return; } Sorter[] sorted = new Sorter[classes.length]; for (i = 0; i < sorted.length; i++) { ClassInfo cl = classes[i]; String name = cl.name(); sorted[i] = new Sorter(name, cl); } Arrays.sort(sorted); // make a pass and resolve ones that have the same name int firstMatch = 0; String lastName = sorted[0].label; for (i = 1; i < sorted.length; i++) { String s = sorted[i].label; if (!lastName.equals(s)) { if (firstMatch != i - 1) { // there were duplicates for (int j = firstMatch; j < i; j++) { PackageInfo pkg = ((ClassInfo) sorted[j].data).containingPackage(); if (pkg != null) { sorted[j].label = sorted[j].label + " (" + pkg.name() + ")"; } } } firstMatch = i; lastName = s; } } // and sort again Arrays.sort(sorted); for (i = 0; i < sorted.length; i++) { String s = sorted[i].label; ClassInfo cl = (ClassInfo) sorted[i].data; char first = Character.toUpperCase(s.charAt(0)); cl.makeShortDescrHDF(data, "docs.classes." + first + '.' + i); } setPageTitle(data, "Class Index"); ClearPage.write(data, "classes.cs", javadocDir + "classes" + htmlExtension); }
public static void writePackage(PackageInfo pkg) { // these this and the description are in the same directory, // so it's okay Data data = makePackageHDF(); String name = pkg.name(); data.setValue("package.name", name); data.setValue("package.since.key", SinceTagger.keyForName(pkg.getSince())); data.setValue("package.since.name", pkg.getSince()); data.setValue("package.descr", "...description..."); pkg.setFederatedReferences(data, "package"); makeClassListHDF(data, "package.annotations", ClassInfo.sortByName(pkg.getAnnotations())); makeClassListHDF(data, "package.interfaces", ClassInfo.sortByName(pkg.getInterfaces())); makeClassListHDF(data, "package.classes", ClassInfo.sortByName(pkg.ordinaryClasses())); makeClassListHDF(data, "package.modules", ClassInfo.sortByName(pkg.modules())); makeClassListHDF(data, "package.enums", ClassInfo.sortByName(pkg.enums())); makeClassListHDF(data, "package.exceptions", ClassInfo.sortByName(pkg.exceptions())); makeClassListHDF(data, "package.errors", ClassInfo.sortByName(pkg.errors())); TagInfo[] shortDescrTags = pkg.firstSentenceTags(); TagInfo[] longDescrTags = pkg.inlineTags(); TagInfo.makeHDF(data, "package.shortDescr", shortDescrTags); TagInfo.makeHDF(data, "package.descr", longDescrTags); data.setValue( "package.hasLongDescr", TagInfo.tagsEqual(shortDescrTags, longDescrTags) ? "0" : "1"); String filename = Doclava.javadocDir + pkg.relativePath(); setPageTitle(data, name); ClearPage.write(data, "package.cs", filename); filename = javadocDir + pkg.fullDescriptionFile(); setPageTitle(data, name + " Details"); ClearPage.write(data, "package-descr.cs", filename); Proofread.writePackage(filename, pkg.inlineTags()); }
public static void writePackages(String filename) { Data data = makePackageHDF(); int i = 0; for (PackageInfo pkg : choosePackages()) { writePackage(pkg); data.setValue("docs.packages." + i + ".name", pkg.name()); data.setValue("docs.packages." + i + ".link", pkg.htmlPage()); TagInfo.makeHDF(data, "docs.packages." + i + ".shortDescr", pkg.firstSentenceTags()); i++; } setPageTitle(data, "Package Index"); TagInfo.makeHDF(data, "root.descr", Converter.convertTags(root.inlineTags(), null)); ClearPage.write(data, "packages.cs", filename); ClearPage.write(data, "package-list.cs", javadocDir + "package-list"); Proofread.writePackages(filename, Converter.convertTags(root.inlineTags(), null)); }
public static PackageInfo[] choosePackages() { if (sVisiblePackages != null) { return sVisiblePackages; } ClassInfo[] classes = Converter.rootClasses(); SortedMap<String, PackageInfo> sorted = new TreeMap<String, PackageInfo>(); for (ClassInfo cl : classes) { PackageInfo pkg = cl.containingPackage(); String name; if (pkg == null) { name = ""; } else { name = pkg.name(); } sorted.put(name, pkg); } ArrayList<PackageInfo> result = new ArrayList<PackageInfo>(); for (String s : sorted.keySet()) { PackageInfo pkg = sorted.get(s); if (pkg.isHidden()) { continue; } Boolean allHidden = true; int pass = 0; ClassInfo[] classesToCheck = null; while (pass < 5) { switch (pass) { case 0: classesToCheck = pkg.ordinaryClasses(); break; case 1: classesToCheck = pkg.enums(); break; case 2: classesToCheck = pkg.errors(); break; case 3: classesToCheck = pkg.exceptions(); break; case 4: classesToCheck = pkg.getInterfaces(); break; default: System.err.println("Error reading package: " + pkg.name()); break; } for (ClassInfo cl : classesToCheck) { if (!cl.isHidden()) { allHidden = false; break; } } if (!allHidden) { break; } pass++; } if (allHidden) { continue; } result.add(pkg); } sVisiblePackages = result.toArray(new PackageInfo[result.size()]); return sVisiblePackages; }
public static Data makePackageHDF() { Data data = makeHDF(); ClassInfo[] classes = Converter.rootClasses(); SortedMap<String, PackageInfo> sorted = new TreeMap<String, PackageInfo>(); for (ClassInfo cl : classes) { PackageInfo pkg = cl.containingPackage(); String name; if (pkg == null) { name = ""; } else { name = pkg.name(); } sorted.put(name, pkg); } int i = 0; for (String s : sorted.keySet()) { PackageInfo pkg = sorted.get(s); if (pkg.isHidden()) { continue; } Boolean allHidden = true; int pass = 0; ClassInfo[] classesToCheck = null; while (pass < 5) { switch (pass) { case 0: classesToCheck = pkg.ordinaryClasses(); break; case 1: classesToCheck = pkg.enums(); break; case 2: classesToCheck = pkg.errors(); break; case 3: classesToCheck = pkg.exceptions(); break; case 4: classesToCheck = pkg.getInterfaces(); break; default: System.err.println("Error reading package: " + pkg.name()); break; } for (ClassInfo cl : classesToCheck) { if (!cl.isHidden()) { allHidden = false; break; } } if (!allHidden) { break; } pass++; } if (allHidden) { continue; } data.setValue("reference", "1"); data.setValue("reference.apilevels", sinceTagger.hasVersions() ? "1" : "0"); data.setValue("docs.packages." + i + ".name", s); data.setValue("docs.packages." + i + ".link", pkg.htmlPage()); data.setValue("docs.packages." + i + ".since.key", SinceTagger.keyForName(pkg.getSince())); data.setValue("docs.packages." + i + ".since.name", pkg.getSince()); TagInfo.makeHDF(data, "docs.packages." + i + ".shortDescr", pkg.firstSentenceTags()); i++; } sinceTagger.writeVersionNames(data); return data; }
public int compare(PackageInfo a, PackageInfo b) { return a.name().compareTo(b.name()); }