jcommander icon indicating copy to clipboard operation
jcommander copied to clipboard

Example code in documentation does not compile

Open hogejo opened this issue 1 year ago • 3 comments

I keep bumping into example code that does not compile. :smiling_face_with_tear:

I have the following problems:

  1. Example classes should be either package private or public - for consistence https://jcommander.org/#_parameter_delegates has package private classes, while https://jcommander.org/#_more_complex_syntaxes_commands has public and private at the same time
  2. Example classes should never be private Is https://jcommander.org/#_internationalization or any example with a private class correct?
  3. Class members should be also package private or public - for consistence For example, https://jcommander.org/#_parameter_delegates won't work with private members

I would like to fix all of the above, but I would like a decision from the maintainers please!

Since these classes and members are used for configuration or applications, I would assume most of us put them in a dedicated package and make the classes and members public. So I would default to public classes and members. Let me know if I can fix all classes and members like that.

Thank you for the library, Greg

hogejo avatar Nov 29 '24 21:11 hogejo

I would kindly ask for only changing the absolute essential minimum change, and to abstain from any non-essential refactoring. Having said that, what actually is not compiling?

mkarg avatar Dec 11 '24 12:12 mkarg

The example classes if copied to dedicated files don't compile. This is because the visibility of the example classes.

Image

hogejo avatar May 19 '25 11:05 hogejo

The intention of this docs section is to have both code blocks (the upper and the lower) within the same main class (hence single file). If you do that, it compiles. This is not a bug, it is intention. But I see your point. You want to be able to copy-and-run the code. This is not the intention of the docs. It shall just showcase the use of the API. This is not a Java beginner tutorial. ;-)

mkarg avatar May 19 '25 21:05 mkarg

@hogejo Closing this issue as you were not responsive since May.

mkarg avatar Aug 10 '25 12:08 mkarg