Skip to content

Commit

Permalink
Added detect cross references task to the project.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaz committed Nov 24, 2012
1 parent 17c977d commit 503d409
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 0 deletions.
39 changes: 39 additions & 0 deletions AppledocTests/Processing/DetectCrossReferencesTaskTests.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// DetectCrossReferencesTaskTests.m
// appledoc
//
// Created by Tomaz Kragelj on 24/11/12.
// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
//

#import "Store.h"
#import "DetectCrossReferencesTask.h"
#import "TestCaseBase.hh"

static void runWithTask(void(^handler)(DetectCrossReferencesTask *task, id comment)) {
DetectCrossReferencesTask *task = [[DetectCrossReferencesTask alloc] init];
CommentInfo *comment = [[CommentInfo alloc] init];
handler(task, comment);
[task release];
}

static void setupComment(id comment, NSString *first ...) {
va_list args;
va_start(args, first);
NSMutableArray *sections = [@[] mutableCopy];
for (NSString *arg=first; arg!=nil; arg=va_arg(args, NSString *)) {
[sections addObject:arg];
}
va_end(args);

if ([comment isKindOfClass:[CommentInfo class]])
[comment setSourceSections:sections];
else
[given([comment sourceSections]) willReturn:sections];
}

#pragma mark -

TEST_BEGIN(DetectCrossReferencesTaskTests)

TEST_END
13 changes: 13 additions & 0 deletions AppledocTests/Processing/ProcessorTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ - (NSInteger)processCommentForObject:(ObjectInfoBase *)object context:(ObjectInf
// execute & verify
processor.splitCommentToSectionsTask should_not be_nil();
processor.registerCommentComponentsTask should_not be_nil();
processor.detectCrossReferencesTask should_not be_nil();
});
});
});
Expand Down Expand Up @@ -210,6 +211,18 @@ - (NSInteger)processCommentForObject:(ObjectInfoBase *)object context:(ObjectInf
});
});

it(@"should invoke detect cross references task if comment given", ^{
runWithProcessor(^(Processor *processor) {
// setup
[given([object comment]) willReturn:comment];
processor.detectCrossReferencesTask = componentsTask;
// execute
[processor processCommentForObject:object context:context];
// verify
gbcatch([verify(componentsTask) processCommentForObject:object context:context]);
});
});

it(@"should ignore all required tasks if comment is not given", ^{
runWithProcessor(^(Processor *processor) {
// setup
Expand Down
12 changes: 12 additions & 0 deletions appledoc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@
73D76C5B1660BBE900B611AB /* RegisterCommentComponentsTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 73D76C5A1660BBE900B611AB /* RegisterCommentComponentsTask.m */; };
73D76C5C1660BBE900B611AB /* RegisterCommentComponentsTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 73D76C5A1660BBE900B611AB /* RegisterCommentComponentsTask.m */; };
73D76C5E1660BF9A00B611AB /* RegisterCommentComponentsTaskTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73D76C5D1660BF9A00B611AB /* RegisterCommentComponentsTaskTests.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
73D76C6916613B5D00B611AB /* DetectCrossReferencesTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 73D76C6816613B5D00B611AB /* DetectCrossReferencesTask.m */; };
73D76C6A16613B5D00B611AB /* DetectCrossReferencesTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 73D76C6816613B5D00B611AB /* DetectCrossReferencesTask.m */; };
73D76C6D16613C4700B611AB /* DetectCrossReferencesTaskTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73D76C6C16613C4600B611AB /* DetectCrossReferencesTaskTests.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
73D8651B153FEBD900BDAAFE /* MethodArgumentInfoTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73D8651A153FEBD900BDAAFE /* MethodArgumentInfoTests.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
73DC6D2F164800B900C1AA0D /* CommentSectionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 73DC6D2E164800B800C1AA0D /* CommentSectionInfo.m */; };
73DC6D30164800B900C1AA0D /* CommentSectionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 73DC6D2E164800B800C1AA0D /* CommentSectionInfo.m */; };
Expand Down Expand Up @@ -340,6 +343,9 @@
73D76C591660BBD900B611AB /* RegisterCommentComponentsTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterCommentComponentsTask.h; sourceTree = "<group>"; };
73D76C5A1660BBE900B611AB /* RegisterCommentComponentsTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegisterCommentComponentsTask.m; sourceTree = "<group>"; };
73D76C5D1660BF9A00B611AB /* RegisterCommentComponentsTaskTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RegisterCommentComponentsTaskTests.mm; sourceTree = "<group>"; };
73D76C6716613B5D00B611AB /* DetectCrossReferencesTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetectCrossReferencesTask.h; sourceTree = "<group>"; };
73D76C6816613B5D00B611AB /* DetectCrossReferencesTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetectCrossReferencesTask.m; sourceTree = "<group>"; };
73D76C6C16613C4600B611AB /* DetectCrossReferencesTaskTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DetectCrossReferencesTaskTests.mm; sourceTree = "<group>"; };
73D8651A153FEBD900BDAAFE /* MethodArgumentInfoTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MethodArgumentInfoTests.mm; sourceTree = "<group>"; };
73DC6D2D164800B800C1AA0D /* CommentSectionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentSectionInfo.h; sourceTree = "<group>"; };
73DC6D2E164800B800C1AA0D /* CommentSectionInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentSectionInfo.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -644,6 +650,8 @@
73A3E48A15D8288D00769863 /* SplitCommentToSectionsTask.m */,
73D76C591660BBD900B611AB /* RegisterCommentComponentsTask.h */,
73D76C5A1660BBE900B611AB /* RegisterCommentComponentsTask.m */,
73D76C6716613B5D00B611AB /* DetectCrossReferencesTask.h */,
73D76C6816613B5D00B611AB /* DetectCrossReferencesTask.m */,
73AEC5C715DAB33700830AC7 /* MarkdownParser.h */,
73AEC5C815DAB33700830AC7 /* MarkdownParser.m */,
);
Expand All @@ -657,6 +665,7 @@
73CDF8B715E9415E0046C8E1 /* ProcessorTaskTests.mm */,
73A3E48D15D8369500769863 /* SplitCommentToSectionsTaskTests.mm */,
73D76C5D1660BF9A00B611AB /* RegisterCommentComponentsTaskTests.mm */,
73D76C6C16613C4600B611AB /* DetectCrossReferencesTaskTests.mm */,
);
path = Processing;
sourceTree = "<group>";
Expand Down Expand Up @@ -963,6 +972,8 @@
73DC6D30164800B900C1AA0D /* CommentSectionInfo.m in Sources */,
73D76C5C1660BBE900B611AB /* RegisterCommentComponentsTask.m in Sources */,
73D76C5E1660BF9A00B611AB /* RegisterCommentComponentsTaskTests.mm in Sources */,
73D76C6A16613B5D00B611AB /* DetectCrossReferencesTask.m in Sources */,
73D76C6D16613C4700B611AB /* DetectCrossReferencesTaskTests.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1027,6 +1038,7 @@
738F2CAD1643035C00BEC518 /* NSRegularExpression+Appledoc.m in Sources */,
73DC6D2F164800B900C1AA0D /* CommentSectionInfo.m in Sources */,
73D76C5B1660BBE900B611AB /* RegisterCommentComponentsTask.m in Sources */,
73D76C6916613B5D00B611AB /* DetectCrossReferencesTask.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
13 changes: 13 additions & 0 deletions appledoc/Processing/DetectCrossReferencesTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// DetectCrossReferencesTask.h
// appledoc
//
// Created by Tomaz Kragelj on 24.11.12.
// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
//

#import "ProcessorTask.h"

@interface DetectCrossReferencesTask : ProcessorTask

@end
21 changes: 21 additions & 0 deletions appledoc/Processing/DetectCrossReferencesTask.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// DetectCrossReferencesTask.m
// appledoc
//
// Created by Tomaz Kragelj on 24.11.12.
// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
//

#import "Objects.h"
#import "Store.h"
#import "DetectCrossReferencesTask.h"

@implementation DetectCrossReferencesTask

#pragma mark - Processing

- (NSInteger)processComment:(CommentInfo *)comment {
return GBResultOk;
}

@end
1 change: 1 addition & 0 deletions appledoc/Processing/Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@

@property (nonatomic, strong) ProcessorTask *splitCommentToSectionsTask;
@property (nonatomic, strong) ProcessorTask *registerCommentComponentsTask;
@property (nonatomic, strong) ProcessorTask *detectCrossReferencesTask;

@end
8 changes: 8 additions & 0 deletions appledoc/Processing/Processor.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ - (NSInteger)processCommentForObject:(ObjectInfoBase *)object context:(ObjectInf
NSInteger result = GBResultOk;
GB_PROCESS([self.splitCommentToSectionsTask processCommentForObject:object context:context]);
GB_PROCESS([self.registerCommentComponentsTask processCommentForObject:object context:context]);
GB_PROCESS([self.detectCrossReferencesTask processCommentForObject:object context:context]);
return result;
}

Expand All @@ -92,4 +93,11 @@ - (ProcessorTask *)registerCommentComponentsTask {
return _registerCommentComponentsTask;
}

- (ProcessorTask *)detectCrossReferencesTask {
if (_detectCrossReferencesTask) return _detectCrossReferencesTask;
LogDebug(@"Initializing detect cross references task due to first access...");
_detectCrossReferencesTask = [[ProcessorTask alloc] init];
return _detectCrossReferencesTask;
}

@end

0 comments on commit 503d409

Please sign in to comment.