Permalink
Browse files

Merge pull request #239 from kenji21/master

Links like [this method] as custom title now works. Closes #239.
  • Loading branch information...
2 parents 5a442eb + c8b2b2e commit 1690b3548a86bf866fc1387d283011a4c0fa8487 @tomaz committed Aug 14, 2012
@@ -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]+)\\][>]?");
}
}
@@ -705,7 +705,6 @@ - (NSString *)stringByConvertingSimpleCrossReferencesInString:(NSString *)string
NSString *remainingText = [string substringWithRange:remainingRange];
[result appendString:remainingText];
}
- NSLog(@"result : %@", result);
return result;
}
@@ -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];
@@ -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;
}
@@ -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 {

0 comments on commit 1690b35

Please sign in to comment.