/**
   * Constructor.
   *
   * @param filename the file to be generated.
   * @throws IOException
   * @throws DocletAbortException
   */
  public PackageUseWriter(
      ConfigurationImpl configuration, ClassUseMapper mapper, DocPath filename, PackageDoc pkgdoc)
      throws IOException {
    super(configuration, DocPath.forPackage(pkgdoc).resolve(filename));
    this.pkgdoc = pkgdoc;

    // by examining all classes in this package, find what packages
    // use these classes - produce a map between using package and
    // used classes.
    ClassDoc[] content = pkgdoc.allClasses();
    for (int i = 0; i < content.length; ++i) {
      ClassDoc usedClass = content[i];
      Set<ClassDoc> usingClasses = mapper.classToClass.get(usedClass.qualifiedName());
      if (usingClasses != null) {
        for (Iterator<ClassDoc> it = usingClasses.iterator(); it.hasNext(); ) {
          ClassDoc usingClass = it.next();
          PackageDoc usingPackage = usingClass.containingPackage();
          Set<ClassDoc> usedClasses = usingPackageToUsedClasses.get(usingPackage.name());
          if (usedClasses == null) {
            usedClasses = new TreeSet<ClassDoc>();
            usingPackageToUsedClasses.put(Util.getPackageName(usingPackage), usedClasses);
          }
          usedClasses.add(usedClass);
        }
      }
    }
  }
 /**
  * Add the list of classes that use the given package.
  *
  * @param contentTree the content tree to which the class list will be added
  */
 protected void addClassList(Content contentTree) throws IOException {
   String[] classTableHeader =
       new String[] {
         configuration.getText(
             "doclet.0_and_1",
             configuration.getText("doclet.Class"),
             configuration.getText("doclet.Description"))
       };
   Iterator<String> itp = usingPackageToUsedClasses.keySet().iterator();
   while (itp.hasNext()) {
     String packageName = itp.next();
     PackageDoc usingPackage = configuration.root.packageNamed(packageName);
     HtmlTree li = new HtmlTree(HtmlTag.LI);
     li.addStyle(HtmlStyle.blockList);
     if (usingPackage != null) {
       li.addContent(getMarkerAnchor(usingPackage.name()));
     }
     String tableSummary =
         configuration.getText(
             "doclet.Use_Table_Summary", configuration.getText("doclet.classes"));
     Content table =
         HtmlTree.TABLE(
             HtmlStyle.useSummary,
             0,
             3,
             0,
             tableSummary,
             getTableCaption(
                 configuration.getResource(
                     "doclet.ClassUse_Classes.in.0.used.by.1",
                     getPackageLink(pkgdoc, Util.getPackageName(pkgdoc)),
                     getPackageLink(usingPackage, Util.getPackageName(usingPackage)))));
     table.addContent(getSummaryTableHeader(classTableHeader, "col"));
     Content tbody = new HtmlTree(HtmlTag.TBODY);
     Iterator<ClassDoc> itc = usingPackageToUsedClasses.get(packageName).iterator();
     for (int i = 0; itc.hasNext(); i++) {
       HtmlTree tr = new HtmlTree(HtmlTag.TR);
       if (i % 2 == 0) {
         tr.addStyle(HtmlStyle.altColor);
       } else {
         tr.addStyle(HtmlStyle.rowColor);
       }
       addClassRow(itc.next(), packageName, tr);
       tbody.addContent(tr);
     }
     table.addContent(tbody);
     li.addContent(table);
     contentTree.addContent(li);
   }
 }
Пример #3
0
 @Override
 protected void registerAdditionalKeyboardShortcuts() throws IOException {
   if (rootPackageDoc != null) {
     rootPackageDoc.registerAdditionalKeyboardShortcuts();
     keyboardShortcuts.putAll(rootPackageDoc.keyboardShortcuts);
   }
 }
 /**
  * Build the package serialized form for the current package being processed.
  *
  * @param node the XML element that specifies which components to document
  * @param serializedSummariesTree content tree to which the documentation will be added
  */
 public void buildPackageSerializedForm(XMLNode node, Content serializedSummariesTree) {
   Content packageSerializedTree = writer.getPackageSerializedHeader();
   String foo = currentPackage.name();
   ClassDoc[] classes = currentPackage.allClasses(false);
   if (classes == null || classes.length == 0) {
     return;
   }
   if (!serialInclude(currentPackage)) {
     return;
   }
   if (!serialClassFoundToDocument(classes)) {
     return;
   }
   buildChildren(node, packageSerializedTree);
   serializedSummariesTree.addContent(packageSerializedTree);
 }
 /** Copy the doc files for the current ClassDoc if necessary. */
 private void copyDocFiles() {
   PackageDoc containingPackage = annotationTypeDoc.containingPackage();
   if ((configuration.packages == null
           || Arrays.binarySearch(configuration.packages, containingPackage) < 0)
       && !containingPackagesSeen.contains(containingPackage.name())) {
     // Only copy doc files dir if the containing package is not
     // documented AND if we have not documented a class from the same
     // package already. Otherwise, we are making duplicate copies.
     Util.copyDocFiles(
         configuration,
         Util.getPackageSourcePath(configuration, annotationTypeDoc.containingPackage())
             + DirectoryManager.getDirectoryPath(annotationTypeDoc.containingPackage())
             + File.separator,
         DocletConstants.DOC_FILES_DIR_NAME,
         true);
     containingPackagesSeen.add(containingPackage.name());
   }
 }
Пример #6
0
  /**
   * Add the given class to the given map.
   *
   * @param classdoc the ClassDoc to add to the catelog.
   * @param map the Map to add the ClassDoc to.
   */
  private void addClass(ClassDoc classdoc, Map<String, Set<ClassDoc>> map) {

    PackageDoc pkg = classdoc.containingPackage();
    if (pkg.isIncluded() || (configuration.nodeprecated && Util.isDeprecated(pkg))) {
      // No need to catalog this class if it's package is
      // included on the command line or if -nodeprecated option is set
      // and the containing package is marked as deprecated.
      return;
    }
    String key = Util.getPackageName(pkg);
    Set<ClassDoc> s = map.get(key);
    if (s == null) {
      packageSet.add(key);
      s = new HashSet<ClassDoc>();
    }
    s.add(classdoc);
    map.put(key, s);
  }
 private Map<String, List<ProgramElementDoc>> pkgDivide(
     Map<String, ? extends List<? extends ProgramElementDoc>> classMap) {
   Map<String, List<ProgramElementDoc>> map = new HashMap<>();
   List<? extends ProgramElementDoc> list = classMap.get(classdoc.qualifiedName());
   if (list != null) {
     Collections.sort(list);
     for (ProgramElementDoc doc : list) {
       PackageDoc pkg = doc.containingPackage();
       pkgSet.add(pkg);
       List<ProgramElementDoc> inPkg = map.get(pkg.name());
       if (inPkg == null) {
         inPkg = new ArrayList<>();
         map.put(pkg.name(), inPkg);
       }
       inPkg.add(doc);
     }
   }
   return map;
 }
 /**
  * Add the package annotation list.
  *
  * @param contentTree the content tree to which the package annotation list will be added
  */
 protected void addPackageAnnotationList(Content contentTree) throws IOException {
   if ((!classdoc.isAnnotationType())
       || pkgToPackageAnnotations == null
       || pkgToPackageAnnotations.isEmpty()) {
     return;
   }
   Content table =
       HtmlTree.TABLE(
           HtmlStyle.useSummary,
           0,
           3,
           0,
           useTableSummary,
           getTableCaption(
               configuration.getResource(
                   "doclet.ClassUse_PackageAnnotation",
                   getLink(
                       new LinkInfoImpl(
                           configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)))));
   table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
   Content tbody = new HtmlTree(HtmlTag.TBODY);
   Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator();
   for (int i = 0; it.hasNext(); i++) {
     PackageDoc pkg = it.next();
     HtmlTree tr = new HtmlTree(HtmlTag.TR);
     if (i % 2 == 0) {
       tr.addStyle(HtmlStyle.altColor);
     } else {
       tr.addStyle(HtmlStyle.rowColor);
     }
     Content tdFirst =
         HtmlTree.TD(HtmlStyle.colFirst, getPackageLink(pkg, new StringContent(pkg.name())));
     tr.addContent(tdFirst);
     HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
     tdLast.addStyle(HtmlStyle.colLast);
     addSummaryComment(pkg, tdLast);
     tr.addContent(tdLast);
     tbody.addContent(tr);
   }
   table.addContent(tbody);
   Content li = HtmlTree.LI(HtmlStyle.blockList, table);
   contentTree.addContent(li);
 }
 /**
  * Add the class list that use the given class.
  *
  * @param contentTree the content tree to which the class list will be added
  */
 protected void addClassList(Content contentTree) throws IOException {
   HtmlTree ul = new HtmlTree(HtmlTag.UL);
   ul.addStyle(HtmlStyle.blockList);
   for (PackageDoc pkg : pkgSet) {
     Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
     Content link =
         getResource(
             "doclet.ClassUse_Uses.of.0.in.1",
             getLink(
                 new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)),
             getPackageLink(pkg, Util.getPackageName(pkg)));
     Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
     li.addContent(heading);
     addClassUse(pkg, li);
     ul.addContent(li);
   }
   Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
   contentTree.addContent(li);
 }
 /**
  * Add the package use information.
  *
  * @param pkg the package that uses the given class
  * @param contentTree the content tree to which the package use information will be added
  */
 protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
   Content tdFirst =
       HtmlTree.TD(
           HtmlStyle.colFirst,
           getHyperLink(pkg.name(), new StringContent(Util.getPackageName(pkg))));
   contentTree.addContent(tdFirst);
   HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
   tdLast.addStyle(HtmlStyle.colLast);
   addSummaryComment(pkg, tdLast);
   contentTree.addContent(tdLast);
 }
 /**
  * Convert the Classes in the given Package to an HTML.
  *
  * @param pd the Package to convert.
  * @param outputdir the name of the directory to output to.
  */
 public void convertPackage(PackageDoc pd, DocPath outputdir) {
   if (pd == null) {
     return;
   }
   for (ClassDoc cd : pd.allClasses()) {
     // If -nodeprecated option is set and the class is marked as deprecated,
     // do not convert the package files to HTML. We do not check for
     // containing package deprecation since it is already check in
     // the calling method above.
     if (!(configuration.nodeprecated && utils.isDeprecated(cd))) convertClass(cd, outputdir);
   }
 }
 /** Generate the package use list. */
 protected void generatePackageUseFile() throws IOException {
   Content body = getPackageUseHeader();
   HtmlTree div = new HtmlTree(HtmlTag.DIV);
   div.addStyle(HtmlStyle.contentContainer);
   if (usingPackageToUsedClasses.isEmpty()) {
     div.addContent(getResource("doclet.ClassUse_No.usage.of.0", pkgdoc.name()));
   } else {
     addPackageUse(div);
   }
   body.addContent(div);
   addNavLinks(false, body);
   addBottom(body);
   printHtmlDocument(null, true, body);
 }
 /**
  * Add the package use information.
  *
  * @param pkg the package that used the given package
  * @param contentTree the content tree to which the information will be added
  */
 protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
   Content tdFirst =
       HtmlTree.TD(
           HtmlStyle.colFirst,
           getHyperLink(Util.getPackageName(pkg), new StringContent(Util.getPackageName(pkg))));
   contentTree.addContent(tdFirst);
   HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
   tdLast.addStyle(HtmlStyle.colLast);
   if (pkg != null && pkg.name().length() != 0) {
     addSummaryComment(pkg, tdLast);
   } else {
     tdLast.addContent(getSpace());
   }
   contentTree.addContent(tdLast);
 }
 /**
  * Get the header for the package use listing.
  *
  * @return a content tree representing the package use header
  */
 protected Content getPackageUseHeader() {
   String packageText = configuration.getText("doclet.Package");
   String name = pkgdoc.name();
   String title = configuration.getText("doclet.Window_ClassUse_Header", packageText, name);
   Content bodyTree = getBody(true, getWindowTitle(title));
   addTop(bodyTree);
   addNavLinks(true, bodyTree);
   ContentBuilder headContent = new ContentBuilder();
   headContent.addContent(getResource("doclet.ClassUse_Title", packageText));
   headContent.addContent(new HtmlTree(HtmlTag.BR));
   headContent.addContent(name);
   Content heading =
       HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, headContent);
   Content div = HtmlTree.DIV(HtmlStyle.header, heading);
   bodyTree.addContent(div);
   return bodyTree;
 }
 /**
  * Build the class serialized form.
  *
  * @param node the XML element that specifies which components to document
  * @param packageSerializedTree content tree to which the documentation will be added
  */
 public void buildClassSerializedForm(XMLNode node, Content packageSerializedTree) {
   Content classSerializedTree = writer.getClassSerializedHeader();
   ClassDoc[] classes = currentPackage.allClasses(false);
   Arrays.sort(classes);
   for (int j = 0; j < classes.length; j++) {
     currentClass = classes[j];
     fieldWriter = writer.getSerialFieldWriter(currentClass);
     methodWriter = writer.getSerialMethodWriter(currentClass);
     if (currentClass.isClass() && currentClass.isSerializable()) {
       if (!serialClassInclude(currentClass)) {
         continue;
       }
       Content classTree = writer.getClassHeader(currentClass);
       buildChildren(node, classTree);
       classSerializedTree.addContent(classTree);
     }
   }
   packageSerializedTree.addContent(classSerializedTree);
 }
Пример #16
0
  public void generate() throws IOException {
    writeHeader("Overview");
    writeNavBar();

    open("div class='container-fluid'");
    writeDescription();
    writePackagesTable("Packages", tool.getPackages(module));
    writeDependencies();
    close("div");

    for (Package pkg : module.getPackages()) {
      if (tool.isRootPackage(module, pkg) && !pkg.getMembers().isEmpty()) {
        rootPackageDoc = new PackageDoc(tool, writer, pkg);
        rootPackageDoc.generate();
      }
    }

    writeFooter();
  }
Пример #17
0
 /**
  * Return all of the classes specified on the command-line that belong to the given package.
  *
  * @param packageDoc the package to return the classes for.
  */
 public ClassDoc[] allClasses(PackageDoc pkgDoc) {
   return pkgDoc.isIncluded()
       ? pkgDoc.allClasses()
       : getArray(allClasses, Util.getPackageName(pkgDoc));
 }
Пример #18
0
  /**
   * The entry point into the Parser class.
   *
   * @param root A RootDoc intstance obtained via the doclet API
   * @return A XML (XStream) serializable element, containing everything parsed from javadoc doclet
   */
  public static Root ParseRoot(RootDoc root) {
    processingStorage = new HashMap<PackageDoc, ParserMediary>();

    try {
      md5 = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
      log.error("unable to acquire MD5 algorithm", e);
      return null;
    }

    rootXml = new Root();

    ClassDoc[] allClasses = root.classes();

    for (ClassDoc classDoc : allClasses) {
      PackageDoc doc = classDoc.containingPackage();

      ParserMediary mediary = null;

      // the age old 'if I have it pull out existing, if I don't make a new one'
      if (processingStorage.containsKey(doc)) {
        mediary = processingStorage.get(doc);
      } else {
        mediary =
            new ParserMediary(
                doc.name(),
                doc.commentText(),
                ParseAnnotationInstances(doc.annotations(), doc.name()));

        processingStorage.put(doc, mediary);
      }

      if (classDoc.isIncluded()) {
        // dev comment--why do enums show up as ordinary class?
        if (classDoc.isOrdinaryClass() || classDoc.isException() || classDoc.isError()) {
          mediary.addClass(ParseClass(classDoc));
        } else if (classDoc.isEnum()) {
          mediary.addEnum(ParseEnum(classDoc));
        } else if (isAnnotation(classDoc)) {
          mediary.addAnnotation(ParseAnnotation(classDoc));
        } else if (classDoc.isInterface()) {
          mediary.addInterface(ParseInterface(classDoc));
        }
      } else {
        log.debug("Skipping not-included class " + classDoc.qualifiedName());
      }
    }

    if (processingStorage.size() > 0) {
      List list = new ArrayList<Package>();

      for (ParserMediary mediary : processingStorage.values()) {
        list.add(mediary.wrapup());
      }

      rootXml.packages = (Package[]) list.toArray(new Package[] {});
    } else {
      log.warn("No packages found!");
    }

    return rootXml;
  }
Пример #19
0
 /**
  * Add at least the first sentence from a doc block for a package to the API. This is used by the
  * report generator if no comment is provided. The default source tree may not include the
  * package.html files, so this may be unavailable in many cases. Need to make sure that HTML tags
  * are not confused with XML tags. This could be done by stuffing the &lt; character to another
  * string or by handling HTML in the parser. This second option is neater. Note that XML expects
  * all element tags to have either a closing "/>" or a matching end element tag. Due to the
  * difficulties of converting incorrect HTML to XHTML, the first option is used.
  */
 public void addPkgDocumentation(RootDoc root, PackageDoc pd, int indent) {
   String rct = null;
   String filename = pd.name();
   try {
     // See if the source path was specified as part of the
     // options and prepend it if it was.
     String srcLocation = null;
     String[][] options = root.options();
     for (int opt = 0; opt < options.length; opt++) {
       if ((options[opt][0]).compareTo("-sourcepath") == 0) {
         srcLocation = options[opt][1];
         break;
       }
     }
     filename = filename.replace('.', JDiff.DIR_SEP.charAt(0));
     if (srcLocation != null) {
       // Make a relative location absolute
       if (srcLocation.startsWith("..")) {
         String curDir = System.getProperty("user.dir");
         while (srcLocation.startsWith("..")) {
           srcLocation = srcLocation.substring(3);
           int idx = curDir.lastIndexOf(JDiff.DIR_SEP);
           curDir = curDir.substring(0, idx + 1);
         }
         srcLocation = curDir + srcLocation;
       }
       filename = srcLocation + JDiff.DIR_SEP + filename;
     }
     // Try both ".htm" and ".html"
     filename += JDiff.DIR_SEP + "package.htm";
     File f2 = new File(filename);
     if (!f2.exists()) {
       filename += "l";
     }
     FileInputStream f = new FileInputStream(filename);
     BufferedReader d = new BufferedReader(new InputStreamReader(f));
     String str = d.readLine();
     // Ignore everything except the lines between <body> elements
     boolean inBody = false;
     while (str != null) {
       if (!inBody) {
         if (str.toLowerCase().trim().startsWith("<body")) {
           inBody = true;
         }
         str = d.readLine(); // Get the next line
         continue; // Ignore the line
       } else {
         if (str.toLowerCase().trim().startsWith("</body")) {
           inBody = false;
           continue; // Ignore the line
         }
       }
       if (rct == null) rct = str + "\n";
       else rct += str + "\n";
       str = d.readLine();
     }
   } catch (java.io.FileNotFoundException e) {
     // If it doesn't exist, that's fine
     if (trace) System.out.println("No package level documentation file at '" + filename + "'");
   } catch (java.io.IOException e) {
     System.out.println("Error reading file \"" + filename + "\": " + e.getMessage());
     System.exit(5);
   }
   if (rct != null) {
     rct = stripNonPrintingChars(rct, (Doc) pd);
     rct = rct.trim();
     if (rct.compareTo("") != 0
         && rct.indexOf(Comments.placeHolderText) == -1
         && rct.indexOf("InsertOtherCommentsHere") == -1) {
       int idx = endOfFirstSentence(rct);
       if (idx == 0) return;
       for (int i = 0; i < indent; i++) outputFile.print(" ");
       outputFile.println("<doc>");
       for (int i = 0; i < indent; i++) outputFile.print(" ");
       String firstSentence = null;
       if (idx == -1) firstSentence = rct;
       else firstSentence = rct.substring(0, idx + 1);
       String firstSentenceNoTags = API.stuffHTMLTags(firstSentence);
       outputFile.println(firstSentenceNoTags);
       for (int i = 0; i < indent; i++) outputFile.print(" ");
       outputFile.println("</doc>");
     }
   }
 }
 /**
  * Add the class use information.
  *
  * @param pkg the package that uses the given class
  * @param contentTree the content tree to which the class use information will be added
  */
 protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
   Content classLink =
       getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc));
   Content pkgLink = getPackageLink(pkg, Util.getPackageName(pkg));
   classSubWriter.addUseInfo(
       pkgToClassAnnotations.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_Annotation", classLink, pkgLink),
       classUseTableSummary,
       contentTree);
   classSubWriter.addUseInfo(
       pkgToClassTypeParameter.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_TypeParameter", classLink, pkgLink),
       classUseTableSummary,
       contentTree);
   classSubWriter.addUseInfo(
       pkgToSubclass.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_Subclass", classLink, pkgLink),
       subclassUseTableSummary,
       contentTree);
   classSubWriter.addUseInfo(
       pkgToSubinterface.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_Subinterface", classLink, pkgLink),
       subinterfaceUseTableSummary,
       contentTree);
   classSubWriter.addUseInfo(
       pkgToImplementingClass.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_ImplementingClass", classLink, pkgLink),
       classUseTableSummary,
       contentTree);
   fieldSubWriter.addUseInfo(
       pkgToField.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_Field", classLink, pkgLink),
       fieldUseTableSummary,
       contentTree);
   fieldSubWriter.addUseInfo(
       pkgToFieldAnnotations.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink, pkgLink),
       fieldUseTableSummary,
       contentTree);
   fieldSubWriter.addUseInfo(
       pkgToFieldTypeParameter.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink, pkgLink),
       fieldUseTableSummary,
       contentTree);
   methodSubWriter.addUseInfo(
       pkgToMethodAnnotations.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink, pkgLink),
       methodUseTableSummary,
       contentTree);
   methodSubWriter.addUseInfo(
       pkgToMethodParameterAnnotations.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink, pkgLink),
       methodUseTableSummary,
       contentTree);
   methodSubWriter.addUseInfo(
       pkgToMethodTypeParameter.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink, pkgLink),
       methodUseTableSummary,
       contentTree);
   methodSubWriter.addUseInfo(
       pkgToMethodReturn.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_MethodReturn", classLink, pkgLink),
       methodUseTableSummary,
       contentTree);
   methodSubWriter.addUseInfo(
       pkgToMethodReturnTypeParameter.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink, pkgLink),
       methodUseTableSummary,
       contentTree);
   methodSubWriter.addUseInfo(
       pkgToMethodArgs.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_MethodArgs", classLink, pkgLink),
       methodUseTableSummary,
       contentTree);
   methodSubWriter.addUseInfo(
       pkgToMethodArgTypeParameter.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink, pkgLink),
       methodUseTableSummary,
       contentTree);
   methodSubWriter.addUseInfo(
       pkgToMethodThrows.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_MethodThrows", classLink, pkgLink),
       methodUseTableSummary,
       contentTree);
   constrSubWriter.addUseInfo(
       pkgToConstructorAnnotations.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink, pkgLink),
       constructorUseTableSummary,
       contentTree);
   constrSubWriter.addUseInfo(
       pkgToConstructorParameterAnnotations.get(pkg.name()),
       configuration.getResource(
           "doclet.ClassUse_ConstructorParameterAnnotations", classLink, pkgLink),
       constructorUseTableSummary,
       contentTree);
   constrSubWriter.addUseInfo(
       pkgToConstructorArgs.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink, pkgLink),
       constructorUseTableSummary,
       contentTree);
   constrSubWriter.addUseInfo(
       pkgToConstructorArgTypeParameter.get(pkg.name()),
       configuration.getResource(
           "doclet.ClassUse_ConstructorArgsTypeParameters", classLink, pkgLink),
       constructorUseTableSummary,
       contentTree);
   constrSubWriter.addUseInfo(
       pkgToConstructorThrows.get(pkg.name()),
       configuration.getResource("doclet.ClassUse_ConstructorThrows", classLink, pkgLink),
       constructorUseTableSummary,
       contentTree);
 }
Пример #21
0
 /**
  * Given a package, return it's file name without the extension.
  *
  * @param packageDoc the package to check.
  * @return the file name of the given package.
  */
 public static String getPackageFileHeadName(PackageDoc packageDoc) {
   return packageDoc == null || packageDoc.name().length() == 0
       ? DocletConstants.DEFAULT_PACKAGE_FILE_NAME
       : packageDoc.name();
 }
Пример #22
0
  /**
   * Process each package and the classes/interfaces within it.
   *
   * @param pd an array of PackageDoc objects
   */
  public void processPackages(RootDoc root) {
    PackageDoc[] specified_pd = root.specifiedPackages();
    Map pdl = new TreeMap();
    for (int i = 0; specified_pd != null && i < specified_pd.length; i++) {
      pdl.put(specified_pd[i].name(), specified_pd[i]);
    }

    // Classes may be specified separately, so merge their packages into the
    // list of specified packages.
    ClassDoc[] cd = root.specifiedClasses();
    // This is lists of the specific classes to document
    Map classesToUse = new HashMap();
    for (int i = 0; cd != null && i < cd.length; i++) {
      PackageDoc cpd = cd[i].containingPackage();
      if (cpd == null && !packagesOnly) {
        // If the RootDoc object has been created from a jar file
        // this duplicates classes, so we have to be able to disable it.
        // TODO this is still null?
        cpd = root.packageNamed("anonymous");
      }
      String pkgName = cpd.name();
      String className = cd[i].name();
      if (trace) System.out.println("Found package " + pkgName + " for class " + className);
      if (!pdl.containsKey(pkgName)) {
        if (trace) System.out.println("Adding new package " + pkgName);
        pdl.put(pkgName, cpd);
      }

      // Keep track of the specific classes to be used for this package
      List classes;
      if (classesToUse.containsKey(pkgName)) {
        classes = (ArrayList) classesToUse.get(pkgName);
      } else {
        classes = new ArrayList();
      }
      classes.add(cd[i]);
      classesToUse.put(pkgName, classes);
    }

    PackageDoc[] pd = (PackageDoc[]) pdl.values().toArray(new PackageDoc[0]);
    for (int i = 0; pd != null && i < pd.length; i++) {
      String pkgName = pd[i].name();

      // Check for an exclude tag in the package doc block, but not
      // in the package.htm[l] file.
      if (!shownElement(pd[i], null)) continue;

      if (trace) System.out.println("PROCESSING PACKAGE: " + pkgName);
      outputFile.println("<package name=\"" + pkgName + "\">");

      int tagCount = pd[i].tags().length;
      if (trace) System.out.println("#tags: " + tagCount);

      List classList;
      if (classesToUse.containsKey(pkgName)) {
        // Use only the specified classes in the package
        System.out.println("Using the specified classes");
        classList = (ArrayList) classesToUse.get(pkgName);
      } else {
        // Use all classes in the package
        classList = new LinkedList(Arrays.asList(pd[i].allClasses()));
      }
      Collections.sort(classList);
      ClassDoc[] classes = new ClassDoc[classList.size()];
      classes = (ClassDoc[]) classList.toArray(classes);
      processClasses(classes, pkgName);

      addPkgDocumentation(root, pd[i], 2);

      outputFile.println("</package>");
    }
  } // processPackages