Browse files

Fixing links with custom title detection (custom titles like [this me…

…thod] now works) and markdown generation. Refs #237
  • Loading branch information...
1 parent d0800f9 commit c8b2b2ec953ce311561959cd14602ccc2d1032ef @kenji21 committed Aug 13, 2012
View
2 Application/GBCommentComponentsProvider.m
@@ -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]+)\\][>]?");
}
}
View
14 Processing/GBCommentsProcessor.m
@@ -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;
}
View
12 Testing/GBCommentsProcessor-PreprocessingTesting.m
@@ -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 c8b2b2e

Please sign in to comment.