示例#1
0
  // Checks whether javaClass has a path tag associated with it and if it does
  // processes its methods and creates a tag for the class on the root
  void processClass(JavaClass javaClass, ObjectNode paths, ArrayNode tags) {
    // If the class does not have a Path tag then ignore it
    JavaAnnotation annotation = getPathAnnotation(javaClass);
    if (annotation == null) {
      return;
    }

    String path = getPath(annotation);
    if (path == null) {
      return;
    }

    String resourcePath = "/" + path;
    String tagPath = path.isEmpty() ? "/" : path;

    // Create tag node for this class.
    ObjectNode tagObject = mapper.createObjectNode();
    tagObject.put("name", tagPath);
    if (javaClass.getComment() != null) {
      tagObject.put("description", shortText(javaClass.getComment()));
    }
    tags.add(tagObject);

    // Create an array node add to all methods from this class.
    ArrayNode tagArray = mapper.createArrayNode();
    tagArray.add(tagPath);

    processAllMethods(javaClass, resourcePath, paths, tagArray);
  }
示例#2
0
  @Test
  public void descriptionAppearsInClassJavadoc() throws IOException {

    String javaDocComment = classWithTitle.getComment();

    assertThat(javaDocComment, containsString("A title for this type"));
  }
示例#3
0
  @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));
  }
 public String getDescription() {
   return javaClass.getComment();
 }
 /**
  * Get comment string of Java class.
  *
  * @param className
  * @return
  * @author hzjingcheng
  */
 @SuppressWarnings("unused")
 private String getClassComment(String className) {
   JavaClass cls = builder.getClassByName(className);
   return cls.getComment();
 }