7

I'm using BlueJ and I would like to generate the Javadoc of my whole project. I would like to show private methods on the Javadoc, is there any way to do it? BlueJ has a tool which makes the Javadoc, but BlueJ ignore private methods. Is just a convention? If it's a convention, I don't understand why, they ignore "internal" methods, they are useful too -.-*

The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156
Thorba
  • 181
  • 1
  • 11

3 Answers3

6

This link suggests that BlueJ will only generate JavaDocs for public methods and classes. Specifically:

your output will only contain information about public methods and variables

However, according to this bug report linked to in Andrew Thompson's answer, it appears this has been fixed in version 1.1.5 of BlueJ. In fact, according to section 9.8 of the BlueJ Reference Manual, you can specify exactly what options to use when running the JavaDoc tool by editing the doctool.options property.

There appear to be 3 properties that control the behaviour of documentation generation:

  • doctool.command: controls what command is used to generate documentation, and by default is set to javadoc
  • doctool.outputdir: controls where generated documentation is saved, and by default is set to doc
  • doctool.options: controls other command line options passed to the command specified by javadoc.command, and by default is set to -author –version –nodeprecated –package. Note, that by replacing -package with -private you can document all methods.

In general, since the JavaDoc tool is a command line program, you can simply call it yourself from the command line with something like this:

$ javadoc -d \path\to\output\folder -sourcepath \path\to\source\folder -private

Note, this command assumes that the javadoc is included in your PATH environment variable, which is usually the case in most java installations.

  • The -d option gives the desired output directory
  • The -sourcepath option tells the JavaDoc tool where to find the source code to document
  • The -private option tells the JavaDoc tool to create documentation for all classes, members, and methods (as private is the most restricted visibility)

The full list of options that control the members that JavaDoc will document is:

  • -public - Shows only public classes and members.
  • -protected - Shows only protected and public classes and members. This is the default.
  • -package - Shows only package, protected, and public classes and members.
  • -private - Shows all classes and members.

(Taken from the JavaDoc Documentation)

EDIT 0: Updated answer to incorporate new information brought to light by Andrew Thompson

Community
  • 1
  • 1
chrisbunney
  • 5,819
  • 7
  • 48
  • 67
  • Thanks for the info, nicely organized ;) Very interesting link you put about Javadoc & BlueJ, very useful! – Thorba Jan 02 '12 at 00:55
3

Generally by convention people do not put private methods in Javadoc because Javadoc is meant to be for somebody consuming your code. Since they can't access private methods there's no sense in documenting them for that audience.

However, the javadoc tool has a flag to enable this:

javadoc -private

Will generate private methods in your Javadoc. I'm not sure how BlueJ works with this, but maybe you can pass in a flag or something.

Todd
  • 30,472
  • 11
  • 81
  • 89
  • Thank you very much, I didn't know I could use javadoc on console like a command, I'm a newbie :( – Thorba Jan 02 '12 at 00:54
  • 1
    Unless that individual consuming your code is another developer who must maintain/extend the code you originally wrote ;) – chrisbunney Jan 02 '12 at 01:01
  • @chrisbunney Then the methods shouldn't be private if they are meant to be extended or used by subclasses. In the case of maintenance, they'd have the code and could read its Javadoc formatted comments, they just wouldn't be in the HTML-formatted Javadoc. We're not talking about leaving out comments, just not putting them in the API documents that Javadoc generally creates. But I do see your point! – Todd Jan 02 '12 at 13:34
3

The link in the accepted answer is from an article written in 2001. A lot has changed since then.

E.G. Hunting down through the top 5 or so links for 'bluej+javadocs' includes a link to something that mentions the bug report to allow inclusion of private methods in javadoc. The description mentions:

make javadoc parameters user definable (in bluej.defs) so that users have to option to include private methods in the documentation

Is also mentions:

Resolution:     FIXED 

Note: I don't use BlueJ, but had to go on a hunt when I heard the incredible answer that a major IDE has no ability to offer configuration of such a simple thing.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • I'd never heard of BlueJ, so I really didn't think twice about it, +1 for the more thorough hunting than I did :) – chrisbunney Jan 02 '12 at 14:04