diff --git a/VVDocumenter-Xcode/Commenter/VVArgument.m b/VVDocumenter-Xcode/Commenter/VVArgument.m index 37ea81a..4e52249 100755 --- a/VVDocumenter-Xcode/Commenter/VVArgument.m +++ b/VVDocumenter-Xcode/Commenter/VVArgument.m @@ -22,7 +22,8 @@ -(void)setType:(NSString *)type -(void)setName:(NSString *)name { if (name != _name) { - _name = [[[[[[name vv_stringByReplacingRegexPattern:@"^&" withString:@""] + _name = [[[[[[[name vv_stringByReplacingRegexPattern:@"\\(|\\)" withString:@""] + vv_stringByReplacingRegexPattern:@"^&" withString:@""] vv_stringByReplacingRegexPattern:@"^\\*+" withString:@""] vv_stringByReplacingRegexPattern:@"\\[.*$" withString:@""] vv_stringByReplacingRegexPattern:@",$" withString:@""] diff --git a/VVDocumenter-Xcode/Commenter/VVBaseCommenter.h b/VVDocumenter-Xcode/Commenter/VVBaseCommenter.h index a40a73b..e50f183 100755 --- a/VVDocumenter-Xcode/Commenter/VVBaseCommenter.h +++ b/VVDocumenter-Xcode/Commenter/VVBaseCommenter.h @@ -17,7 +17,8 @@ -(id) initWithIndentString:(NSString *)indent codeString:(NSString *)code; -(NSString *) document; --(void) parseArguments; + +-(void) parseArgumentsInputArgs:(NSString *)rawArgsCode; // Comment methods -(NSString *) startComment; diff --git a/VVDocumenter-Xcode/Commenter/VVBaseCommenter.m b/VVDocumenter-Xcode/Commenter/VVBaseCommenter.m index 614eb77..0eec7e4 100755 --- a/VVDocumenter-Xcode/Commenter/VVBaseCommenter.m +++ b/VVDocumenter-Xcode/Commenter/VVBaseCommenter.m @@ -118,34 +118,34 @@ -(NSString *) prefixString } } --(void) parseArguments +-(void) parseArgumentsInputArgs:(NSString *)rawArgsCode { [self.arguments removeAllObjects]; - NSArray * braceGroups = [self.code vv_stringsByExtractingGroupsUsingRegexPattern:@"\\(([^\\^][^\\(\\)]*)\\)"]; - if (braceGroups.count > 0) { - NSString *argumentGroupString = braceGroups[0]; - NSArray *argumentStrings = [argumentGroupString componentsSeparatedByString:@","]; - for (__strong NSString *argumentString in argumentStrings) { - VVArgument *arg = [[VVArgument alloc] init]; - argumentString = [argumentString vv_stringByReplacingRegexPattern:@"=\\s*\\w*" withString:@""]; - argumentString = [argumentString vv_stringByReplacingRegexPattern:@"\\s+$" withString:@""]; - argumentString = [argumentString vv_stringByReplacingRegexPattern:@"\\s+" withString:@" "]; - NSMutableArray *tempArgs = [[argumentString componentsSeparatedByString:@" "] mutableCopy]; - while ([[tempArgs lastObject] isEqualToString:@" "]) { - [tempArgs removeLastObject]; - } - - arg.name = [tempArgs lastObject]; - + if (rawArgsCode.length == 0) { + return; + } + + NSArray *argumentStrings = [rawArgsCode componentsSeparatedByString:@","]; + for (__strong NSString *argumentString in argumentStrings) { + VVArgument *arg = [[VVArgument alloc] init]; + argumentString = [argumentString vv_stringByReplacingRegexPattern:@"=\\s*\\w*" withString:@""]; + argumentString = [argumentString vv_stringByReplacingRegexPattern:@"\\s+$" withString:@""]; + argumentString = [argumentString vv_stringByReplacingRegexPattern:@"\\s+" withString:@" "]; + NSMutableArray *tempArgs = [[argumentString componentsSeparatedByString:@" "] mutableCopy]; + while ([[tempArgs lastObject] isEqualToString:@" "]) { [tempArgs removeLastObject]; - arg.type = [tempArgs componentsJoinedByString:@" "]; - - VVLog(@"arg type: %@", arg.type); - VVLog(@"arg name: %@", arg.name); - - [self.arguments addObject:arg]; } + + arg.name = [tempArgs lastObject]; + + [tempArgs removeLastObject]; + arg.type = [tempArgs componentsJoinedByString:@" "]; + + VVLog(@"arg type: %@", arg.type); + VVLog(@"arg name: %@", arg.name); + + [self.arguments addObject:arg]; } - } + @end diff --git a/VVDocumenter-Xcode/Commenter/VVFunctionCommenter.m b/VVDocumenter-Xcode/Commenter/VVFunctionCommenter.m index 8b22ef6..357690b 100755 --- a/VVDocumenter-Xcode/Commenter/VVFunctionCommenter.m +++ b/VVDocumenter-Xcode/Commenter/VVFunctionCommenter.m @@ -22,7 +22,10 @@ -(void) captureReturnType -(void) captureParameters { - [self parseArguments]; + NSArray * braceGroups = [self.code vv_stringsByExtractingGroupsUsingRegexPattern:@"\\(([^\\^].*)\\)"]; + if (braceGroups.count > 0) { + [self parseArgumentsInputArgs:braceGroups[0]]; + } //Remove void arg in block NSArray *tempArray = [NSArray arrayWithArray:self.arguments]; diff --git a/VVDocumenter-Xcode/Commenter/VVMacroCommenter.m b/VVDocumenter-Xcode/Commenter/VVMacroCommenter.m index 962d886..0011e77 100755 --- a/VVDocumenter-Xcode/Commenter/VVMacroCommenter.m +++ b/VVDocumenter-Xcode/Commenter/VVMacroCommenter.m @@ -17,8 +17,9 @@ -(void) captureReturnType -(void) captureParameters { - if ([self.code vv_matchesPatternRegexPattern:@"\\("]) { - [self parseArguments]; + NSArray * braceGroups = [self.code vv_stringsByExtractingGroupsUsingRegexPattern:@"\\(([^\\^][^\\(\\)]*)\\)"]; + if (braceGroups.count > 0) { + [self parseArgumentsInputArgs:braceGroups[0]]; } } diff --git a/VVDocumenterTests/CommenterTests/CommenterTests.m b/VVDocumenterTests/CommenterTests/CommenterTests.m index e179bf9..02b358b 100644 --- a/VVDocumenterTests/CommenterTests/CommenterTests.m +++ b/VVDocumenterTests/CommenterTests/CommenterTests.m @@ -68,7 +68,11 @@ -(void) testParseArguments arg1.type = @"int"; arg1.name = @"y"; - [baseCommenter parseArguments]; + NSArray * braceGroups = [baseCommenter.code vv_stringsByExtractingGroupsUsingRegexPattern:@"\\(([^\\^][^\\(\\)]*)\\)"]; + if (braceGroups.count > 0) { + [baseCommenter parseArgumentsInputArgs:braceGroups[0]]; + } + NSUInteger count = baseCommenter.arguments.count; STAssertEquals(count, (NSUInteger)2, @"There should be 2 args, %@",baseCommenter.arguments); STAssertEqualObjects(arg0.type, [(VVArgument *)baseCommenter.arguments[0] type], @"%@ should be type %@", [(VVArgument *)baseCommenter.arguments[0] type], arg0.type); @@ -84,7 +88,10 @@ -(void) testParseArguments arg1.type = @"char"; arg1.name = @"argv"; - [baseCommenter parseArguments]; + braceGroups = [baseCommenter.code vv_stringsByExtractingGroupsUsingRegexPattern:@"\\(([^\\^][^\\(\\)]*)\\)"]; + if (braceGroups.count > 0) { + [baseCommenter parseArgumentsInputArgs:braceGroups[0]]; + } count = baseCommenter.arguments.count; STAssertEquals(count, (NSUInteger)2, @"There should be 2 args, %@",baseCommenter.arguments); STAssertEqualObjects(arg0.type, [(VVArgument *)baseCommenter.arguments[0] type], @"%@ should be type %@", [(VVArgument *)baseCommenter.arguments[0] type], arg0.type); diff --git a/VVDocumenterTests/DocumenterTests/VVMethodTestsCode.plist b/VVDocumenterTests/DocumenterTests/VVMethodTestsCode.plist index 865ea7d..bb71b20 100644 --- a/VVDocumenterTests/DocumenterTests/VVMethodTestsCode.plist +++ b/VVDocumenterTests/DocumenterTests/VVMethodTestsCode.plist @@ -45,6 +45,18 @@ * <#Description#> * * @return <#return value description#> + */ + + + source + -(void)whenLinked:(void (^)(void))actionHandler + uniform + -(void)whenLinked:(void (^)(void))actionHandler + result + /** + * <#Description#> + * + * @param actionHandler <#actionHandler description#> */ @@ -160,6 +172,19 @@ * @param x <#x description#> * @param y <#y description#> * @param idx <#idx description#> + */ + + + source + void print2DList(int rowCount, int (*p)[10]); + uniform + void print2DList(int rowCount, int (*p)[10]); + result + /** + * <#Description#> + * + * @param rowCount <#rowCount description#> + * @param p <#p description#> */