Skip to content

Commit

Permalink
Merge pull request tomaz#239 from kenji21/master
Browse files Browse the repository at this point in the history
Links like [this method] as custom title now works. Closes tomaz#239.
  • Loading branch information
tomaz committed Aug 14, 2012
2 parents 5a442eb + c8b2b2e commit 1690b35
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Application/GBCommentComponentsProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ - (NSString *)remoteMemberCrossReferenceRegex:(BOOL)templated {
if (templated) {
GBRETURN_ON_DEMAND([self crossReferenceRegexForRegex:[self remoteMemberCrossReferenceRegex:NO]]);
} else {
GBRETURN_ON_DEMAND(@"\\[?([^\\]]*)\\]?\\(?[+-]?\\[([^]\\s]+)\\s+(\\S+)\\]\\)?");
GBRETURN_ON_DEMAND(@"\\[([^\\]]+)\\]\\([<]?[+-]?\\[([^]\\s]+)\\s+([^]\\s]+)\\][>]?\\)|[<]?([+-]?)\\[([^]\\s]+)\\s+([^]\\s]+)\\][>]?");
}
}

Expand Down
14 changes: 12 additions & 2 deletions Processing/GBCommentsProcessor.m
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ - (NSString *)stringByConvertingSimpleCrossReferencesInString:(NSString *)string
NSString *remainingText = [string substringWithRange:remainingRange];
[result appendString:remainingText];
}
NSLog(@"result : %@", result);
return result;
}

Expand Down Expand Up @@ -864,6 +863,17 @@ - (GBCrossRefData)dataForRemoteMemberLinkInString:(NSString *)string searchRange
NSString *linkDisplayText = [components objectAtIndex:1];
NSString *objectName = [components objectAtIndex:2];
NSString *selector = [components objectAtIndex:3];
if( [components count] > 5 ) {
if( [linkDisplayText length] < 2 ) {
linkDisplayText = [components objectAtIndex:4];
}
if( [objectName length] == 0 ) {
objectName = [components objectAtIndex:5];
}
if( [selector length] == 0 ) {
selector = [components objectAtIndex:6];
}
}

// Match object name with one of the known objects. Warn if not found. Note that we mark the result so that we won't be searching the range for other links.
id referencedObject = [self.store classWithName:objectName];
Expand Down Expand Up @@ -893,7 +903,7 @@ - (GBCrossRefData)dataForRemoteMemberLinkInString:(NSString *)string searchRange
// Create link data and return.
result.range = [string rangeOfString:linkText options:0 range:searchRange];
result.address = [self.settings htmlReferenceForObject:referencedMember fromSource:self.currentContext];
if( [linkDisplayText length] > 0 )
if( [linkDisplayText length] > 1 )
{
result.description = linkDisplayText;
}
Expand Down
12 changes: 11 additions & 1 deletion Testing/GBCommentsProcessor-PreprocessingTesting.m
Original file line number Diff line number Diff line change
Expand Up @@ -610,13 +610,23 @@ - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualObjectMeth
NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[text]([Class doSomething:withVars:])" withFlags:0];
NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[text](-[Class value])" withFlags:0];
NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[text with space](+[Class method])" withFlags:0];
NSString *result4b = [processor stringByConvertingCrossReferencesInString:@"[text onlyOneSpace]([Class method])" withFlags:0];
NSString *result4c = [processor stringByConvertingCrossReferencesInString:@"[text](+[Class method]), [text onlyOneSpace]([Class method])" withFlags:0];
NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:])" withFlags:0];

NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:]), [text]([Class method])" withFlags:0];
NSString *result7 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:]), [text with space]([Class method])" withFlags:0];
NSString *result8 = [processor stringByConvertingCrossReferencesInString:@"[text](<-[Class value]>)" withFlags:0];

assertThat(result1, is(@"[text](Classes/Class.html#//api/name/method)"));
assertThat(result2, is(@"[text](Classes/Class.html#//api/name/doSomething:withVars:)"));
assertThat(result3, is(@"[text](Classes/Class.html#//api/name/value)"));
assertThat(result4, is(@"[text with space](Classes/Class.html#//api/name/method)"));
assertThat(result4b, is(@"[text onlyOneSpace](Classes/Class.html#//api/name/method)"));
assertThat(result4c, is(@"[text](Classes/Class.html#//api/name/method), [text onlyOneSpace](Classes/Class.html#//api/name/method)"));
assertThat(result5, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:)"));
assertThat(result6, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:), [text](Classes/Class.html#//api/name/method)"));
assertThat(result7, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:), [text with space](Classes/Class.html#//api/name/method)"));
assertThat(result8, is(@"[text](Classes/Class.html#//api/name/value)"));
}

- (void)testStringByConvertingCrossReferencesInString_shouldIgnoreKnownObjectsInManualLinkDescriptionOrTitle {
Expand Down

0 comments on commit 1690b35

Please sign in to comment.