@Override protected void doWithResourceDocument(ResourceDocument document, Class<?> classOfResource) { // Check if the class is present in the builder. if (javaDocBuilder.getClassByName(classOfResource.getName()) == null) throw new IllegalArgumentException( "Class " + classOfResource + " was not found within the specified source files."); JavaClass javaClass = javaDocBuilder.getClassByName(classOfResource.getName()); document.setDescription(javaClass.getComment()); document.setTitle(titleOrNull(javaClass)); }
@Override protected void doWithResourceDocument(ResourceDocument document, Class<?> classOfResource) { LOG.info("Generating ResourceDocument for {}", classOfResource); if (!classOfResource.isAnnotationPresent(ResourceDoc.class)) { throw new RuntimeException( "Cannot generate documentation for a resource class " + "that is not annotated with @ResoureceDoc"); } // --- Process TGIRest annotations ResourceDoc rd = (ResourceDoc) classOfResource.getAnnotation(ResourceDoc.class); document.setDescription(rd.description()); document.setTitle(rd.title()); }
@Override public final ResourceDocument generateResourceDocument( UriInfo uriInfo, Class<?> classOfResource) { final ResourceDocument document = new ResourceDocument(); // Read the path. final Path path = this.findAnnotationInClass(Path.class, classOfResource); if (null == path) throw new IllegalStateException( "Couldn't find any class/superclass/interface annotated with @Path for " + classOfResource); document.setPath(uriInfo.getPath() + path.value()); this.doWithResourceDocument(document, classOfResource); // Process its methods for (Method method : classOfResource.getDeclaredMethods()) { // Skip methods that are not annotated with @HttpGet if (!isHttpMethod(method)) { LOG.debug("Skipping method {}, it is not annotated with @HttpMethod", method.getName()); continue; } // IllegalStateException is thrown if the method iterated is not // annotated with any of the @HttpMethod annotations. This can happen // for utility/helper methods found within classOfResource. try { document.addMethodDocument(this.generateMethodDocument(uriInfo, method)); } catch (IllegalStateException e) { // Ignoring specific methods, as they aren't annotated with @HttpMethod. LOG.debug("Skipping method {}, it isn't annotated with any @HttpMethod", method.getName()); } } return document; }