Bug 202490 - Javadoc of JavaCore options hard to use
Summary: Javadoc of JavaCore options hard to use
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 major with 1 vote (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-06 12:16 EDT by Dani Megert CLA
Modified: 2008-02-04 09:08 EST (History)
6 users (show)

See Also:


Attachments
Fix - wip: moved the docs (194.46 KB, patch)
2008-01-25 08:40 EST, Maxime Daniel CLA
no flags Details | Diff
Fix wip (179.23 KB, patch)
2008-01-28 08:49 EST, Maxime Daniel CLA
no flags Details | Diff
Fix + test case (189.41 KB, patch)
2008-01-30 11:06 EST, Maxime Daniel CLA
no flags Details | Diff
Fix + test case (187.04 KB, patch)
2008-01-31 03:50 EST, Maxime Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2007-09-06 12:16:15 EDT
M20070905-1045.

The Javadoc for the JavaCore options is a generic blurb:

	/**
	 * Possible  configurable option ID.
	 * @see #getDefaultOptions()
	 * @since 3.1
	 */

This renders Javadoc view and hovers useless. Clients have to open JavaCore, then navigate to getDefaultOptions() and then search in the 900! lines of comment for their option.

Please move (or copy) the Javadoc to their corresponding element so that clients can use the Javadoc view and the Javadoc hover to get information about JavaCore option constants.
Comment 1 Maxime Daniel CLA 2007-09-07 06:06:11 EDT
See also bug 143427.
Comment 2 Dani Megert CLA 2007-09-07 06:52:39 EDT
Exactly: the doc is already there and in good shape. The only thing which is needed is to move or copy it to the corresponding constant(s).
Comment 3 Martin Aeschlimann CLA 2007-09-12 11:40:49 EDT
see bug 124093...
Comment 4 Markus Keller CLA 2008-01-23 06:50:32 EST
This is really a major pain for every user of this API.
Clients should always reference the string constants and when they do this, they should also see their meaning without having to do another lookup in the supersized Javadoc of getDefaultOptions().
Comment 5 Dani Megert CLA 2008-01-23 08:50:09 EST
This bug also renders the Javadoc and the content assist help useless as it says for all JDT Core constants:

	Possible  configurable option ID.

	@see #getDefaultOptions()

Comment 6 Philipe Mulet CLA 2008-01-23 09:35:27 EST
I agree, this is a pain. I probably initiated this a long time ago, but now there are just too many entries. It is probably time to split the doc across all the options.
Comment 7 Markus Keller CLA 2008-01-23 09:51:18 EST
(In reply to comment #6)
Yipee!

To avoid problems with typos as in bug 100278 comment 16, I'd suggest to
- use the {@value} Javadoc tag
- initialize the constants with CompilerOptions.OPTION_*

The ideal solution would be to define the constants in JavaCore and let CompilerOptions refer to the API, but I guess that would be an internal layer break for the standalone compiler. Still, having manifest strings only at one spot and use field accesses everywhere else is the best way to ensure correct mappings and to ease navigation for readers of the code (using reference search or call hierarchy).
Comment 8 Maxime Daniel CLA 2008-01-24 02:45:36 EST
Thinking to what we could do to further improve the situation, I believe we could afford to rename the internal constants after the API ones. Or at least, to give it a try. Doing so would reduce confusion, and mitigate the inconvenience of our being compelled to have the API layer reference the internal constants.
Would anyone strongly object to this?

I also initially thought I could add a test that would check getDefaultOptions' doc against the constants'. But thinking more about it, the constants are grouped enough to make a linear reading of their specification easy enough. Do we want/need to have @see entries in getDefaultOptions' javadoc?
Comment 9 Dani Megert CLA 2008-01-24 03:30:36 EST
>Do we want/need to have @see entries in getDefaultOptions' javadoc?

In addition to each entry:
option id:         "org.eclipse.jdt.core.classpath.exclusionPatterns"

You could add:
constant:          {@link #CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS}
Comment 10 Maxime Daniel CLA 2008-01-24 03:58:12 EST
I was on a more radical thought path: move options doc to constants, and decide between an almost empty javadoc for getDefaultOptions, and the same plus @see tags. If I get you well, you would prefer a more verbose getDefaultOptions javadoc (something like the one we have, plus links).
My bet is that, once each constant is properly described, there is no need for too verbose a getDefaultOptions javadoc any more. So amongst the three following options, my preference would go to 1 or 2:
1 - simplistic getDefaultOptions javadoc;
2 - 1 plus links to constants;
3 - current getDefaultOptions javadoc, augmented with links to the relevant constants.

What about trying 2 and seeing how it fares?
Comment 11 Dani Megert CLA 2008-01-24 04:02:10 EST
>If I get you well, you would prefer a more verbose getDefaultOptions
>javadoc (something like the one we have, plus links).
Nope, I also prefer the radical solution but was not aware you're going that far ;-)
Comment 12 Markus Keller CLA 2008-01-24 05:29:30 EST
(In reply to comment #10)
I'd vote for
> 1 - simplistic getDefaultOptions javadoc;

, but 
> 2 - 1 plus links to constants;
would also be fine with me.

> 3 - current getDefaultOptions javadoc, augmented with links to the relevant
> constants.
That would be hard to manage and keep in sync, and I don't see a real use case for this.

You could also add an @category tag to each COMPILER_ constant and refer to that tag in the Javadoc of getDefaultOptions(). This would implicitly define all options that are returned in the Hashtable and avoid any duplicated definitions.
Comment 13 Maxime Daniel CLA 2008-01-25 08:39:18 EST
Issues/notes:
- now see that @throws, @deprecated, @Deprecated (others?) get interpreted by JDT UI when between <pre> and </pre> (but are not by javadoc itself); need to check if a bug is open for this; don't quite see any workaround for now (except dropping the @ sign); at least one entry made the choice to reference @throws using "A 'throws' tag"; may want to follow that pattern consistently;
- @category is not recognized by javadoc (running with default config); a side effect is that refering to the categories in getDefaultOptions doc introduces kind of an unreferenced link; must improve that (keeping categories if possible - they are kind of neat in Eclipse);
- BTW, masking the uncategorized members on Linux with I20071218-0800 simply drops the class from the Outline view; need to check on latest;
- I do not think that @value would be enough for IDs; we want the literal value to be readable in the code and in the javadoc; may use it for option values, since those get their literals defined in place; for IDs, I'll craft a white box test to check that values match the docs;
- the use of CompilerOptions values for initialization is the subject of bug 216277, I won't address this here;
- found a constant that had to be deprecated, see bug 216571;
- some constants documentation may need to be re-rewritten to become more meaningful; this goes far beyond this bug though, and I won't undertake a formal review for it;
- fixed at least one unbalanced pair of {} in possible values specs;
- since we use <pre> tags, we should keep the number of columns within reasonable limits; not addressed here;
- quite a few @since tags are missing; not addressed here; probably needs that a bug be opened;
- will probably change cross-options reference from the use of literals to the use of {@link}; this made little sense within the getDefaultOptions doc bag, but would be the best solution in the reorganized doc;
- the hosting of builder options by the java core options set must pertain to history and might need a second look; not addressed here;
- may want to craft a test that checks that the documented default value matches the real one;
- use of <br> vs <p>;
- use of <br> or <p> within <pre>;
- since the first sentence of the javadoc is presented in a table at the top of the class documentation, may want to collapse the first lines for each constant into something meaningful.
Comment 14 Maxime Daniel CLA 2008-01-25 08:40:06 EST
Created attachment 87857 [details]
Fix - wip: moved the docs
Comment 15 Maxime Daniel CLA 2008-01-25 09:07:15 EST
(In reply to comment #13)
> Issues/notes:
...
> - BTW, masking the uncategorized members on Linux with I20071218-0800 simply
> drops the class from the Outline view; need to check on latest;
According to bug 153406, this is an expected behavior and the cure would be to add the categories we want to the class itself. Will make a try and see how I like it.
Comment 16 Markus Keller CLA 2008-01-25 09:58:13 EST
(In reply to comment #13)

> - now see that @throws, @deprecated, @Deprecated (others?) get interpreted by
> JDT UI when between <pre> and </pre> (but are not by javadoc itself); need to
> check if a bug is open for this; don't quite see any workaround for now 
Limitation of the syntax coloring for Javadoc tags (JDT/Text). AST looks fine.
A workaround could be to replace '@' with '&#64;', but that's ugly in source.

> - @category is not recognized by javadoc (running with default config); a side
> effect is that refering to the categories in getDefaultOptions doc introduces
> kind of an unreferenced link; must improve that (keeping categories if possible
> - they are kind of neat in Eclipse);
@category is not (yet?) an official tag:
http://java.sun.com/j2se/javadoc/proposed-tags.html
I don't think a link in getDefaultOptions() would make much sense (would have
to link to all occurrences of the respective @category...). Referring to them
in plain text is a good solution.

> - I do not think that @value would be enough for IDs; we want the literal value
> to be readable in the code and in the javadoc;
Constant value is available in Javadoc hover in 3.4 (at the end of the bold
header). I'm working on support for automatically replacing {@value} inside the
Javadoc with the value of the referenced constant.

+1 for the rest of your comments. I would replace the <pre> with normal text
and  HTML definition lists.
Comment 17 Maxime Daniel CLA 2008-01-28 03:06:07 EST
(In reply to comment #16)
> (In reply to comment #13)
> 
> > - now see that @throws, @deprecated, @Deprecated (others?) get interpreted by
> > JDT UI when between <pre> and </pre> (but are not by javadoc itself); need to
> > check if a bug is open for this; don't quite see any workaround for now 
> Limitation of the syntax coloring for Javadoc tags (JDT/Text). AST looks fine.
> A workaround could be to replace '@' with '&#64;', but that's ugly in source.
A search on '<pre> hover' only returned bug 40596 which I believe is unrelated. Any bug open for that? If non, I'll open one and will anchor a fup bug for us on it, and I'll move our current @xxx tags to "tag 'xxx'", unless the definition list trick helps in some way.

> > - @category is not recognized by javadoc (running with default config); a side
> > effect is that refering to the categories in getDefaultOptions doc introduces
> > kind of an unreferenced link; must improve that (keeping categories if possible
> > - they are kind of neat in Eclipse);
> @category is not (yet?) an official tag:
> http://java.sun.com/j2se/javadoc/proposed-tags.html
Knew it. My intent was to collect advantages and drawbacks of using the @category pattern, and the fact that the generated javadoc does not leverage it as of today is a limitation, since we have to find another way to tell the reader where to look for relevant constants, and that very limitation becomes a drawback if you consider that whatever means we use to improve the javadoc as needed, there will be duplication between the @category values and the other classification device. The question left is: does the @category annotation bring enough value in the context of the IDE to outbalance the information duplication issue?

> I don't think a link in getDefaultOptions() would make much sense (would have
> to link to all occurrences of the respective @category...). Referring to them
> in plain text is a good solution.
ack

> > - I do not think that @value would be enough for IDs; we want the literal value
> > to be readable in the code and in the javadoc;
> Constant value is available in Javadoc hover in 3.4 (at the end of the bold
> header). I'm working on support for automatically replacing {@value} inside the
> Javadoc with the value of the referenced constant.
Still. For constants which literal value is available in the code, @value will make perfect sense once its support is complete. This would be the case for option values. For constants which initialization points to another constant, which will be the case for option IDs if we solve bug 216277 by leveraging the language and using CompilerOptions constants, the fact that the javadoc displays the value is invaluable.
> 
> +1 for the rest of your comments.
ack
> I would replace the <pre> with normal text
> and  HTML definition lists.
Will try and consider the results.

Comment 18 Maxime Daniel CLA 2008-01-28 03:13:13 EST
(In reply to comment #15)
> (In reply to comment #13)
> > Issues/notes:
> ...
> > - BTW, masking the uncategorized members on Linux with I20071218-0800 simply
> > drops the class from the Outline view; need to check on latest;
> According to bug 153406, this is an expected behavior and the cure would be to
> add the categories we want to the class itself. Will make a try and see how I
> like it.
Thinking more about it, I came to consider that this was not the way to go. @category is supposed to help classify *members* of a class, which makes using it on a top-level class irrelevant. Markus reopened bug 153406 before I attempted to. I'll proceed on this bug as if bug 153406 was to be fixed.

Comment 19 Dani Megert CLA 2008-01-28 04:21:54 EST
> I'll proceed on this bug as if bug 153406 was to be fixed.
Sorry but we won't work on that bug.
Comment 20 Maxime Daniel CLA 2008-01-28 04:37:31 EST
(In reply to comment #19)
> > I'll proceed on this bug as if bug 153406 was to be fixed.
> Sorry but we won't work on that bug.
My impression from the reading of bug 153406 and related ones was that you considered making the use of categories in the outline view smoother in the case where the top-level class would not bear any @category tag itself, somewhat getting closer to the semantics of the @category tag. Seems I got it wrong. Do you confirm that, when only category 'visible' is checked in its filter, the outline view will show f for listing 1 but not listing 2, and that you plan to change nothing to this?

// listing 1
/** @category visible */
public class X {
  /** @category visible */
  public int f;
}

// listing 2
public class X {
  /** @category visible */
  public int f;
}

If so, is there any existing or planned combination of options that would make the use of listing 2 desirable in any ways?

I definitely do not want to go for listing 1.
Comment 21 Dani Megert CLA 2008-01-28 04:43:59 EST
>the outline view will show f for listing 1 but not listing 2, and that
>you plan to change nothing to this?
Right - at least not for 3.4. Of course if you go into the type (Go Into Top Level Type) then f will be shown for both listings.
Comment 22 Maxime Daniel CLA 2008-01-28 05:21:45 EST
(In reply to comment #17)
> (In reply to comment #16)
> > (In reply to comment #13)
> > 
> > > - now see that @throws, @deprecated, @Deprecated (others?) get interpreted by
> > > JDT UI when between <pre> and </pre> (but are not by javadoc itself); need to
> > > check if a bug is open for this; don't quite see any workaround for now 
> > Limitation of the syntax coloring for Javadoc tags (JDT/Text). AST looks fine.
> > A workaround could be to replace '@' with '&#64;', but that's ugly in source.
> A search on '<pre> hover' only returned bug 40596 which I believe is unrelated.
> Any bug open for that? If non, I'll open one and will anchor a fup bug for us
> on it, and I'll move our current @xxx tags to "tag 'xxx'", unless the
> definition list trick helps in some way.
Using <code> seems to work in all situations, aka <code>@deprecated</code>.
Comment 23 Maxime Daniel CLA 2008-01-28 05:23:36 EST
(In reply to comment #21)
> >the outline view will show f for listing 1 but not listing 2, and that
> >you plan to change nothing to this?
> Right - at least not for 3.4. Of course if you go into the type (Go Into Top
> Level Type) then f will be shown for both listings.
Tested that and looks neat. Suspect some users will be able to get the right options set in place, hence I'll keep categories.

Comment 24 Maxime Daniel CLA 2008-01-28 08:49:01 EST
Created attachment 88007 [details]
Fix wip

This new proposal does the following:
- used definition lists in place of pre-formatted comments enclosed within <pre> tags;
- used <code> tags to neutralized unwanted side effects on javadoc tags used in descriptions (for example 'when encountering a <code>@param</code>', which wants to discuss about the said tag, not to insert such a tag);
- used @link when referring a constant from another constant;
- used @value tags in option values descriptions;
- replaced the use of <br> by the use of <p>;
- (loosely) referenced the categories from options getters and setters; since @category is not supported yet, I preferred to use a loose link than getting the reader of the javadoc confused; users of the IDE should be able to mentally close the gap between the categories as documented in the text (aka 'Compiler option ID') and in category tags (aka 'CompilerOptionID'); note that using white spaces in @category specifies as many categories as words, which is not what we want, whereas the use of the CompilerOptionID format is the text would look odd;
- improved the rendering into the javadoc headers by collapsing the first lines of description (the summary table now has entries like '	CODEASSIST_ARGUMENT_SUFFIXES
          Code assist option ID: Define the Suffixes for Argument Name.'.

Still have to check again the results and to craft a couple of white-box tests that would cross check the docs and the real values.
Comment 25 Markus Keller CLA 2008-01-30 06:14:02 EST
(In reply to comment #24)

Nice. I would also use inline @links for possible values, e.g.:
 * <dt>Possible values:</dt><dd>{{@link #GENERATE}, {@link #DO_NOT_GENERATE}}</dd>
 * <dt>Default:</dt><dd>{@link #GENERATE}</dd>

Clients don't really care about the concrete value and they always refer to the OptionValue constants if they are sane.

In #getDefaultOptions(), I would just use the category identifiers:
 * (categorized in CodeAssistOptionID, CompilerOptionID and CoreOptionID) 
Comment 26 Maxime Daniel CLA 2008-01-30 11:02:30 EST
(In reply to comment #25)
> (In reply to comment #24)
> 
> Nice.
thx
> I would also use inline @links for possible values, e.g.:
>  * <dt>Possible values:</dt><dd>{{@link #GENERATE}, {@link
> #DO_NOT_GENERATE}}</dd>
>  * <dt>Default:</dt><dd>{@link #GENERATE}</dd>
> 
> Clients don't really care about the concrete value and they always refer to the
> OptionValue constants if they are sane.
I won't do that in 3.4 M5 in any case (we're supposed to freeze soon). You may want to open a fup bug (not committing to change anything though ;-)).

> In #getDefaultOptions(), I would just use the category identifiers:
>  * (categorized in CodeAssistOptionID, CompilerOptionID and CoreOptionID) 
Since @category is not leveraged by javadoc, and I need a way to talk about these categories even in the context of the generated javadoc, I preferred to 'refer loosely' to categories (see discussion in comment #24).

Comment 27 Maxime Daniel CLA 2008-01-30 11:06:27 EST
Created attachment 88294 [details]
Fix + test case

This proposal adds a white-box test that checks ids and default values correlation between the javadoc and the real code. It also aligns the javadoc, that suffered a bit during the previous steps.

Kent, would you please let me know what you think (M5 is coming soon and I'd like to release at least a first set of improvements)? Note that I have not run the tests other than the APIDocumentationTests yet. My changes should not affect the code, hence it should be OK. Launching them straight away.
Comment 28 Kent Johnson CLA 2008-01-30 11:37:52 EST
Looks good.

Some of the tabs seem to be off in the patch, but assuming that doesn't affect the UI presentation then it shouldn't matter.
Comment 29 Maxime Daniel CLA 2008-01-31 02:45:06 EST
Thx. I'll release this today then, invalidating the test though (I do not know of our having similar tests yet, and I believe that getting it to run significantly or to get skipped gracefully on releng while running in local will need some tinkering - and may break a nightly build or two. I'll do that in early M6).
Comment 30 Maxime Daniel CLA 2008-01-31 03:50:43 EST
Created attachment 88382 [details]
Fix + test case

Same with:
- HEAD catchup;
- tabs instead of leading white spaces in docs;
- invalidated API doc test (need to refine this after M5, opened fup bug 217223 to this effect;
Comment 31 Maxime Daniel CLA 2008-01-31 04:51:22 EST
Released for 3.4M5.
Comment 32 Eric Jodet CLA 2008-02-04 09:08:40 EST
Verified in the code for 3.4M5 using build I20080204-0010