Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4074234
Votes 277
Synopsis javadoc tool: Traverse/recurse all subpackages with "javadoc <packagename>"
Category doclet:tbd
Reported Against 1.1 , 1.0.2 , 1.2beta4
Release Fixed 1.4(merlin-beta2)
State 10-Fix Delivered, Verified, request for enhancement
Priority: 4-Low
Related Bugs 4023384 , 4175370
Submit Date 25-AUG-1997
Description
Want to be able to specify a root package on the command line and
have javadoc traverse and generate docs for all subpackages.  
Would also need to be able to exclude packages and/or classes
you want to skip over.

Also known as "recursive descent" (or "recursively descend").



Subject: RE: Javadoc - Recursive package search
Date: Fri, 22 Aug 1997 09:24:05 +0100

I think I've probably got my wires crossed!  What I was trying to say
was that if you have a directory tree as follows:

Halifax
    |----General
	  |------HxDate
          |   	  |-------HxData.java
          |
	  |------HxInt
          |   	  |--------HxInt.java
          |
	  |------HxString
          |   	  |-------HxString.java	  
          |
	  |-------HxGeneral.java
          |
	  |-------HxFile.java

In which all files/classes belong to the package Halifax.General you
would expect the following command to pick up all of the source files
even the ones in the sub directories:

Javadoc Halifax.General

or at least.

Javadoc Halifax.General.*

Unfortunately it doesn't happen.
Work Around
For those who need this feature because they have hit the 
command line-length limit (1000 characters on Windows),
we have already implemented a different solution for that --
the @file argument which points to a file that can contain the
rest of the arguments.  This works in 1.2 Beta4.  For more 
information, see:
http://java.sun.com/products/jdk/1.2/docs/tooldocs/win32/javadoc.html#argumentfile
  xxxxx@xxxxx   1998-10-06
Evaluation
Can someone write a wrapper in Java to perform this function?
  xxxxx@xxxxx   1998-04-03

There is a huge demand from the JDC for this functionality and it 
should be added to the tool itself.  For backward compatibility
this functionality will require a flag and a flag or flags will
be needed to exclude packages.
  xxxxx@xxxxx   1998-10-06

Raised priority from 5 to 4 and added workaround.
  xxxxx@xxxxx   1998-10-06

Add option -recurse so that the default is to not recurse, for backward
compatibility.  However, if we require package names, then you
could not run javadoc on all the java.* packages:  javadoc -recurse java
since "java" is not a package.

Or should -exclude take a package or class name, so you could
combine it with -recurse:   javadoc -recurse package1 -exclude package2
This should work at the member level, class level or package level.
  xxxxx@xxxxx   1998-12-15

Further design and discussion needed - fix in 1.3.
  xxxxx@xxxxx   1999-02-04

Because this is so highly requested, how about if we write a wrapper to do
this for Merlin (1.4), then add it to Javadoc later.
  xxxxx@xxxxx   2000-12-06

This RFE has been implemented.  Location of implemetation:

src/share/javac/com/sun/tools/javadoc/JavadocTool.java
src/share/javac/com/sun/tools/javadoc/Start.java
src/share/javac/com/sun/tools/javadoc/resources/javadoc.properties

  xxxxx@xxxxx   2001-07-20
Comments
  
  Include a link with my name & email   

Submitted On 14-JAN-1998
reichel
The current behavior is inconvenient. But for know
you can work-around this by specifying each package
on the command line.
i.e. javadoc -d &lt;docdir&gt; Halifax Halifax.General Halifax.General.HxDate
...
 


Submitted On 06-FEB-1998
engines
I'd rather see this as an optional flag.  Current implementation allows you to
have sub-packages which are not exposed to your customer which I like.  I'd
like to have a -r flag to process recursively or something.


Submitted On 10-FEB-1998
mark_lindner
This is especially annoying under crappy operating systems like
WinNT which limit the length of a command line to about 256 characters.
Not very useful when you are generating javadoc for a long list of
packages with a command whose length exceeds this limit.


Submitted On 02-MAR-1998
tdibble1
As for excluding sub-packages, I like the way PolarDoc implements this; it
defaults to including all subdirs, and you may use the -x mypackage switch to
exclude packages you don't want javadoc'd.
Well, for that matter, JavaSoft could learn quite a bit from PolarDoc!



Submitted On 11-MAY-1998
grohoski
This code will generate the javadoc for large packages which extend beyond the
256 character maximums on win32 systems:
It also redirects the output to a file for perusal since the command line
prompt is not scrollable on win32 systems.
Just include your options in the array as below:
import sun.tools.javadoc.*;
import java.io.*;
public class generateDocs
{
	public static final String myPackages[] = {
		&quot;-version&quot;,
		&quot;-author&quot;,
		&quot;-private&quot;,
		&quot;mypackage&quot;,
		&quot;mypackage.subpackage&quot;,
		&quot;mypackage.subpackage2&quot;,
		&quot;mypackage2.subpackage&quot;,
		&quot;mypackage2.subpackage2&quot;
};

	public static void main(String[] args)
	{
		for(int i = 0; i &lt; 10; i++)
		{
			generateDocs.doYourStuff();
		}
	}
	public static void doYourStuff()
	{
		try
		{
			File outFile = new File(&quot;c:\\logs\\javadoc.log&quot;);
			PrintStream outStream = new PrintStream(new FileOutputStream(outFile));
			System.setOut(outStream);
			System.out.println(&quot;Beginning documentation creation&quot;);
			sun.tools.javadoc.Main.main(myPackages);
		}
		catch(IOException e)
		{
			System.out.println(&quot;Error setting stderr&quot;);
			e.printStackTrace();
		}
	}


Submitted On 13-MAY-1998
tryphon
I agree with this bug : my application has
186 packages !!! Javadoc is hell for me !!
Another bug : under WinNT the option -J&lt;flag&gt;
doesn't work. With my 911 classes, I must run
&quot;java -mx32m -ms32m sun.tools.javadoc.Main ...&quot;.


Submitted On 15-MAY-1998
mbp@pharos.com.au
Please do this with a -recursive option to change 
from the normal functionality.


Submitted On 27-MAY-1998
spau008
Hi,
I don't know why this option was never added in the first place.
Seems like just having an option (like &quot;dir /s&quot;in DOS) would have
been common sense.
If you don't want it, don't slash it. 
It would be a REAL time saver.


Submitted On 30-JUN-1998
bribass
A recursive flag would greatly simplify javadoc generation for my deeply
packaged classes.


Submitted On 17-JUL-1998
mbells
It would be interesting to be able to specify
either both recursive and non recursive packages
in one command line. Maybe using the syntax:
javadoc &lt;options&gt; package1.* package2 package3.*.*
package1 would include all first level subpackage, and
package2 would include no other subpackage, and
package3 would include all second level subpackages (recurse twice).
This is simple, and like &quot;-r&quot; is similar to command
line shells (replacing &quot;/&quot; with &quot;.&quot;, eg. &quot;ls
bin/*/*&quot;).
But, this is *much* more powerful.


Submitted On 05-AUG-1998
loverde
The problem with this feature request is figuring
out how to &quot;prune&quot; unwanted packages from the
list.  Personally, I use a &quot;ksh&quot; script to generate
a list of package names similar to the following:

***** BEGIN get_javadocdirs SCRIPT *****
#!/ksh
#
# Name: get_javadocdirs
# Usage: get_javadocdirs &lt;sourcepath&gt;
#
# Get a list of the directories, pruning
# the CVS and test subdirectories
cd $1
ALL_PKGDIRS=`find . -name CVS -prune -o -name test -prune -o -type d -print
# Prune any directories that don't contain a java 
# file
PKGDIRS=&quot;&quot;
for DIR in $ALL_PKGDIRS; do
  LSDIR=`ls $DIR/*.java 2&gt; /dev/null`
  if [ ! -z &quot;$LSDIR&quot; ]; then
    PKGDIRS=`echo $PKGDIRS $DIR`
  fi
done
# Convert directory names to package names
#
PKGNAMES=&quot;&quot;
for DIR in $PKGDIRS; do
  PKGNAME=`echo $DIR | sed -e 's/\.\///g'`
  PKGNAME=`echo $PKGNAME | sed -e 's/\//\./g'`
  PKGNAMES=`echo $PKGNAMES $PKGNAME`
done
# Return the list of package names
#
echo $PKGNAMES
***** END get_javadocdirs SCRIPT *****
Similar scripts could be written in perl
or the scripting language of your choice.  As I 
said, perhaps the biggest problem is deciding 
how to prune directories from your list of
package names.
Using this script, javadoc generation is simply:
javadoc -d &lt;destdir&gt; `get_javadocdirs &lt;basepath&gt;`
Of course, this is primarily a Unix solution. 
However, it will work on Win32 using a Unix toolkit
like the GnuWin32 tools.  As for other platforms
(e.g. Mac), I'm not sure what the solution would be.





Submitted On 27-AUG-1998
mcangus
Another possible solution is to allow javadoc to read an ascii file containing
the list of package names.  I.e.:
javadoc -d [dest] -f [filename] ...
The input file could be created on Wintel machines using a command like: 
&quot;dir /s /aD /b /v * &gt;[filename]&quot; 
Then an editor can be used to remove the unwanted packages.


Submitted On 10-NOV-1998
JamesSchriever
Here is an easy work-around on Windows NT using 1.2 beta4 or later:
1.  Type the following on the command line from
    the root of you packages to get a file
    containing a listing of directories:
       dir /ad /s /b &gt; packages.txt
2.  Then use @packages.txt for your source.
       e.g. javadoc @packages.txt
This could be done in one step if javadoc accepted stdin for the files so that
it would have the ability to accept piped input.  
       e.g.  dir /ad /s /b | javadoc



Submitted On 02-DEC-1998
jourdan
It's really painful to not have this -r option !!
Dot it before jdk1.2 last release !!
it's not a hard feature to implement !! Lazy ??


Submitted On 14-JAN-1999
dkramer
Oops, I meant the slashes would have to be changed
to dots.


Submitted On 14-JAN-1999
dkramer
The use of &quot;packages.text&quot; mentioned by James Schreiver, 
should work fine.  However, his mention of:
dir /ad /s /b | javadoc
would not work as-is (even if Javadoc accepted stdin)
because Javadoc takes package names not directory 
names -- the dots would have to be changed to 
slashes somehow.
-Doug Kramer
 Javadoc team


Submitted On 06-APR-1999
bertlamb
Polardoc kicks Javadoc's ass


Submitted On 20-MAY-1999
aaron_h
Workaround:
On a Windows box, make a batch file in
your source dir like:
dir /a-d /b /s *.java &gt; ~files
javadoc -d ..\doc @~files
del ~files
You might modify this to take a source dir as a parameter.
This simply generates a file listing to be fed into javadoc.
In any case, if this is done you still won't get any package
documentation as described in:
4214962
Synopsis
No package info generated for source files passed on command line


Submitted On 03-NOV-1999
dkf
Surely the way to handle pulling the directories to parse on
the command line is to have the &quot;filename&quot; - be mapped to
reading from System.in (many Unix tools do just this) so the
following command line would do the trick...
   dir /ad /s /b | javadoc @-
Well, except for the required filter (producing the following
Solaris command line...)
   find hierRoot -type d -print | sed s,/,.,g | javadoc @-
As it is, at the moment I have a *really* crufty shell-script to
handle all this for me which also requires manual maintenance.
Anything that lets me get away from that is deeply welcome!


Submitted On 25-JAN-2000
annehj
Should be obvious


Submitted On 06-APR-2000
jhitt
This would be very convenient - Right now I have to 
maintain a separate batch program with all the package 
names.  I agree it should be a -r (or -s) option.  In order 
to implement this, I think the java.lang.Package class 
might need a method like: public Package[] 
Package.getSubpackages(), or some other way to traverse the 
package tree via reflection.


Submitted On 25-OCT-2000
laurentcaillette
I do like the way Javadoc handles a list of packages, through the use of @package-list parameter. Many of 
my packages have a &quot;test&quot; subpackage, which should not pollute my documentation.
My personal opinion is that a package name should support the asterisk wildcard ('*'), in order to say that 
subpackages should be added.


Submitted On 12-APR-2001
stefanreich
Ant, a tool for automating build processes, has a "javadoc" 
command that does the job nicely. I often create an ant-
build.xml for projects just for generating javadocs.

Here's the URL:
http://jakarta.apache.org/ant/


Submitted On 19-APR-2001
diroussel
I also use Jakarta Ant to build my javadoc.  I reckomend it 
to everyone.


Submitted On 27-SEP-2001
richwilsonaus
Under Windows 2000 (and possibly NT) you can use:

dir /b /s *.java > files.txt

to generate a list of files in a directory.



PLEASE NOTE: JDK6 is formerly known as Project Mustang