Skip to content

Commit

Permalink
When merging method documentation, section name is also copied if ori…
Browse files Browse the repository at this point in the history
…ginal name is nil. Closes tomaz#199.
  • Loading branch information
tomaz committed Mar 8, 2012
1 parent e203ada commit 53f9aec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Model/GBMethodData.h
Expand Up @@ -9,7 +9,7 @@
#import "GBModelBase.h"

@class GBMethodArgument;

@class GBMethodSectionData;

/** Defines different method types. */
enum {
Expand Down Expand Up @@ -113,6 +113,12 @@ typedef NSUInteger GBMethodType;
*/
@property (readonly) NSString *prefixedMethodSelector;

/** The section this method belongs to.
Primarily used so that we can setup proper section name when merging from protocols.
*/
@property (retain) GBMethodSectionData *methodSection;

///---------------------------------------------------------------------------------------
/// @name Helper properties
///---------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions Model/GBMethodData.m
Expand Up @@ -8,6 +8,7 @@

#import "GRMustache.h"
#import "GBMethodArgument.h"
#import "GBMethodSectionData.h"
#import "GBMethodData.h"
#import "RegexKitLite.h"

Expand Down Expand Up @@ -389,6 +390,7 @@ - (BOOL)isProperty {
@synthesize methodSelectorDelimiter = _methodSelectorDelimiter;
@synthesize methodPrefix = _methodPrefix;
@synthesize prefixedMethodSelector = _prefixedMethodSelector;
@synthesize methodSection;
@synthesize isRequired;

@end
3 changes: 3 additions & 0 deletions Model/GBMethodSectionData.m
Expand Up @@ -6,6 +6,7 @@
// Copyright (C) 2010, Gentle Bytes. All rights reserved.
//

#import "GBMethodData.h"
#import "GBMethodSectionData.h"

@implementation GBMethodSectionData
Expand All @@ -16,11 +17,13 @@ - (void)registerMethod:(GBMethodData *)method {
NSParameterAssert(method != nil);
if (!_methods) _methods = [[NSMutableArray alloc] init];
[_methods addObject:method];
method.methodSection = self;
}

- (BOOL)unregisterMethod:(GBMethodData *)method {
if ([_methods containsObject:method]) {
[_methods removeObject:method];
method.methodSection = nil;
return YES;
}
return NO;
Expand Down
4 changes: 4 additions & 0 deletions Processing/GBProcessor.m
Expand Up @@ -245,6 +245,10 @@ - (void)copyKnownDocumentationForMethod:(GBMethodData *)method {
GBMethodData *protocolMethod = [protocol.methods methodBySelector:method.methodSelector];
if (protocolMethod.comment) {
GBLogVerbose(@"Copying documentation for %@ from adopted protocol %@...", method, protocol);
if (protocolMethod.methodSection.sectionName && !method.methodSection.sectionName) {
GBLogDebug(@"Copying section name %@ from %@...", protocolMethod.methodSection.sectionName, protocol);
method.methodSection.sectionName = protocolMethod.methodSection.sectionName;
}
protocolMethod.comment.originalContext = protocolMethod.parentObject;
method.comment = protocolMethod.comment;
return;
Expand Down

0 comments on commit 53f9aec

Please sign in to comment.