Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented method arguments registration and processing.

  • Loading branch information...
commit 42d1cf7789ab7b49bb5cbba3898f9ec72c048bd5 1 parent 4a138c6
@tomaz authored
View
21 Model/GBComment.h
@@ -74,6 +74,27 @@
*/
@property (retain) GBCommentComponentsList *longDescription;
+/** All registeres method parameters, only applicable for methods, empty list is used otherwise.
+
+ @see methodExceptions
+ @see methodResult
+ */
+@property (retain) NSMutableArray *methodParameters;
+
+/** All registeres method exceptions, only applicable for methods, empty list if used otherwise.
+
+ @see methodParameters
+ @see methodResult
+ */
+@property (retain) NSMutableArray *methodExceptions;
+
+/** Method result description, only applicable for methods, empty list is used otherwise.
+
+ @see methodParameters
+ @see methodExceptions
+ */
+@property (retain) GBCommentComponentsList *methodResult;
+
///---------------------------------------------------------------------------------------
/// @name Output generator helpers
///---------------------------------------------------------------------------------------
View
6 Model/GBComment.m
@@ -28,6 +28,9 @@ - (id)init {
self = [super init];
if (self) {
self.longDescription = [GBCommentComponentsList componentsList];
+ self.methodParameters = [NSMutableArray array];
+ self.methodExceptions = [NSMutableArray array];
+ self.methodResult = [GBCommentComponentsList componentsList];
}
return self;
}
@@ -50,5 +53,8 @@ - (NSString *)debugDescription {
@synthesize shortDescription;
@synthesize longDescription;
+@synthesize methodParameters;
+@synthesize methodExceptions;
+@synthesize methodResult;
@end
View
61 Model/GBCommentArgument.h
@@ -0,0 +1,61 @@
+//
+// GBCommentArgument.h
+// appledoc
+//
+// Created by Tomaz Kragelj on 16.2.11.
+// Copyright 2011 Gentle Bytes. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@class GBCommentComponentsList;
+@class GBSourceInfo;
+
+/** Handles individual `GBComment` named argument.
+
+ A comment argument is either a parameter or exception. In any case, the class allows assigning argument name and description. The description is simply a list of comment components in the form of `GBCommentComponentsList`. This allows every parameter contain arbitrary descriptions!
+ */
+@interface GBCommentArgument : NSObject
+
+///---------------------------------------------------------------------------------------
+/// @name Initialization & disposal
+///---------------------------------------------------------------------------------------
+
+/** Returns a new autoreleased instance of the object with the given string value.
+
+ This is a helper initializer which allows setting name with a single message. Sending this message is equivalent to sending `argumentWithName:sourceInfo:`, passing the given _value_ and `nil` for source info.
+
+ @param name Name of the argument.
+ @return Returns initialized object or `nil` if initialization fails.
+ @see argumentWithName:sourceInfo:
+ */
++ (id)argumentWithName:(NSString *)name;
+
+/** Returns a new autoreleased instance of the comment with the given string value and source info.
+
+ This is a helper initializer which allows setting default values with a single message.
+
+ @param name Name of the argument.
+ @param info Source info to set.
+ @return Returns initialized object or `nil` if initialization fails.
+ @see argumentWithName:
+ */
++ (id)argumentWithName:(NSString *)name sourceInfo:(GBSourceInfo *)info;
+
+///---------------------------------------------------------------------------------------
+/// @name Argument description
+///---------------------------------------------------------------------------------------
+
+/** The name of the argument.
+ */
+@property (copy) NSString *argumentName;
+
+/** The description components of the argument as `GBCommentComponentsList`.
+ */
+@property (retain) GBCommentComponentsList *argumentDescription;
+
+/** Source file information.
+ */
+@property (retain) GBSourceInfo *sourceInfo;
+
+@end
View
44 Model/GBCommentArgument.m
@@ -0,0 +1,44 @@
+//
+// GBCommentArgument.m
+// appledoc
+//
+// Created by Tomaz Kragelj on 16.2.11.
+// Copyright 2011 Gentle Bytes. All rights reserved.
+//
+
+#import "GBSourceInfo.h"
+#import "GBCommentComponentsList.h"
+#import "GBCommentArgument.h"
+
+@implementation GBCommentArgument
+
+#pragma mark Initialization & disposal
+
++ (id)argumentWithName:(NSString *)name {
+ return [self argumentWithName:name sourceInfo:nil];
+}
+
++ (id)argumentWithName:(NSString *)name sourceInfo:(GBSourceInfo *)info {
+ GBCommentArgument *result = [[[self alloc] init] autorelease];
+ if (result) {
+ result.argumentName = name;
+ result.sourceInfo = info;
+ }
+ return result;
+}
+
+- (id)init {
+ self = [super init];
+ if (self) {
+ self.argumentDescription = [GBCommentComponentsList componentsList];
+ }
+ return self;
+}
+
+#pragma mark Properties
+
+@synthesize argumentName;
+@synthesize argumentDescription;
+@synthesize sourceInfo;
+
+@end
View
2  Model/GBCommentComponentsList.h
@@ -10,7 +10,7 @@
/** Handles a list of `GBCommentComponent`s.
- Although we could handle the lists as `NSArray`s directly, having additional layer in-between unifies the access to the list.
+ Although we could handle the lists as `NSArray`s directly, having additional layer in-between unifies the access to the list and simplifies the interface.
*/
@interface GBCommentComponentsList : NSObject {
@private
View
1  Model/GBDataObjects.h
@@ -9,6 +9,7 @@
#import "GBComment.h"
#import "GBCommentComponent.h"
#import "GBCommentComponentsList.h"
+#import "GBCommentArgument.h"
#import "GBClassData.h"
#import "GBCategoryData.h"
View
72 Processing/GBCommentsProcessor.m
@@ -28,6 +28,7 @@ - (BOOL)processReturnBlockInString:(NSString *)string lines:(NSArray *)lines blo
- (BOOL)processRelatedBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange;
- (BOOL)isLineMatchingDirectiveStatement:(NSString *)string;
+- (GBCommentComponent *)commentComponentFromString:(NSString *)string;
- (NSString *)stringByPreprocessingString:(NSString *)string;
- (NSString *)stringByCombiningTrimmedLines:(NSArray *)lines;
@@ -38,8 +39,7 @@ - (NSString *)stringByCombiningTrimmedLines:(NSArray *)lines;
@property (readonly) GBCommentComponentsProvider *components;
@property (retain) NSMutableDictionary *reservedShortDescriptionData;
-@property (readonly) NSString *sourceFileInfo;
-@property (assign) NSUInteger currentStartLine;
+@property (retain) GBSourceInfo *currentSourceInfo;
@end
@@ -124,7 +124,9 @@ - (BOOL)findCommentBlockInLines:(NSArray *)lines blockRange:(NSRange *)blockRang
- (void)processCommentBlockInLines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange {
// The given range is guaranteed to point to actual block within the lines array, so we only need to determine the kind of block and how to handle it. We only need to handle short description based on settings if this is first block within the comment.
- self.currentStartLine = self.currentComment.sourceInfo.lineNumber + blockRange.location;
+ NSString *filename = self.currentComment.sourceInfo.filename;
+ NSUInteger lineNumber = self.currentComment.sourceInfo.lineNumber + blockRange.location;
+ self.currentSourceInfo = [GBSourceInfo infoWithFilename:filename ? filename : @"unknownfile" lineNumber:lineNumber];
// If the block is a directive, we should handle only it's description text for the main block. If this is the first block in the comment, we should take the first part of the directive for short description.
NSArray *block = [lines subarrayWithRange:blockRange];
@@ -136,7 +138,7 @@ - (void)processCommentBlockInLines:(NSArray *)lines blockRange:(NSRange)blockRan
if ([self processExceptionBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
if ([self processReturnBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
if ([self processRelatedBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
- GBLogWarn(@"Unknown directive block %@ encountered at %@, processing as standard text!", [[lines firstObject] normalizedDescription], self.sourceFileInfo);
+ GBLogWarn(@"Unknown directive block %@ encountered at %@, processing as standard text!", [[lines firstObject] normalizedDescription], self.currentSourceInfo);
}
// Handle short description and update block range if we're not repeating first paragraph.
@@ -154,9 +156,8 @@ - (void)processCommentBlockInLines:(NSArray *)lines blockRange:(NSRange)blockRan
NSString *blockString = [self stringByCombiningTrimmedLines:blockLines];
if ([blockString length] == 0) return;
- GBLogDebug(@"- Registering text block %@ at %@...", [blockString normalizedDescription], self.sourceFileInfo);
- GBCommentComponent *component = [GBCommentComponent componentWithStringValue:blockString];
- component.markdownValue = [self stringByPreprocessingString:blockString];
+ // Process the string and register long description component.
+ GBCommentComponent *component = [self commentComponentFromString:blockString];
[self.currentComment.longDescription registerComponent:component];
}
@@ -208,12 +209,11 @@ - (BOOL)processWarningBlockInString:(NSString *)string lines:(NSArray *)lines bl
NSString *directive = [components objectAtIndex:1];
NSString *description = [components objectAtIndex:2];
NSString *stringValue = [NSString stringWithFormat:@"%@%@", directive, description];
- GBLogDebug(@"- Registering warning block %@ at %@...", [description normalizedDescription], self.sourceFileInfo);
+ GBLogDebug(@"- Registering warning block %@ at %@...", [description normalizedDescription], self.currentSourceInfo);
[self registerShortDescriptionFromLines:lines range:shortRange removePrefix:directive];
// Convert to markdown and register everything. We always use the whole text for directive.
- GBCommentComponent *component = [GBCommentComponent componentWithStringValue:stringValue];
- component.markdownValue = [self stringByPreprocessingString:description];
+ GBCommentComponent *component = [self commentComponentFromString:stringValue];
[self.currentComment.longDescription registerComponent:component];
return YES;
}
@@ -226,12 +226,11 @@ - (BOOL)processBugBlockInString:(NSString *)string lines:(NSArray *)lines blockR
NSString *directive = [components objectAtIndex:1];
NSString *description = [components objectAtIndex:2];
NSString *stringValue = [NSString stringWithFormat:@"%@%@", directive, description];
- GBLogDebug(@"- Registering bug block %@ at %@...", [description normalizedDescription], self.sourceFileInfo);
+ GBLogDebug(@"- Registering bug block %@ at %@...", [description normalizedDescription], self.currentSourceInfo);
[self registerShortDescriptionFromLines:lines range:shortRange removePrefix:directive];
// Convert to markdown and register everything. We always use the whole text for directive.
- GBCommentComponent *component = [GBCommentComponent componentWithStringValue:stringValue];
- component.markdownValue = [self stringByPreprocessingString:description];
+ GBCommentComponent *component = [self commentComponentFromString:stringValue];
[self.currentComment.longDescription registerComponent:component];
return YES;
}
@@ -241,14 +240,17 @@ - (BOOL)processParamBlockInString:(NSString *)string lines:(NSArray *)lines bloc
if ([components count] == 0) return NO;
// Get data from captures. Index 1 is directive, index 2 name, index 3 description text.
- NSString *directive = [components objectAtIndex:1];
NSString *name = [components objectAtIndex:2];
NSString *description = [components objectAtIndex:3];
NSString *prefix = [string substringToIndex:[string rangeOfString:description].location];
- GBLogDebug(@"- Registering parameter %@ description %@ at %@...", name, [description normalizedDescription], self.sourceFileInfo);
+ GBLogDebug(@"- Registering parameter %@ description %@ at %@...", name, [description normalizedDescription], self.currentSourceInfo);
[self reserveShortDescriptionFromLines:lines range:shortRange removePrefix:prefix];
-
- // Convert to markdown and register everything. We always use the whole text for directive.
+
+ // Prepare object representation from the description and register the parameter to the comment.
+ GBCommentArgument *argument = [GBCommentArgument argumentWithName:name sourceInfo:self.currentSourceInfo];
+ GBCommentComponent *component = [self commentComponentFromString:description];
+ [argument.argumentDescription registerComponent:component];
+ [self.currentComment.methodParameters addObject:argument];
return YES;
}
@@ -257,14 +259,17 @@ - (BOOL)processExceptionBlockInString:(NSString *)string lines:(NSArray *)lines
if ([components count] == 0) return NO;
// Get data from captures. Index 1 is directive, index 2 name, index 3 description text.
- NSString *directive = [components objectAtIndex:1];
NSString *name = [components objectAtIndex:2];
NSString *description = [components objectAtIndex:3];
NSString *prefix = [string substringToIndex:[string rangeOfString:description].location];
- GBLogDebug(@"- Registering exception %@ description %@ at %@...", name, [description normalizedDescription], self.sourceFileInfo);
+ GBLogDebug(@"- Registering exception %@ description %@ at %@...", name, [description normalizedDescription], self.currentSourceInfo);
[self reserveShortDescriptionFromLines:lines range:shortRange removePrefix:prefix];
- // Convert to markdown and register everything. We always use the whole text for directive.
+ // Prepare object representation from the description and register the exception to the comment.
+ GBCommentArgument *argument = [GBCommentArgument argumentWithName:name sourceInfo:self.currentSourceInfo];
+ GBCommentComponent *component = [self commentComponentFromString:description];
+ [argument.argumentDescription registerComponent:component];
+ [self.currentComment.methodExceptions addObject:argument];
return YES;
}
@@ -273,13 +278,14 @@ - (BOOL)processReturnBlockInString:(NSString *)string lines:(NSArray *)lines blo
if ([components count] == 0) return NO;
// Get data from captures. Index 1 is directive, index 2 description text.
- NSString *directive = [components objectAtIndex:1];
NSString *description = [components objectAtIndex:2];
NSString *prefix = [string substringToIndex:[string rangeOfString:description].location];
- GBLogDebug(@"- Registering return description %@ at %@...", [description normalizedDescription], self.sourceFileInfo);
+ GBLogDebug(@"- Registering return description %@ at %@...", [description normalizedDescription], self.currentSourceInfo);
[self reserveShortDescriptionFromLines:lines range:shortRange removePrefix:prefix];
- // Convert to markdown and register everything. We always use the whole text for directive.
+ // Prepare object representation from the description and register the result to the comment.
+ GBCommentComponent *component = [self commentComponentFromString:description];
+ [self.currentComment.methodResult registerComponent:component];
return YES;
}
@@ -288,10 +294,9 @@ - (BOOL)processRelatedBlockInString:(NSString *)string lines:(NSArray *)lines bl
if ([components count] == 0) return NO;
// Get data from captures. Index 1 is directive, index 2 reference.
- NSString *directive = [components objectAtIndex:1];
NSString *reference = [components objectAtIndex:2];
NSString *prefix = [string substringToIndex:[string rangeOfString:reference].location];
- GBLogDebug(@"- Registering related symbol %@ at %@...", reference, self.sourceFileInfo);
+ GBLogDebug(@"- Registering related symbol %@ at %@...", reference, self.currentSourceInfo);
[self reserveShortDescriptionFromLines:lines range:shortRange removePrefix:prefix];
// Convert to markdown and register everything. We always use the whole text for directive.
@@ -308,7 +313,15 @@ - (BOOL)isLineMatchingDirectiveStatement:(NSString *)string {
return NO;
}
-#pragma mark Preprocessing methods
+#pragma mark Text processing methods
+
+- (GBCommentComponent *)commentComponentFromString:(NSString *)string {
+ // Preprocesses the given string to markdown representation, and returns a new GBCommentComponent registered with both values.
+ GBLogDebug(@"- Registering text block %@ at %@...", [string normalizedDescription], self.currentSourceInfo);
+ GBCommentComponent *result = [GBCommentComponent componentWithStringValue:string sourceInfo:self.currentSourceInfo];
+ result.markdownValue = [self stringByPreprocessingString:string];
+ return result;
+}
- (NSString *)stringByPreprocessingString:(NSString *)string {
return string;
@@ -326,17 +339,12 @@ - (NSString *)stringByCombiningTrimmedLines:(NSArray *)lines {
#pragma mark Properties
-- (NSString *)sourceFileInfo {
- // Helper method for simplifiying logging of current line and source file information.
- return [NSString stringWithFormat:@"%@@%lu", self.currentComment.sourceInfo.filename, self.currentStartLine];
-}
-
- (GBCommentComponentsProvider *)components {
return self.settings.commentComponents;
}
@synthesize reservedShortDescriptionData;
-@synthesize currentStartLine;
+@synthesize currentSourceInfo;
@synthesize currentComment;
@synthesize currentContext;
@synthesize settings;
View
3  Testing/GBCommentTesting.m
@@ -20,6 +20,9 @@ - (void)testInit_shouldSetupDefaultComponents {
GBComment *comment = [GBComment commentWithStringValue:@""];
// verify
assertThat(comment.longDescription, isNot(nil));
+ assertThat(comment.methodParameters, isNot(nil));
+ assertThat(comment.methodExceptions, isNot(nil));
+ assertThat(comment.methodResult, isNot(nil));
}
@end
View
69 Testing/GBCommentsProcessorTesting.m
@@ -98,15 +98,18 @@ - (void)testProcessCommentWithContextStore_descriptions_shouldHandleDescriptionF
GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:[GBTestObjectsRegistry realSettingsProvider]];
GBComment *comment1 = [GBComment commentWithStringValue:@"@param name Description\n\nParagraph"];
GBComment *comment2 = [GBComment commentWithStringValue:@"@param name Description\n\nParagraph\n\n@warning Warning"];
- GBComment *comment3 = [GBComment commentWithStringValue:@"Prefix\n\n@param name Description\n\nParagraph"];
+ GBComment *comment3 = [GBComment commentWithStringValue:@"@param name1 Description1\n@param name2 Description2"];
+ GBComment *comment4 = [GBComment commentWithStringValue:@"Prefix\n\n@param name Description\n\nParagraph"];
// execute
[processor processComment:comment1 withContext:nil store:store];
[processor processComment:comment2 withContext:nil store:store];
[processor processComment:comment3 withContext:nil store:store];
+ [processor processComment:comment4 withContext:nil store:store];
// verify - we only use parameter description if there is nothing else found in the comment.
[self assertComment:comment1 matchesShortDesc:@"Description" longDesc:nil];
[self assertComment:comment2 matchesShortDesc:@"Warning" longDesc:@"@warning Warning", nil];
- [self assertComment:comment3 matchesShortDesc:@"Prefix" longDesc:@"Prefix", nil];
+ [self assertComment:comment3 matchesShortDesc:@"Description1" longDesc:nil];
+ [self assertComment:comment4 matchesShortDesc:@"Prefix" longDesc:@"Prefix", nil];
}
- (void)testProcessCommentWithContextStore_descriptions_shouldHandleDescriptionForExceptionDirectiveRegardlessOfSettings {
@@ -115,15 +118,18 @@ - (void)testProcessCommentWithContextStore_descriptions_shouldHandleDescriptionF
GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:[GBTestObjectsRegistry realSettingsProvider]];
GBComment *comment1 = [GBComment commentWithStringValue:@"@exception name Description\n\nParagraph"];
GBComment *comment2 = [GBComment commentWithStringValue:@"@exception name Description\n\nParagraph\n\n@warning Warning"];
- GBComment *comment3 = [GBComment commentWithStringValue:@"Prefix\n\n@exception name Description\n\nParagraph"];
+ GBComment *comment3 = [GBComment commentWithStringValue:@"@exception name Description1\n@exception name2 Description2"];
+ GBComment *comment4 = [GBComment commentWithStringValue:@"Prefix\n\n@exception name Description\n\nParagraph"];
// execute
[processor processComment:comment1 withContext:nil store:store];
[processor processComment:comment2 withContext:nil store:store];
[processor processComment:comment3 withContext:nil store:store];
+ [processor processComment:comment4 withContext:nil store:store];
// verify - we only use parameter description if there is nothing else found in the comment.
[self assertComment:comment1 matchesShortDesc:@"Description" longDesc:nil];
[self assertComment:comment2 matchesShortDesc:@"Warning" longDesc:@"@warning Warning", nil];
- [self assertComment:comment3 matchesShortDesc:@"Prefix" longDesc:@"Prefix", nil];
+ [self assertComment:comment3 matchesShortDesc:@"Description1" longDesc:nil];
+ [self assertComment:comment4 matchesShortDesc:@"Prefix" longDesc:@"Prefix", nil];
}
- (void)testProcessCommentWithContextStore_descriptions_shouldHandleDescriptionForReturnDirectiveRegardlessOfSettings {
@@ -160,6 +166,61 @@ - (void)testProcessCommentWithContextStore_descriptions_shouldHandleRelatedSymbo
[self assertComment:comment3 matchesShortDesc:@"Prefix" longDesc:@"Prefix", nil];
}
+#pragma mark Method data testing
+
+- (void)testProcessCommentWithContextStore_methods_shouldRegisterAllParametersDescriptionsProperly {
+ // setup
+ GBStore *store = [GBTestObjectsRegistry store];
+ GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:[GBTestObjectsRegistry realSettingsProvider]];
+ GBComment *comment = [GBComment commentWithStringValue:@"@param name1 Description1\nLine2\n\nParagraph2\n@param name2 Description2"];
+ // execute
+ [processor processComment:comment withContext:nil store:store];
+ // verify - we only use parameter description if there is nothing else found in the comment.
+ [self assertMethodArguments:comment.methodParameters matches:@"name1", @"Description1\nLine2\n\nParagraph2", GBEND, @"name2", @"Description2", GBEND, nil];
+}
+
+- (void)testProcessCommentWithContextStore_methods_shouldRegisterAllParametersRegardlessOfEmptyLinesGaps {
+ // setup
+ GBStore *store = [GBTestObjectsRegistry store];
+ GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:[GBTestObjectsRegistry realSettingsProvider]];
+ GBComment *comment1 = [GBComment commentWithStringValue:@"@param name1 Description1\n@param name2 Description2"];
+ GBComment *comment2 = [GBComment commentWithStringValue:@"@param name1 Description1\n\n\n\n\n\n@param name2 Description2"];
+ // execute
+ [processor processComment:comment1 withContext:nil store:store];
+ [processor processComment:comment2 withContext:nil store:store];
+ // verify - we only use parameter description if there is nothing else found in the comment.
+ [self assertMethodArguments:comment1.methodParameters matches:@"name1", @"Description1", GBEND, @"name2", @"Description2", GBEND, nil];
+ [self assertMethodArguments:comment2.methodParameters matches:@"name1", @"Description1", GBEND, @"name2", @"Description2", GBEND, nil];
+}
+
+- (void)testProcessCommentWithContextStore_methods_shouldRegisterAllExceptionsRegardlessOfEmptyLinesGaps {
+ // setup
+ GBStore *store = [GBTestObjectsRegistry store];
+ GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:[GBTestObjectsRegistry realSettingsProvider]];
+ GBComment *comment1 = [GBComment commentWithStringValue:@"@exception name1 Description1\n@exception name2 Description2"];
+ GBComment *comment2 = [GBComment commentWithStringValue:@"@exception name1 Description1\n\n\n\n\n\n@exception name2 Description2"];
+ // execute
+ [processor processComment:comment1 withContext:nil store:store];
+ [processor processComment:comment2 withContext:nil store:store];
+ // verify - we only use parameter description if there is nothing else found in the comment.
+ [self assertMethodArguments:comment1.methodExceptions matches:@"name1", @"Description1", GBEND, @"name2", @"Description2", GBEND, nil];
+ [self assertMethodArguments:comment2.methodExceptions matches:@"name1", @"Description1", GBEND, @"name2", @"Description2", GBEND, nil];
+}
+
+- (void)testProcessCommentWithContextStore_methods_shouldRegisterResultDescriptionProperly {
+ // setup
+ GBStore *store = [GBTestObjectsRegistry store];
+ GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:[GBTestObjectsRegistry realSettingsProvider]];
+ GBComment *comment1 = [GBComment commentWithStringValue:@"@return Description"];
+ GBComment *comment2 = [GBComment commentWithStringValue:@"@return Description1\nLine2\n\nParagraph2"];
+ // execute
+ [processor processComment:comment1 withContext:nil store:store];
+ [processor processComment:comment2 withContext:nil store:store];
+ // verify - we only use parameter description if there is nothing else found in the comment.
+ [self assertCommentComponents:comment1.methodResult matchesStringValues:@"Description", nil];
+ [self assertCommentComponents:comment2.methodResult matchesStringValues:@"Description1\nLine2\n\nParagraph2", nil];
+}
+
#pragma mark Private methods testing
- (void)testFindCommentBlockInLinesBlockRangeShortRange_shouldDetectSingleComponent {
View
2  Testing/GBObjectsAssertor.h
@@ -14,6 +14,7 @@
#define GBDecorationTypeNone 9999
#define GBNULL [NSNull null]
+#define GBEND GBNULL
// Need to derive from GHTestCase otherwise GH macros used wouldn't work...
@interface GBObjectsAssertor : GHTestCase
@@ -28,5 +29,6 @@
- (void)assertCommentComponents:(GBCommentComponentsList *)components matchesValues:(NSString *)first values:(va_list)args;
- (void)assertCommentComponents:(GBCommentComponentsList *)components matchesStringValues:(NSString *)first, ... NS_REQUIRES_NIL_TERMINATION;
- (void)assertComment:(GBComment *)comment matchesShortDesc:(NSString *)shortValue longDesc:(NSString *)first, ... NS_REQUIRES_NIL_TERMINATION;
+- (void)assertMethodArguments:(NSArray *)arguments matches:(NSString *)name, ... NS_REQUIRES_NIL_TERMINATION;
@end
View
46 Testing/GBObjectsAssertor.m
@@ -139,7 +139,7 @@ - (void)assertFormattedComponents:(NSArray *)components match:(NSString *)first,
}
}
-#pragma mark Comment creation and assertion methods
+#pragma mark Comment assertion methods
- (void)assertCommentComponents:(GBCommentComponentsList *)components matchesValues:(NSString *)first values:(va_list)args {
NSMutableArray *expected = [NSMutableArray array];
@@ -173,4 +173,48 @@ - (void)assertComment:(GBComment *)comment matchesShortDesc:(NSString *)shortVal
va_end(args);
}
+- (void)assertMethodArguments:(NSArray *)arguments matches:(NSString *)name, ... {
+ NSMutableArray *expected = [NSMutableArray array];
+ if (name) {
+ va_list args;
+ va_start(args, name);
+ NSString *value;
+ NSMutableArray *strings = [NSMutableArray array];
+ while ((value = va_arg(args, NSString *))) {
+ if (!name) {
+ name = value;
+ } else if (value != (id)GBEND) {
+ [strings addObject:value];
+ } else {
+ NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:name, @"name", strings, @"comps", nil];
+ [expected addObject:data];
+ [strings removeAllObjects];
+ name = nil;
+ }
+ }
+ va_end(args);
+ if (name) [NSException raise:@"Expecting GBEND to end method argument descriptions list!"];
+ }
+ assertThatInteger([arguments count], equalToInteger([expected count]));
+ for (NSUInteger i=0; i<[arguments count]; i++) {
+ GBCommentArgument *argument = [arguments objectAtIndex:i];
+ NSDictionary *data = [expected objectAtIndex:i];
+
+ NSString *expectedName = [data objectForKey:@"name"];
+ assertThat(argument.argumentName, is(expectedName));
+
+ NSMutableArray *expectedComps = [data objectForKey:@"comps"];
+ if ([expectedComps count] > 0) {
+ NSString *firstExpectedComp = [expectedComps firstObject];
+ [expectedComps removeObjectAtIndex:0];
+ char *argList = NULL;
+ if ([expectedComps count] > 0) {
+ argList = (char *)malloc(sizeof(NSString *) * [expectedComps count]);
+ [expectedComps getObjects:(id *)argList];
+ }
+ [self assertCommentComponents:argument.argumentDescription matchesValues:firstExpectedComp values:(__va_list_tag *)argList];
+ }
+ }
+}
+
@end
View
8 appledoc.xcodeproj/project.pbxproj
@@ -188,6 +188,8 @@
73F568D312A22CFF00A72BB2 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73F568D212A22CFF00A72BB2 /* CoreServices.framework */; };
73F568D412A22CFF00A72BB2 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73F568D212A22CFF00A72BB2 /* CoreServices.framework */; };
73F70DB71227B34300D19EBA /* GBComment.m in Sources */ = {isa = PBXBuildFile; fileRef = 73F70DB61227B34300D19EBA /* GBComment.m */; };
+ 73FAC0F9130BCB6F00F22475 /* GBCommentArgument.m in Sources */ = {isa = PBXBuildFile; fileRef = 73FAC0F8130BCB6F00F22475 /* GBCommentArgument.m */; };
+ 73FAC0FA130BCB6F00F22475 /* GBCommentArgument.m in Sources */ = {isa = PBXBuildFile; fileRef = 73FAC0F8130BCB6F00F22475 /* GBCommentArgument.m */; };
73FC6DB511FCCCC600AAD0B9 /* GBParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 73FC6DB411FCCCC600AAD0B9 /* GBParser.m */; };
73FC6DDC11FCCE6B00AAD0B9 /* GBObjectiveCParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 73FC6DDA11FCCE6B00AAD0B9 /* GBObjectiveCParser.m */; };
73FC6E1011FCD54400AAD0B9 /* GBStore.m in Sources */ = {isa = PBXBuildFile; fileRef = 73FC6E0E11FCD54400AAD0B9 /* GBStore.m */; };
@@ -380,6 +382,8 @@
73F568D212A22CFF00A72BB2 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
73F70DB51227B34300D19EBA /* GBComment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBComment.h; sourceTree = "<group>"; };
73F70DB61227B34300D19EBA /* GBComment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBComment.m; sourceTree = "<group>"; };
+ 73FAC0F7130BCB6F00F22475 /* GBCommentArgument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBCommentArgument.h; sourceTree = "<group>"; };
+ 73FAC0F8130BCB6F00F22475 /* GBCommentArgument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBCommentArgument.m; sourceTree = "<group>"; };
73FC6D8D11FCCB7000AAD0B9 /* AppledocTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "AppledocTests-Info.plist"; path = "../AppledocTests-Info.plist"; sourceTree = "<group>"; };
73FC6DB311FCCCC600AAD0B9 /* GBParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBParser.h; sourceTree = "<group>"; };
73FC6DB411FCCCC600AAD0B9 /* GBParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBParser.m; sourceTree = "<group>"; };
@@ -832,6 +836,8 @@
73AF4EC713093570001152DB /* GBCommentComponent.m */,
73AF4ECA130938F3001152DB /* GBCommentComponentsList.h */,
73AF4ECB130938F3001152DB /* GBCommentComponentsList.m */,
+ 73FAC0F7130BCB6F00F22475 /* GBCommentArgument.h */,
+ 73FAC0F8130BCB6F00F22475 /* GBCommentArgument.m */,
);
name = Comments;
sourceTree = "<group>";
@@ -1211,6 +1217,7 @@
73AF4ECD130938F3001152DB /* GBCommentComponentsList.m in Sources */,
73AF4ECF13093B5A001152DB /* GBCommentComponentsListTesting.m in Sources */,
73B99A891309452E00890FA0 /* GBCommentsProcessorTesting.m in Sources */,
+ 73FAC0FA130BCB6F00F22475 /* GBCommentArgument.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1291,6 +1298,7 @@
735B2387130418A100704844 /* GBTemplateFilesHandler.m in Sources */,
73AF4EC813093570001152DB /* GBCommentComponent.m in Sources */,
73AF4ECC130938F3001152DB /* GBCommentComponentsList.m in Sources */,
+ 73FAC0F9130BCB6F00F22475 /* GBCommentArgument.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Please sign in to comment.
Something went wrong with that request. Please try again.