static Map<String, String> getNameToCommentMapping(ConstructorDoc constructorDoc) { ImmutableMap.Builder<String, String> nameToCommentMapping = ImmutableMap.builder(); Tag[] params = constructorDoc.tags("@param"); for (Tag param: params) { String[] text = param.text().split(" ", 2); String snakeCaseParamName = UPPER_CAMEL.to(LOWER_UNDERSCORE, text[0]); String paramComment = text[1].trim(); nameToCommentMapping.put(snakeCaseParamName, paramComment); } return nameToCommentMapping.build(); } }
@Before public void initialiseMocks() { when(constructorDoc.tags(PARAM_TAG_NAME)).thenReturn(new Tag[] {tag1, tag2}); when(tag1.name()).thenReturn(PARAM_TAG_NAME); when(tag1.text()).thenReturn(FIRST_PARAM_TEXT); when(tag2.name()).thenReturn(PARAM_TAG_NAME); when(tag2.text()).thenReturn(SECOND_PARAM_TEXT); when(tag3.name()).thenReturn(RETURN_TAG_NAME); when(tag3.text()).thenReturn(RETURN_TAG_TEXT); }
protected Constructor parseConstructor(ConstructorDoc constructorDoc) { Constructor constructorNode = objectFactory.createConstructor(); constructorNode.setName(constructorDoc.name()); constructorNode.setQualified(constructorDoc.qualifiedName()); String comment = constructorDoc.commentText(); if (comment.length() > 0) { constructorNode.setComment(comment); } constructorNode.setScope(parseScope(constructorDoc)); constructorNode.setIncluded(constructorDoc.isIncluded()); constructorNode.setFinal(constructorDoc.isFinal()); constructorNode.setNative(constructorDoc.isNative()); constructorNode.setStatic(constructorDoc.isStatic()); constructorNode.setSynchronized(constructorDoc.isSynchronized()); constructorNode.setVarArgs(constructorDoc.isVarArgs()); constructorNode.setSignature(constructorDoc.signature()); for (Parameter parameter : constructorDoc.parameters()) { constructorNode.getParameter().add(parseMethodParameter(parameter)); } for (Type exceptionType : constructorDoc.thrownExceptionTypes()) { constructorNode.getException().add(parseTypeInfo(exceptionType)); } for (AnnotationDesc annotationDesc : constructorDoc.annotations()) { constructorNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, constructorDoc.qualifiedName())); } for (Tag tag : constructorDoc.tags()) { constructorNode.getTag().add(parseTag(tag)); } return constructorNode; }
parameterComment = findComment( JAVADOC_RETURN_TAG_NAME, doc.tags() ); if ( parameterComment != null ) { factory.constructTagDocumentation( parameter, parameterComment );