BIMserver icon indicating copy to clipboard operation
BIMserver copied to clipboard

Replace JavaDoc with custom annotations for public interfaces

Open hlg opened this issue 4 years ago • 0 comments

Currently, methods of public interfaces are documented via JavaDoc-style comments (parameter names, description of method behaviour, parameters and return value). Consider for example the AuthInterface.login method:

https://github.com/opensourceBIM/BIMserver/blob/2e59595be40418f81ab080f4bcf5b72eee690afb/PluginBase/src/org/bimserver/shared/interfaces/AuthInterface.java#L36-L49

Usually, comments - and those the JavaDoc entries - are only available at compile time. But at runtime, the service map holds the interface metadata within SService, SMethod, SParameter etc. On SService.init, method names and parameter types are populated via reflection, parameter names are extracted from the WebParam annotation, but doc strings can only be extracted from the JavaDoc when sources are available at runtime. If that is the case, then the service map entries are initialized from doc strings with the help of Eclipse JDT AstParser.

https://github.com/opensourceBIM/BIMserver/blob/2e59595be40418f81ab080f4bcf5b72eee690afb/PluginBase/src/org/bimserver/shared/meta/SService.java#L76-L129

This is a smart solution, but I would suggest to replace (or duplicate) the JavaDoc comments with custom annotations, such that they are available at runtime regardless of source code availability. As a side effect, the dependency on org.eclipse.jdt can be removed from PluginBase.

hlg avatar Jan 08 '22 22:01 hlg