package cmp.Xref;
import cmp.business.CSVWriter; // comma-separated values
import com.sun.javadoc.*;
import com.sun.javadoc.Doclet;
import java.io.FileWriter;

/**
* Doclet to extract a list of all methods, all names fully qualified with signatures.
* From that output you can extract the package and class names.
*
* invoked with:
* javadoc -doclet com.mindprod.Xref.AllMethods -classpath .;C:\;J:\program files\java\jdk1.5.0_05\lib\tools.jar -subpackages cmp
*
* One problem with this code is it cannot tell if com.mindprod.Wassup.Wassup.SortCollator
* is the SortCollator inner class ef com.mindprod.Wassup.Wassup, or if it is a separate cass in
* package com.mindprod.Wassup.Wassup.
*/
public class AllMethods extends Doclet
   {

   /**
   * iterates over all methods extracting
   * them to a csv file.
   *
   * @param root object representing the entire JavaDoc information.
   *
   * @return true if successful
   */
   public static boolean start(RootDoc root)
      {
      try
         {
         out.println( "Beginning export..." );
         CSVWriter csv = new CSVWriter( new FileWriter( "allmethods.csv" ), false, ';' );
         ClassDoc[] classes = root.classes ();
         for ( int i=0; i<classes.length; i++ )
            {
            MethodDoc[] methods = classes[i].methods ();
            for ( int j=0; j<methods.length; j++ )
               {
               csv.put( methods [j].toString() );
               csv.nl();
               }
            }
         csv.close();
         return true;
         }

      catch ( Exception e )
         {
         e.printStackTrace();
         return false;
         }
      }
   } // end class AllMethods