Ejemplo n.º 1
0
 /** {@inheritDoc} */
 public Content getTagletOutput(Tag tag, TagletWriter writer) {
   ArrayList inlineTags = new ArrayList();
   inlineTags.add(new TextTag(tag.holder(), "<b>"));
   inlineTags.addAll(Arrays.asList(tag.inlineTags()));
   inlineTags.add(new TextTag(tag.holder(), "</b>"));
   return writer.commentTagsToOutput(tag, (Tag[]) inlineTags.toArray(new Tag[] {}));
 }
 /** 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());
   }
 }
 /**
  * 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);
 }
 /**
  * Build the serial field tags information.
  *
  * @param serializableFieldsTree content tree to which the documentation will be added
  */
 public void buildSerialFieldTagsInfo(Content serializableFieldsTree) {
   if (configuration.nocomment) {
     return;
   }
   FieldDoc field = (FieldDoc) currentMember;
   // Process Serializable Fields specified as array of
   // ObjectStreamFields. Print a member for each serialField tag.
   // (There should be one serialField tag per ObjectStreamField
   // element.)
   SerialFieldTag[] tags = field.serialFieldTags();
   Arrays.sort(tags);
   int tagsLength = tags.length;
   for (int i = 0; i < tagsLength; i++) {
     if (tags[i].fieldName() == null
         || tags[i].fieldType() == null) // ignore malformed @serialField tags
     continue;
     Content fieldsContentTree = fieldWriter.getFieldsContentHeader((i == tagsLength - 1));
     fieldWriter.addMemberHeader(
         tags[i].fieldTypeDoc(), tags[i].fieldType(), "", tags[i].fieldName(), fieldsContentTree);
     fieldWriter.addMemberDescription(tags[i], fieldsContentTree);
     serializableFieldsTree.addContent(fieldsContentTree);
   }
 }
 public static boolean start(com.sun.javadoc.RootDoc root) {
   ClassDoc[] classes = root.classes();
   if (classes.length != 1) throw new Error("1 " + Arrays.asList(classes));
   return true;
 }
Ejemplo n.º 6
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