Permalink
Browse files

Merge branch 'fetch-documentation' into experimental

  • Loading branch information...
2 parents 4c47395 + 91d6dc3 commit 89fc82c3b40cf64a2c946bfb374c4f437d3fd39a @tomaz tomaz committed Dec 12, 2012
View
12 AppledocTests/Common/SettingsTests.mm
@@ -62,8 +62,10 @@ static void runWithSettings(void(^handler)(GBSettings *settings)) {
it(@"should work for comment related settings", ^{
runWithSettings(^(GBSettings *settings) {
// execute
+ [settings setBool:YES forKey:GBOptions.searchMissingComments];
[settings setObject:@"crossrefs" forKey:GBOptions.crossRefsFormat];
// verify
+ settings.searchForMissingComments should equal(YES);
settings.crossRefsFormat should equal(@"crossrefs");
});
});
@@ -73,19 +75,9 @@ static void runWithSettings(void(^handler)(GBSettings *settings)) {
// execute
[settings setInteger:2 forKey:GBOptions.loggingFormat];
[settings setInteger:3 forKey:GBOptions.loggingLevel];
- [settings setBool:YES forKey:GBOptions.loggingInternalEnabled];
- [settings setBool:YES forKey:GBOptions.loggingCommonEnabled];
- [settings setBool:YES forKey:GBOptions.loggingStoreEnabled];
- [settings setBool:YES forKey:GBOptions.loggingParsingEnabled];
- [settings setBool:YES forKey:GBOptions.loggingProcessingEnabled];
// verify
settings.loggingFormat should equal(2);
settings.loggingLevel should equal(3);
- settings.loggingInternalEnabled should equal(YES);
- settings.loggingCommonEnabled should equal(YES);
- settings.loggingStoreEnabled should equal(YES);
- settings.loggingParsingEnabled should equal(YES);
- settings.loggingProcessingEnabled should equal(YES);
});
});
View
267 AppledocTests/Processing/FetchDocumentationTaskTests.mm
@@ -0,0 +1,267 @@
+//
+// FetchDocumentationTaskTests.m
+// appledoc
+//
+// Created by Tomaz Kragelj on 7/12/12.
+// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
+//
+
+#import "StoreMocks.h"
+#import "FetchDocumentationTask.h"
+#import "TestCaseBase.hh"
+
+#define GBSections [comment sourceSections]
+
+#pragma mark -
+
+static void runWithTask(id store, id settings, void(^handler)(FetchDocumentationTask *task, id store, id settings)) {
+ FetchDocumentationTask *task = [[FetchDocumentationTask alloc] init];
+ task.settings = settings ? settings : mock([GBSettings class]);
+ task.store = store ? store : mock([Store class]);
+ handler(task, task.store, task.settings);
+ [task release];
+}
+
+static void runWithTask(void(^handler)(FetchDocumentationTask *task, id store, id settings)) {
+ runWithTask(nil, nil, handler);
+}
+
+static id createBaseClass() {
+ return [StoreMocks mockClass:@"BaseClass" block:^(id object) { }];
+}
+
+static id createDerivedClass(id baseClass) {
+ return [StoreMocks mockClass:@"DerivedClass" block:^(id object) {
+ [StoreMocks add:object asDerivedClassFrom:baseClass];
+ }];
+}
+
+static id createAdoptedProtocol(NSString *name, id adoptedInObject) {
+ return [StoreMocks mockProtocol:name block:^(id object) {
+ [StoreMocks add:adoptedInObject asAdopting:object];
+ }];
+}
+
+static id createMethod(NSString *selector, id parent) {
+ BOOL isClassMethod = [selector hasPrefix:@"+"];
+ return [StoreMocks createMethod:selector block:^(MethodInfo *object) {
+ if (isClassMethod)
+ [StoreMocks add:object asClassMethodOf:parent];
+ else
+ [StoreMocks add:object asInstanceMethodOf:parent];
+ }];
+}
+
+static id createCommentedMethod(NSString *selector, id parent) {
+ id result = createMethod(selector, parent);
+ [StoreMocks addMockCommentTo:result];
+ return result;
+}
+
+static id createProperty(NSString *name, id parent) {
+ return [StoreMocks createProperty:name block:^(PropertyInfo *object) {
+ [StoreMocks add:object asPropertyOf:parent];
+ }];
+}
+
+static id createCommentedProperty(NSString *name, id parent) {
+ id result = createProperty(name, parent);
+ [StoreMocks addMockCommentTo:result];
+ return result;
+}
+
+#define GBSearch [info[@"search"] boolValue]
+#define GBVerify(d,b) if (GBSearch) d.comment should equal(b.comment); else d.comment should be_nil()
+
+#pragma mark -
+
+TEST_BEGIN(FetchDocumentationTaskTests)
+
+describe(@"copy documentation from super classes:", ^{
+ sharedExamplesFor(@"examples", ^(NSDictionary *info) {
+ __block id settings;
+
+ beforeEach(^{
+ settings = mock([GBSettings class]);
+ [given([settings searchForMissingComments]) willReturnBool:GBSearch];
+ });
+
+ it(@"should handle class method", ^{
+ runWithTask(nil, settings, ^(FetchDocumentationTask *task, id store, id settings) {
+ // setup
+ id baseClass = createBaseClass();
+ id derivedClass = createDerivedClass(baseClass);
+ MethodInfo *baseMethod = createCommentedMethod(@"+method", baseClass);
+ MethodInfo *derivedMethod = createMethod(@"+method", derivedClass);
+ [given([store storeClasses]) willReturn:@[ baseClass, derivedClass ]];
+ // execute
+ [task runTask];
+ // verify
+ GBVerify(derivedMethod, baseMethod);
+ });
+ });
+
+ it(@"should handle instance method", ^{
+ runWithTask(nil, settings, ^(FetchDocumentationTask *task, id store, id settings) {
+ // setup
+ id baseClass = createBaseClass();
+ id derivedClass = createDerivedClass(baseClass);
+ MethodInfo *baseMethod = createCommentedMethod(@"-method", baseClass);
+ MethodInfo *derivedMethod = createMethod(@"-method", derivedClass);
+ [given([store storeClasses]) willReturn:@[ baseClass, derivedClass ]];
+ // execute
+ [task runTask];
+ // verify
+ GBVerify(derivedMethod, baseMethod);
+ });
+ });
+
+ it(@"should copy property from base class", ^{
+ runWithTask(nil, settings, ^(FetchDocumentationTask *task, id store, id settings) {
+ // setup
+ id baseClass = createBaseClass();
+ id derivedClass = createDerivedClass(baseClass);
+ PropertyInfo *baseProperty = createCommentedProperty(@"property", baseClass);
+ PropertyInfo *derivedProperty = createProperty(@"property", derivedClass);
+ [given([store storeClasses]) willReturn:@[ baseClass, derivedClass ]];
+ // execute
+ [task runTask];
+ // verify
+ GBVerify(derivedProperty, baseProperty);
+ });
+ });
+ });
+
+ describe(@"search enabled:", ^{
+ beforeEach(^{
+ [[SpecHelper specHelper] sharedExampleContext][@"search"] = @(YES);
+ });
+ itShouldBehaveLike(@"examples");
+ });
+
+ describe(@"search disabled:", ^{
+ beforeEach(^{
+ [[SpecHelper specHelper] sharedExampleContext][@"search"] = @(NO);
+ });
+ itShouldBehaveLike(@"examples");
+ });
+});
+
+describe(@"adopted protocols:", ^{
+ // This block describes actual unit tests.
+ sharedExamplesFor(@"examples", ^(NSDictionary *info) {
+ __block id store;
+ __block id settings;
+
+ beforeEach(^{
+ store = info[@"store"];
+ settings = mock([GBSettings class]);
+ [given([settings searchForMissingComments]) willReturnBool:GBSearch];
+ });
+
+ it(@"should fetch for class methods", ^{
+ runWithTask(store, settings, ^(FetchDocumentationTask *task, id store, id settings) {
+ // setup
+ id object = info[@"object"];
+ id protocol = createAdoptedProtocol(@"Protocol", object);
+ MethodInfo *objectClassMethod = createMethod(@"+method", object);
+ ObjectInfoBase *protocolClassMethod = createCommentedMethod(@"+method", protocol);
+ // execute
+ [task runTask];
+ // verify
+ GBVerify(objectClassMethod, protocolClassMethod);
+ });
+ });
+
+ it(@"should fetch for instance methods", ^{
+ runWithTask(store, settings, ^(FetchDocumentationTask *task, id store, id settings) {
+ // setup
+ id object = info[@"object"];
+ id protocol = createAdoptedProtocol(@"Protocol", object);
+ MethodInfo *objectInstanceMethod = createMethod(@"-method", object);
+ ObjectInfoBase *protocolInstanceMethod = createCommentedMethod(@"-method", protocol);
+ // execute
+ [task runTask];
+ // verify
+ GBVerify(objectInstanceMethod, protocolInstanceMethod);
+ });
+ });
+
+ it(@"should fetch for properties", ^{
+ runWithTask(store, settings, ^(FetchDocumentationTask *task, id store, id settings) {
+ // setup
+ id object = info[@"object"];
+ id protocol = createAdoptedProtocol(@"Protocol", object);
+ PropertyInfo *objectProperty = createProperty(@"property", object);
+ ObjectInfoBase *protocolProperty = createCommentedProperty(@"property", protocol);
+ // execute
+ [task runTask];
+ // verify
+ GBVerify(objectProperty, protocolProperty);
+ });
+ });
+ });
+
+ // This block described variants for above tests (repeats the tests for different types of objects).
+ sharedExamplesFor(@"variants", ^(NSDictionary *info) {
+ describe(@"classes:", ^{
+ beforeEach(^{
+ id store = mock([Store class]);
+ id object = mock([ClassInfo class]);
+ [given([store storeClasses]) willReturn:@[ object ]];
+ [[SpecHelper specHelper] sharedExampleContext][@"store"] = store;
+ [[SpecHelper specHelper] sharedExampleContext][@"object"] = object;
+ });
+ itShouldBehaveLike(@"examples");
+ });
+
+ describe(@"extensions:", ^{
+ beforeEach(^{
+ id store = mock([Store class]);
+ id object = mock([CategoryInfo class]);
+ [given([store storeExtensions]) willReturn:@[ object ]];
+ [[SpecHelper specHelper] sharedExampleContext][@"store"] = store;
+ [[SpecHelper specHelper] sharedExampleContext][@"object"] = object;
+ });
+ itShouldBehaveLike(@"examples");
+ });
+
+ describe(@"categories:", ^{
+ beforeEach(^{
+ id store = mock([Store class]);
+ id object = mock([CategoryInfo class]);
+ [given([store storeCategories]) willReturn:@[ object ]];
+ [[SpecHelper specHelper] sharedExampleContext][@"store"] = store;
+ [[SpecHelper specHelper] sharedExampleContext][@"object"] = object;
+ });
+ itShouldBehaveLike(@"examples");
+ });
+
+ describe(@"protocols:", ^{
+ beforeEach(^{
+ id store = mock([Store class]);
+ id object = mock([ProtocolInfo class]);
+ [given([store storeProtocols]) willReturn:@[ object ]];
+ [[SpecHelper specHelper] sharedExampleContext][@"store"] = store;
+ [[SpecHelper specHelper] sharedExampleContext][@"object"] = object;
+ });
+ itShouldBehaveLike(@"examples");
+ });
+ });
+
+ // These two blocks repeat all the variants, for all the examples, for search enabled or disabled.
+ describe(@"search enabled:", ^{
+ beforeEach(^{
+ [[SpecHelper specHelper] sharedExampleContext][@"search"] = @(YES);
+ });
+ itShouldBehaveLike(@"variants");
+ });
+ describe(@"search disabled:", ^{
+ beforeEach(^{
+ [[SpecHelper specHelper] sharedExampleContext][@"search"] = @(NO);
+ });
+ itShouldBehaveLike(@"variants");
+ });
+});
+
+TEST_END
View
119 AppledocTests/Processing/LinkKnownObjectsTaskTests.mm
@@ -7,8 +7,9 @@
//
#import "Store.h"
-#import "LinkKnownObjectsTask.h"
#import "TestCaseBase.hh"
+#import "StoreMocks.h"
+#import "LinkKnownObjectsTask.h"
#define GBSections [comment sourceSections]
@@ -21,59 +22,25 @@ static void runWithTask(void(^handler)(LinkKnownObjectsTask *task, id store)) {
[task release];
}
-static id createInterface(void(^handler)(InterfaceInfoBase *interface)) {
- InterfaceInfoBase *result = [[InterfaceInfoBase alloc] init];
- handler(result);
- return result;
-}
-
-static id createClass(void(^handler)(ClassInfo *info)) {
- ClassInfo *result = [[ClassInfo alloc] init];
- handler(result);
- return result;
-}
-
static id createClass(NSString *name) {
- id result = mock([ClassInfo class]);
- [given([result nameOfClass]) willReturn:name];
- return result;
-}
-
-static id createCategory(void(^handler)(CategoryInfo *info)) {
- CategoryInfo *result = [[CategoryInfo alloc] init];
- handler(result);
- return result;
-}
-
-static id createProtocol(void(^handler)(ProtocolInfo *info)) {
- ProtocolInfo *result = [[ProtocolInfo alloc] init];
- handler(result);
- return result;
+ return [StoreMocks mockClass:name block:^(id object) { }];
}
static id createProtocol(NSString *name) {
- id result = mock([ProtocolInfo class]);
- [given([result nameOfProtocol]) willReturn:name];
- return result;
-}
-
-static void deriveClass(ClassInfo *object, NSString *name) {
- object.classSuperClass.nameOfObject = name;
+ return [StoreMocks mockProtocol:name block:^(id object) { }];
}
-static void extendClass(CategoryInfo *object, NSString *name) {
- object.categoryClass.nameOfObject = name;
+static id createDerivedClass(NSString *name, NSString *baseName) {
+ return [StoreMocks createClass:^(ClassInfo *object) {
+ object.nameOfClass = name;
+ [object derive:baseName];
+ }];
}
-static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
- va_list args;
- va_start(args, first);
- for (NSString *arg=first; arg!=nil; arg=va_arg(args, NSString *)) {
- ObjectLinkInfo *link = [[ObjectLinkInfo alloc] init];
- link.nameOfObject = arg;
- [interface.interfaceAdoptedProtocols addObject:link];
- }
- va_end(args);
+static id createCategory(NSString *className) {
+ return [StoreMocks createCategory:^(CategoryInfo *object) {
+ [object extend:className];
+ }];
}
#pragma mark -
@@ -85,9 +52,9 @@ static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
it(@"should link classes to known protocols", ^{
runWithTask(^(LinkKnownObjectsTask *task, id store) {
// setup
- InterfaceInfoBase *class1 = createInterface(^(InterfaceInfoBase *interface) {
- adoptProtocols(interface, @"MyProtocol1", @"MyProtocol2", @"UnknownProtocol", nil);
- });
+ ClassInfo *class1 = [StoreMocks createClass:^(ClassInfo *object) {
+ [object adopt:@"MyProtocol1", @"MyProtocol2", @"UnknownProtocol", nil];
+ }];
id protocol1 = createProtocol(@"MyProtocol1");
id protocol2 = createProtocol(@"MyProtocol2");
[given([store storeProtocols]) willReturn:@[ protocol1, protocol2 ]];
@@ -104,10 +71,9 @@ static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
it(@"should link extensions to known protocols", ^{
runWithTask(^(LinkKnownObjectsTask *task, id store) {
- // setup
- InterfaceInfoBase *extension1 = createCategory(^(CategoryInfo *interface) {
- adoptProtocols(interface, @"MyProtocol1", @"MyProtocol2", @"UnknownProtocol", nil);
- });
+ CategoryInfo *extension1 = [StoreMocks createCategory:^(CategoryInfo *object) {
+ [object adopt:@"MyProtocol1", @"MyProtocol2", @"UnknownProtocol", nil];
+ }];
id protocol1 = createProtocol(@"MyProtocol1");
id protocol2 = createProtocol(@"MyProtocol2");
[given([store storeProtocols]) willReturn:@[ protocol1, protocol2 ]];
@@ -124,9 +90,9 @@ static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
it(@"should link categories to known protocols", ^{
runWithTask(^(LinkKnownObjectsTask *task, id store) {
// setup
- InterfaceInfoBase *category1 = createCategory(^(CategoryInfo *interface) {
- adoptProtocols(interface, @"MyProtocol1", @"MyProtocol2", @"UnknownProtocol", nil);
- });
+ CategoryInfo *category1 = [StoreMocks createCategory:^(CategoryInfo *object) {
+ [object adopt:@"MyProtocol1", @"MyProtocol2", @"UnknownProtocol", nil];
+ }];
id protocol1 = createProtocol(@"MyProtocol1");
id protocol2 = createProtocol(@"MyProtocol2");
[given([store storeProtocols]) willReturn:@[ protocol1, protocol2 ]];
@@ -143,9 +109,9 @@ static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
it(@"should link protocols to known protocols", ^{
runWithTask(^(LinkKnownObjectsTask *task, id store) {
// setup
- ProtocolInfo *protocol1 = createProtocol(^(ProtocolInfo *info) {
- adoptProtocols(info, @"MyProtocol1", @"MyProtocol2", @"UnknownProtocol", nil);
- });
+ ProtocolInfo *protocol1 = [StoreMocks createProtocol:^(ProtocolInfo *object) {
+ [object adopt:@"MyProtocol1", @"MyProtocol2", @"UnknownProtocol", nil];
+ }];
id protocol2 = createProtocol(@"MyProtocol1");
id protocol3 = createProtocol(@"MyProtocol2");
[given([store storeProtocols]) willReturn:@[ protocol1, protocol2, protocol3 ]];
@@ -163,9 +129,7 @@ static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
it(@"should link to known super classes", ^{
runWithTask(^(LinkKnownObjectsTask *task, id store) {
// setup
- ClassInfo *class1 = createClass(^(ClassInfo *info) {
- deriveClass(info, @"MyBaseClass");
- });
+ ClassInfo *class1 = createDerivedClass(@"MyClass", @"MyBaseClass");
id class2 = createClass(@"MyBaseClass");
[given([store storeClasses]) willReturn:@[ class1, class2 ]];
// execute
@@ -178,18 +142,9 @@ static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
it(@"should handle multiple depths of class hierarchies", ^{
runWithTask(^(LinkKnownObjectsTask *task, id store) {
// setup
- ClassInfo *class1 = createClass(^(ClassInfo *info) {
- info.nameOfClass = @"Class1";
- deriveClass(info, @"Class2");
- });
- ClassInfo *class2 = createClass(^(ClassInfo *info) {
- info.nameOfClass = @"Class2";
- deriveClass(info, @"Class3");
- });
- ClassInfo *class3 = createClass(^(ClassInfo *info) {
- info.nameOfClass = @"Class3";
- deriveClass(info, @"Unknown");
- });
+ ClassInfo *class1 = createDerivedClass(@"Class1", @"Class2");
+ ClassInfo *class2 = createDerivedClass(@"Class2", @"Class3");
+ ClassInfo *class3 = createDerivedClass(@"Class3", @"UnknownClass");
[given([store storeClasses]) willReturn:@[ class1, class2, class3 ]];
// execute
[task runTask];
@@ -205,12 +160,8 @@ static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
it(@"should link extensions to known classes", ^{
runWithTask(^(LinkKnownObjectsTask *task, id store) {
// setup
- CategoryInfo *extension1 = createCategory(^(CategoryInfo *info) {
- extendClass(info, @"Class1");
- });
- CategoryInfo *extension2 = createCategory(^(CategoryInfo *info) {
- extendClass(info, @"UnknownClass");
- });
+ CategoryInfo *extension1 = createCategory(@"Class1");
+ CategoryInfo *extension2 = createCategory(@"UnknownClass");
ClassInfo *class1 = createClass(@"Class1");
[given([store storeExtensions]) willReturn:@[ extension1, extension2 ]];
[given([store storeClasses]) willReturn:@[ class1 ]];
@@ -225,12 +176,8 @@ static void adoptProtocols(InterfaceInfoBase *interface, NSString *first, ...) {
it(@"should link categories to known classes", ^{
runWithTask(^(LinkKnownObjectsTask *task, id store) {
// setup
- CategoryInfo *category1 = createCategory(^(CategoryInfo *info) {
- extendClass(info, @"Class1");
- });
- CategoryInfo *category2 = createCategory(^(CategoryInfo *info) {
- extendClass(info, @"UnknownClass");
- });
+ CategoryInfo *category1 = createCategory(@"Class1");
+ CategoryInfo *category2 = createCategory(@"UnknownClass");
ClassInfo *class1 = createClass(@"Class1");
[given([store storeCategories]) willReturn:@[ category1, category2 ]];
[given([store storeClasses]) willReturn:@[ class1 ]];
View
171 AppledocTests/Processing/ProcessorTests.mm
@@ -10,13 +10,22 @@
#import "Processor.h"
#import "TestCaseBase.hh"
-static void runWithProcessor(void(^handler)(Processor *processor)) {
+static void runWithProcessor(BOOL mockedTasks, void(^handler)(Processor *processor)) {
Processor *processor = [[Processor alloc] init];
+ if (mockedTasks) {
+ processor.linkKnownObjectsTask = mock([ProcessorTask class]);
+ processor.mergeKnownObjectsTask = mock([ProcessorTask class]);
+ processor.fetchDocumentationTask = mock([ProcessorTask class]);
+ }
handler(processor);
[processor release];
}
-#pragma mark -
+static void runWithProcessor(void(^handler)(Processor *processor)) {
+ runWithProcessor(NO, handler);
+}
+
+#pragma mark -
@interface Processor (UnitTestingPrivateAPI)
- (NSInteger)processCommentForObject:(ObjectInfoBase *)object context:(ObjectInfoBase *)parent;
@@ -59,6 +68,13 @@ - (NSInteger)processCommentForObject:(ObjectInfoBase *)object context:(ObjectInf
itShouldBehaveLike(@"tasks");
});
+ describe(@"fetch documentation task:", ^{
+ beforeEach(^{
+ [[SpecHelper specHelper] sharedExampleContext][@"task"] = @"fetchDocumentationTask";
+ });
+ itShouldBehaveLike(@"tasks");
+ });
+
describe(@"split comment to sections task:", ^{
beforeEach(^{
[[SpecHelper specHelper] sharedExampleContext][@"task"] = @"splitCommentToSectionsTask";
@@ -109,146 +125,23 @@ - (NSInteger)processCommentForObject:(ObjectInfoBase *)object context:(ObjectInf
gbcatch([verify(task) runTask]);
});
});
-});
-
-describe(@"comment processing:", ^{
- describe(@"enumerating objects:", ^{
- describe(@"top level objects:", ^{
- it(@"should enumerate classes", ^{
- runWithProcessor(^(Processor *processor) {
- // setup
- id settings = mock([GBSettings class]);
- id classes = mock([NSArray class]);
- id store = mock([Store class]);
- [given([store storeClasses]) willReturn:classes];
- // execute
- [processor runWithSettings:settings store:store];
- // verify
- gbcatch([verify(classes) enumerateObjectsUsingBlock:(id)anything()]);
- });
- });
-
- it(@"should enumerate extensions", ^{
- runWithProcessor(^(Processor *processor) {
- // setup
- id settings = mock([GBSettings class]);
- id extensions = mock([NSArray class]);
- id store = mock([Store class]);
- [given([store storeExtensions]) willReturn:extensions];
- // execute
- [processor runWithSettings:settings store:store];
- // verify
- gbcatch([verify(extensions) enumerateObjectsUsingBlock:(id)anything()]);
- });
- });
-
- it(@"should enumerate categories", ^{
- runWithProcessor(^(Processor *processor) {
- // setup
- id settings = mock([GBSettings class]);
- id categories = mock([NSArray class]);
- id store = mock([Store class]);
- [given([store storeCategories]) willReturn:categories];
- // execute
- [processor runWithSettings:settings store:store];
- // verify
- gbcatch([verify(categories) enumerateObjectsUsingBlock:(id)anything()]);
- });
- });
-
- it(@"should enumerate protocols", ^{
- runWithProcessor(^(Processor *processor) {
- // setup
- id settings = mock([GBSettings class]);
- id protocols = mock([NSArray class]);
- id store = mock([Store class]);
- [given([store storeProtocols]) willReturn:protocols];
- // execute
- [processor runWithSettings:settings store:store];
- // verify
- gbcatch([verify(protocols) enumerateObjectsUsingBlock:(id)anything()]);
- });
- });
- });
-
- describe(@"members:", ^{
- __block InterfaceInfoBase *object;
- __block id classMethods;
- __block id interfaceMethods;
- __block id properties;
-
- beforeEach(^{
- classMethods = mock([NSArray class]);
- interfaceMethods = mock([NSArray class]);
- properties = mock([NSArray class]);
- object = [[[InterfaceInfoBase alloc] init] autorelease];
- object.interfaceClassMethods = classMethods;
- object.interfaceInstanceMethods = interfaceMethods;
- object.interfaceProperties = properties;
- });
-
- it(@"should enumerate class members", ^{
- runWithProcessor(^(Processor *processor) {
- // setup
- id settings = mock([GBSettings class]);
- id store = mock([Store class]);
- [given([store storeClasses]) willReturn:@[object]];
- // execute
- [processor runWithSettings:settings store:store];
- // verify
- gbcatch([verify(classMethods) enumerateObjectsUsingBlock:(id)anything()]);
- gbcatch([verify(interfaceMethods) enumerateObjectsUsingBlock:(id)anything()]);
- gbcatch([verify(properties) enumerateObjectsUsingBlock:(id)anything()]);
- });
- });
-
- it(@"should enumerate extension members", ^{
- runWithProcessor(^(Processor *processor) {
- // setup
- id settings = mock([GBSettings class]);
- id store = mock([Store class]);
- [given([store storeExtensions]) willReturn:@[object]];
- // execute
- [processor runWithSettings:settings store:store];
- // verify
- gbcatch([verify(classMethods) enumerateObjectsUsingBlock:(id)anything()]);
- gbcatch([verify(interfaceMethods) enumerateObjectsUsingBlock:(id)anything()]);
- gbcatch([verify(properties) enumerateObjectsUsingBlock:(id)anything()]);
- });
- });
-
- it(@"should enumerate category members", ^{
- runWithProcessor(^(Processor *processor) {
- // setup
- id settings = mock([GBSettings class]);
- id store = mock([Store class]);
- [given([store storeCategories]) willReturn:@[object]];
- // execute
- [processor runWithSettings:settings store:store];
- // verify
- gbcatch([verify(classMethods) enumerateObjectsUsingBlock:(id)anything()]);
- gbcatch([verify(interfaceMethods) enumerateObjectsUsingBlock:(id)anything()]);
- gbcatch([verify(properties) enumerateObjectsUsingBlock:(id)anything()]);
- });
- });
-
- it(@"should enumerate protocol members", ^{
- runWithProcessor(^(Processor *processor) {
- // setup
- id settings = mock([GBSettings class]);
- id store = mock([Store class]);
- [given([store storeProtocols]) willReturn:@[object]];
- // execute
- [processor runWithSettings:settings store:store];
- // verify
- gbcatch([verify(classMethods) enumerateObjectsUsingBlock:(id)anything()]);
- gbcatch([verify(interfaceMethods) enumerateObjectsUsingBlock:(id)anything()]);
- gbcatch([verify(properties) enumerateObjectsUsingBlock:(id)anything()]);
- });
- });
+
+ it(@"should invoke fetch documentation task", ^{
+ runWithProcessor(^(Processor *processor) {
+ // setup
+ id settings = mock([GBSettings class]);
+ id store = mock([Store class]);
+ id task = mock([ProcessorTask class]);
+ processor.fetchDocumentationTask = task;
+ // execute
+ [processor runWithSettings:settings store:store];
+ // verify
+ gbcatch([verify(task) runTask]);
});
});
+});
+describe(@"comment processing:", ^{
describe(@"processing comments:", ^{
__block id context;
__block id object;
View
27 AppledocTests/Store/InterfaceInfoBaseTests.mm
@@ -117,6 +117,15 @@ static void runWithInterfaceInfoBaseWithRegistrar(void(^handler)(InterfaceInfoBa
});
});
+ it(@"should set self as parent of created property", ^{
+ runWithInterfaceInfoBaseWithRegistrar(^(InterfaceInfoBase *info, Store *store) {
+ // exexute
+ [info beginPropertyDefinition];
+ // verify
+ [info.currentRegistrationObject memberParent] should equal(info);
+ });
+ });
+
it(@"should set current source info to class", ^{
runWithInterfaceInfoBaseWithRegistrar(^(InterfaceInfoBase *info, Store *store) {
// setup
@@ -179,6 +188,15 @@ static void runWithInterfaceInfoBaseWithRegistrar(void(^handler)(InterfaceInfoBa
});
});
+ it(@"should set self as parent of created method", ^{
+ runWithInterfaceInfoBaseWithRegistrar(^(InterfaceInfoBase *info, Store *store) {
+ // exexute
+ [info beginMethodDefinitionWithType:GBStoreTypes.classMethod];
+ // verify
+ [info.currentRegistrationObject memberParent] should equal(info);
+ });
+ });
+
it(@"should set current source info to class", ^{
runWithInterfaceInfoBaseWithRegistrar(^(InterfaceInfoBase *info, Store *store) {
// setup
@@ -240,6 +258,15 @@ static void runWithInterfaceInfoBaseWithRegistrar(void(^handler)(InterfaceInfoBa
});
});
+ it(@"should set self as parent of created method", ^{
+ runWithInterfaceInfoBaseWithRegistrar(^(InterfaceInfoBase *info, Store *store) {
+ // exexute
+ [info beginMethodDefinitionWithType:GBStoreTypes.instanceMethod];
+ // verify
+ [info.currentRegistrationObject memberParent] should equal(info);
+ });
+ });
+
it(@"should set current source info to class", ^{
runWithInterfaceInfoBaseWithRegistrar(^(InterfaceInfoBase *info, Store *store) {
// setup
View
19 AppledocTests/Store/MethodInfoTests.mm
@@ -40,14 +40,27 @@ static void runWithMethodInfoWithRegistrar(void(^handler)(MethodInfo *info, Stor
});
describe(@"selector, unique ID & cross reference template:", ^{
+ it(@"should handle class method", ^{
+ runWithMethodInfo(^(MethodInfo *info) {
+ // setup
+ MethodArgumentInfo *argument = [[MethodArgumentInfo alloc] init];
+ argument.argumentSelector = @"method";
+ [info.methodArguments addObject:argument];
+ info.methodType = GBStoreTypes.classMethod;
+ // execute & verify
+ info.uniqueObjectID should equal(@"+method");
+ info.objectCrossRefPathTemplate should equal(@"#+method");
+ });
+ });
+
it(@"should handle single argument", ^{
runWithMethodInfo(^(MethodInfo *info) {
// setup
MethodArgumentInfo *argument = [[MethodArgumentInfo alloc] init];
argument.argumentSelector = @"method";
[info.methodArguments addObject:argument];
// execute & verify
- info.uniqueObjectID should equal(@"method");
+ info.uniqueObjectID should equal(@"-method");
info.objectCrossRefPathTemplate should equal(@"#-method");
});
});
@@ -60,7 +73,7 @@ static void runWithMethodInfoWithRegistrar(void(^handler)(MethodInfo *info, Stor
argument.argumentVariable = @"var";
[info.methodArguments addObject:argument];
// execute & verify
- info.uniqueObjectID should equal(@"method:");
+ info.uniqueObjectID should equal(@"-method:");
info.objectCrossRefPathTemplate should equal(@"#-method:");
});
});
@@ -77,7 +90,7 @@ static void runWithMethodInfoWithRegistrar(void(^handler)(MethodInfo *info, Stor
argument2.argumentVariable = @"var";
[info.methodArguments addObject:argument2];
// execute & verify
- info.uniqueObjectID should equal(@"method:withArg:");
+ info.uniqueObjectID should equal(@"-method:withArg:");
info.objectCrossRefPathTemplate should equal(@"#-method:withArg:");
});
});
View
60 AppledocTests/TestingBase/StoreMocks.h
@@ -0,0 +1,60 @@
+//
+// StoreMocks.h
+// appledoc
+//
+// Created by Tomaz Kragelj on 11.12.12.
+// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
+//
+
+#import "Store.h"
+
+typedef void(^GBCreateObjectBlock)(id object);
+
+@interface StoreMocks : NSObject
+
++ (InterfaceInfoBase *)createInterface:(void(^)(InterfaceInfoBase *object))handler;
++ (ClassInfo *)createClass:(void(^)(ClassInfo *object))handler;
++ (CategoryInfo *)createCategory:(void(^)(CategoryInfo *object))handler;
++ (ProtocolInfo *)createProtocol:(void(^)(ProtocolInfo *object))handler;
+
++ (MethodInfo *)createMethod:(NSString *)uniqueID;
++ (MethodInfo *)createMethod:(NSString *)uniqueID block:(void(^)(MethodInfo *object))handler;
++ (PropertyInfo *)createProperty:(NSString *)uniqueID;
++ (PropertyInfo *)createProperty:(NSString *)uniqueID block:(void(^)(PropertyInfo *object))handler;
++ (ObjectLinkInfo *)link:(id)nameOrObject;
+
++ (id)mockClass:(NSString *)name block:(GBCreateObjectBlock)handler;
++ (id)mockCategory:(NSString *)name onClass:(NSString *)className block:(GBCreateObjectBlock)handler;
++ (id)mockProtocol:(NSString *)name block:(GBCreateObjectBlock)handler;
+
++ (id)mockMethod:(NSString *)uniqueID;
++ (id)mockMethod:(NSString *)uniqueID block:(GBCreateObjectBlock)handler;
++ (id)mockProperty:(NSString *)uniqueID;
++ (id)mockProperty:(NSString *)uniqueID block:(GBCreateObjectBlock)handler;
+
++ (void)addMockCommentTo:(id)objectOrMock;
++ (void)add:(id)classOrMock asDerivedClassFrom:(id)baseOrMock;
++ (void)add:(id)objectOrMock asAdopting:(id)protocolOrMock;
++ (void)add:(id)methodOrMock asClassMethodOf:(id)interfaceOrMock;
++ (void)add:(id)methodOrMock asInstanceMethodOf:(id)interfaceOrMock;
++ (void)add:(id)propertyOrMock asPropertyOf:(id)interfaceOrMock;
+
+@end
+
+#pragma mark -
+
+@interface InterfaceInfoBase (UnitTestsMocks)
+- (void)adopt:(NSString *)first, ... NS_REQUIRES_NIL_TERMINATION;
+@end
+
+#pragma mark -
+
+@interface CategoryInfo (UnitTestsMocks)
+- (void)extend:(NSString *)name;
+@end
+
+#pragma mark -
+
+@interface ClassInfo (UnitTestsMocks)
+- (void)derive:(NSString *)name;
+@end
View
222 AppledocTests/TestingBase/StoreMocks.m
@@ -0,0 +1,222 @@
+//
+// StoreMocks.m
+// appledoc
+//
+// Created by Tomaz Kragelj on 11.12.12.
+// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
+//
+
+#define MOCKITO_SHORTHAND
+#import <OCMockito/OCMockito.h>
+#import "Objects.h"
+#import "StoreMocks.h"
+
+@implementation StoreMocks
+
+#pragma mark - Real interfaces
+
++ (InterfaceInfoBase *)createInterface:(void(^)(InterfaceInfoBase *object))handler {
+ InterfaceInfoBase *result = [[InterfaceInfoBase alloc] init];
+ handler(result);
+ return result;
+}
+
++ (ClassInfo *)createClass:(void(^)(ClassInfo *object))handler {
+ ClassInfo *result = [[ClassInfo alloc] init];
+ handler(result);
+ return result;
+}
+
++ (CategoryInfo *)createCategory:(void(^)(CategoryInfo *object))handler {
+ CategoryInfo *result = [[CategoryInfo alloc] init];
+ handler(result);
+ return result;
+}
+
++ (ProtocolInfo *)createProtocol:(void(^)(ProtocolInfo *object))handler {
+ ProtocolInfo *result = [[ProtocolInfo alloc] init];
+ handler(result);
+ return result;
+}
+
+#pragma mark - Real members
+
++ (MethodInfo *)createMethod:(NSString *)uniqueID block:(void(^)(MethodInfo *object))handler {
+ MethodInfo *result = [[MethodInfo alloc] init];
+ NSRange range = NSMakeRange(1, uniqueID.length - 1);
+ NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"([^:]+)(:?)" options:0 error:nil];
+ [regex enumerateMatchesInString:uniqueID options:0 range:range usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop) {
+ NSString *selector = [match gb_stringAtIndex:1 in:uniqueID];
+ NSString *colon = [match gb_stringAtIndex:2 in:uniqueID];
+ MethodArgumentInfo *argument = [[MethodArgumentInfo alloc] init];
+ argument.argumentSelector = selector;
+ argument.argumentVariable = (colon.length > 0) ? selector : nil;
+ [result.methodArguments addObject:argument];
+ }];
+ result.methodType = ([uniqueID characterAtIndex:0] == '+') ? GBStoreTypes.classMethod : GBStoreTypes.instanceMethod;
+ handler(result);
+ return result;
+}
+
++ (MethodInfo *)createMethod:(NSString *)uniqueID {
+ return [self createMethod:uniqueID block:^(MethodInfo *object) { }];
+}
+
++ (PropertyInfo *)createProperty:(NSString *)uniqueID block:(void(^)(PropertyInfo *object))handler {
+ PropertyInfo *result = [[PropertyInfo alloc] init];
+ result.propertyName = uniqueID;
+ handler(result);
+ return result;
+}
+
++ (PropertyInfo *)createProperty:(NSString *)uniqueID {
+ return [self createProperty:uniqueID block:^(PropertyInfo *object) { }];
+}
+
++ (ObjectLinkInfo *)link:(id)nameOrObject {
+ ObjectLinkInfo *result = [[ObjectLinkInfo alloc] init];
+ if ([nameOrObject isKindOfClass:[NSString class]])
+ result.nameOfObject = nameOrObject;
+ else
+ result.linkToObject = nameOrObject;
+ return result;
+}
+
+#pragma mark - Mock interfaces
+
++ (id)mockClass:(NSString *)name block:(GBCreateObjectBlock)handler {
+ id result = mock([ClassInfo class]);
+ [given([result nameOfClass]) willReturn:name];
+ handler(result);
+ return result;
+}
+
++ (id)mockCategory:(NSString *)name onClass:(NSString *)className block:(GBCreateObjectBlock)handler {
+ id result = mock([CategoryInfo class]);
+ [given([result nameOfCategory]) willReturn:name];
+ [given([result nameOfClass]) willReturn:className];
+ [given([result categoryClass]) willReturn:[self link:className]];
+ handler(result);
+ return result;
+}
+
++ (id)mockProtocol:(NSString *)name block:(GBCreateObjectBlock)handler {
+ id result = mock([ProtocolInfo class]);
+ [given([result nameOfProtocol]) willReturn:name];
+ handler(result);
+ return result;
+}
+
+#pragma mark - Mock members
+
++ (id)mockMethod:(NSString *)uniqueID {
+ return [self mockMethod:uniqueID block:^(id object) { }];
+}
+
++ (id)mockMethod:(NSString *)uniqueID block:(void(^)(id object))handler {
+ id result = mock([MethodInfo class]);
+ [given([result uniqueObjectID]) willReturn:uniqueID];
+ handler(result);
+ return result;
+}
+
++ (id)mockProperty:(NSString *)uniqueID {
+ return [self mockProperty:uniqueID block:^(id object) { }];
+}
+
++ (id)mockProperty:(NSString *)uniqueID block:(void(^)(id object))handler {
+ id result = mock([PropertyInfo class]);
+ [given([result uniqueObjectID]) willReturn:uniqueID];
+ handler(result);
+ return result;
+}
+
+#pragma mark - Common stuff
+
++ (void)addMockCommentTo:(id)objectOrMock {
+ id comment = mock([CommentInfo class]);
+ if ([self isMock:objectOrMock])
+ [given([objectOrMock comment]) willReturn:comment];
+ else
+ [objectOrMock setComment:comment];
+}
+
++ (void)add:(id)classOrMock asDerivedClassFrom:(id)baseOrMock {
+ ObjectLinkInfo *link = [self link:baseOrMock];
+ if ([self isMock:classOrMock])
+ [given([classOrMock classSuperClass]) willReturn:link];
+ else
+ [classOrMock setClassSuperClass:link];
+}
+
++ (void)add:(id)objectOrMock asAdopting:(id)protocolOrMock {
+ ObjectLinkInfo *link = [self link:protocolOrMock];
+ if ([self isMock:objectOrMock])
+ [given([objectOrMock interfaceAdoptedProtocols]) willReturn:@[ link ]];
+ else
+ [[objectOrMock interfaceAdoptedProtocols] addObject:link];
+}
+
++ (void)add:(id)methodOrMock asClassMethodOf:(id)interfaceOrMock {
+ if ([self isMock:interfaceOrMock])
+ [given([interfaceOrMock interfaceClassMethods]) willReturn:@[ methodOrMock ]];
+ else
+ [[interfaceOrMock interfaceClassMethods] addObject:methodOrMock];
+}
+
++ (void)add:(id)methodOrMock asInstanceMethodOf:(id)interfaceOrMock {
+ if ([self isMock:interfaceOrMock])
+ [given([interfaceOrMock interfaceInstanceMethods]) willReturn:@[ methodOrMock ]];
+ else
+ [[interfaceOrMock interfaceInstanceMethods] addObject:methodOrMock];
+}
+
++ (void)add:(id)propertyOrMock asPropertyOf:(id)interfaceOrMock {
+ if ([self isMock:interfaceOrMock])
+ [given([interfaceOrMock interfaceProperties]) willReturn:@[ propertyOrMock ]];
+ else
+ [[interfaceOrMock interfaceProperties] addObject:propertyOrMock];
+}
+
++ (BOOL)isMock:(id)objectOrMock {
+ return ![objectOrMock isKindOfClass:[ObjectInfoBase class]];
+}
+
+@end
+
+#pragma mark -
+
+@implementation InterfaceInfoBase (UnitTestsMocks)
+
+- (void)adopt:(NSString *)first, ... {
+ va_list args;
+ va_start(args, first);
+ for (NSString *arg=first; arg!=nil; arg=va_arg(args, NSString *)) {
+ ObjectLinkInfo *link = [[ObjectLinkInfo alloc] init];
+ link.nameOfObject = arg;
+ [self.interfaceAdoptedProtocols addObject:link];
+ }
+ va_end(args);
+}
+
+@end
+
+#pragma mark -
+
+@implementation CategoryInfo (UnitTestsMocks)
+
+- (void)extend:(NSString *)name {
+ self.categoryClass.nameOfObject = name;
+}
+
+@end
+
+#pragma mark -
+
+@implementation ClassInfo (UnitTestsMocks)
+
+- (void)derive:(NSString *)name {
+ self.classSuperClass.nameOfObject = name;
+}
+
+@end
View
26 appledoc.xcodeproj/project.pbxproj
@@ -49,6 +49,9 @@
73297915151899CA00592A9D /* ObjectiveCParserState.m in Sources */ = {isa = PBXBuildFile; fileRef = 73297913151899CA00592A9D /* ObjectiveCParserState.m */; };
7329791815189D1B00592A9D /* ObjectiveCFileState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7329791715189D1B00592A9D /* ObjectiveCFileState.m */; };
7329791915189D1B00592A9D /* ObjectiveCFileState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7329791715189D1B00592A9D /* ObjectiveCFileState.m */; };
+ 733256F11677269800CA90E1 /* StoreMocks.m in Sources */ = {isa = PBXBuildFile; fileRef = 733256F01677269800CA90E1 /* StoreMocks.m */; };
+ 7335020F167601D100C514AB /* FetchDocumentationTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 7335020E167601D100C514AB /* FetchDocumentationTask.m */; };
+ 73350210167601D100C514AB /* FetchDocumentationTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 7335020E167601D100C514AB /* FetchDocumentationTask.m */; };
7336652515457A2E000F7AFF /* ConstantInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 7336652415457A2E000F7AFF /* ConstantInfo.m */; };
7336652615457A2E000F7AFF /* ConstantInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 7336652415457A2E000F7AFF /* ConstantInfo.m */; };
7336652915457BF7000F7AFF /* ConstantInfoTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7336652815457BF7000F7AFF /* ConstantInfoTests.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
@@ -112,6 +115,8 @@
73A0268915D6E35F0077D204 /* ProcessorTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 73A0268815D6E35F0077D204 /* ProcessorTask.m */; };
73A0268A15D6E35F0077D204 /* ProcessorTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 73A0268815D6E35F0077D204 /* ProcessorTask.m */; };
73A0268E15D6EFB50077D204 /* ProcessorTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73A0268D15D6EFB50077D204 /* ProcessorTests.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ 73A23633167877D6009AA844 /* MemberInfoBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 73A23632167877D6009AA844 /* MemberInfoBase.m */; };
+ 73A23634167877D6009AA844 /* MemberInfoBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 73A23632167877D6009AA844 /* MemberInfoBase.m */; };
73A3E48B15D8288D00769863 /* SplitCommentToSectionsTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 73A3E48A15D8288D00769863 /* SplitCommentToSectionsTask.m */; };
73A3E48C15D8288D00769863 /* SplitCommentToSectionsTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 73A3E48A15D8288D00769863 /* SplitCommentToSectionsTask.m */; };
73A3E48E15D8369500769863 /* SplitCommentToSectionsTaskTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73A3E48D15D8369500769863 /* SplitCommentToSectionsTaskTests.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
@@ -151,6 +156,7 @@
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 */; };
+ 73DF1FB916760BD300CFDF89 /* FetchDocumentationTaskTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73DF1FB816760BD300CFDF89 /* FetchDocumentationTaskTests.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
73E289F21518E24D00D53484 /* ObjectiveCPropertyState.m in Sources */ = {isa = PBXBuildFile; fileRef = 73F989B71518C63D0068697C /* ObjectiveCPropertyState.m */; };
73E289F31518E24D00D53484 /* ObjectiveCMethodState.m in Sources */ = {isa = PBXBuildFile; fileRef = 73F989BB1518C6530068697C /* ObjectiveCMethodState.m */; };
73E289F41518E24D00D53484 /* ObjectiveCPragmaMarkState.m in Sources */ = {isa = PBXBuildFile; fileRef = 73F989BF1518C6AE0068697C /* ObjectiveCPragmaMarkState.m */; };
@@ -259,6 +265,10 @@
73297913151899CA00592A9D /* ObjectiveCParserState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectiveCParserState.m; sourceTree = "<group>"; };
7329791615189D1B00592A9D /* ObjectiveCFileState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectiveCFileState.h; sourceTree = "<group>"; };
7329791715189D1B00592A9D /* ObjectiveCFileState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectiveCFileState.m; sourceTree = "<group>"; };
+ 733256EF1677269800CA90E1 /* StoreMocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StoreMocks.h; sourceTree = "<group>"; };
+ 733256F01677269800CA90E1 /* StoreMocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StoreMocks.m; sourceTree = "<group>"; };
+ 7335020D167601D100C514AB /* FetchDocumentationTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchDocumentationTask.h; sourceTree = "<group>"; };
+ 7335020E167601D100C514AB /* FetchDocumentationTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FetchDocumentationTask.m; sourceTree = "<group>"; };
7336652315457A2E000F7AFF /* ConstantInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstantInfo.h; sourceTree = "<group>"; };
7336652415457A2E000F7AFF /* ConstantInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ConstantInfo.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
7336652815457BF7000F7AFF /* ConstantInfoTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ConstantInfoTests.mm; sourceTree = "<group>"; };
@@ -327,6 +337,8 @@
73A0268715D6E35F0077D204 /* ProcessorTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessorTask.h; sourceTree = "<group>"; };
73A0268815D6E35F0077D204 /* ProcessorTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProcessorTask.m; sourceTree = "<group>"; };
73A0268D15D6EFB50077D204 /* ProcessorTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessorTests.mm; sourceTree = "<group>"; };
+ 73A23631167877D6009AA844 /* MemberInfoBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemberInfoBase.h; sourceTree = "<group>"; };
+ 73A23632167877D6009AA844 /* MemberInfoBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MemberInfoBase.m; sourceTree = "<group>"; };
73A3E48915D8288D00769863 /* SplitCommentToSectionsTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplitCommentToSectionsTask.h; sourceTree = "<group>"; };
73A3E48A15D8288D00769863 /* SplitCommentToSectionsTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SplitCommentToSectionsTask.m; sourceTree = "<group>"; };
73A3E48D15D8369500769863 /* SplitCommentToSectionsTaskTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SplitCommentToSectionsTaskTests.mm; sourceTree = "<group>"; };
@@ -369,6 +381,7 @@
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>"; };
+ 73DF1FB816760BD300CFDF89 /* FetchDocumentationTaskTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FetchDocumentationTaskTests.mm; sourceTree = "<group>"; };
73DFDD4115527F2D007746D4 /* TestCaseBase.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TestCaseBase.hh; sourceTree = "<group>"; };
73E416DB1541A14700600606 /* EnumInfoTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EnumInfoTests.mm; sourceTree = "<group>"; };
73E416DE1541A8B100600606 /* EnumItemInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnumItemInfo.h; sourceTree = "<group>"; };
@@ -449,6 +462,8 @@
73DFDD4115527F2D007746D4 /* TestCaseBase.hh */,
737C82A1152307AE0064DC46 /* TestStrings.h */,
737C82A2152307AE0064DC46 /* TestStrings.m */,
+ 733256EF1677269800CA90E1 /* StoreMocks.h */,
+ 733256F01677269800CA90E1 /* StoreMocks.m */,
731F83DA15109D5F00112FD1 /* Objects+TestingPrivateAPI.h */,
);
name = "Testing Base";
@@ -582,6 +597,8 @@
children = (
7316B9D515359DEE000F12F3 /* ObjectInfoBase.h */,
7316B9D615359DEE000F12F3 /* ObjectInfoBase.m */,
+ 73A23631167877D6009AA844 /* MemberInfoBase.h */,
+ 73A23632167877D6009AA844 /* MemberInfoBase.m */,
7381A66C1536C05F00BF9BDD /* InterfaceInfoBase.h */,
7381A66D1536C05F00BF9BDD /* InterfaceInfoBase.m */,
735CD2BD1538109900CADD4E /* ObjectLinkInfo.h */,
@@ -675,6 +692,8 @@
73C903E5167144B600B7D14F /* MergeKnownObjectsTask.m */,
733A93101671ED9800734F0A /* LinkKnownObjectsTask.h */,
733A93111671ED9800734F0A /* LinkKnownObjectsTask.m */,
+ 7335020D167601D100C514AB /* FetchDocumentationTask.h */,
+ 7335020E167601D100C514AB /* FetchDocumentationTask.m */,
73A3E48915D8288D00769863 /* SplitCommentToSectionsTask.h */,
73A3E48A15D8288D00769863 /* SplitCommentToSectionsTask.m */,
73D76C591660BBD900B611AB /* RegisterCommentComponentsTask.h */,
@@ -693,6 +712,7 @@
73A0268D15D6EFB50077D204 /* ProcessorTests.mm */,
73CDF8B715E9415E0046C8E1 /* ProcessorTaskTests.mm */,
733A93151671EF0600734F0A /* LinkKnownObjectsTaskTests.mm */,
+ 73DF1FB816760BD300CFDF89 /* FetchDocumentationTaskTests.mm */,
73A3E48D15D8369500769863 /* SplitCommentToSectionsTaskTests.mm */,
73D76C5D1660BF9A00B611AB /* RegisterCommentComponentsTaskTests.mm */,
73D76C6C16613C4600B611AB /* DetectCrossReferencesTaskTests.mm */,
@@ -1010,6 +1030,10 @@
733A93131671ED9800734F0A /* LinkKnownObjectsTask.m in Sources */,
733A93161671EF0600734F0A /* LinkKnownObjectsTaskTests.mm in Sources */,
73D72A081675F1FD007912F1 /* ClassInfoTests.mm in Sources */,
+ 73350210167601D100C514AB /* FetchDocumentationTask.m in Sources */,
+ 73DF1FB916760BD300CFDF89 /* FetchDocumentationTaskTests.mm in Sources */,
+ 733256F11677269800CA90E1 /* StoreMocks.m in Sources */,
+ 73A23634167877D6009AA844 /* MemberInfoBase.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1079,6 +1103,8 @@
73C903E116713F1500B7D14F /* ProcessorCommentTask.m in Sources */,
73C903E6167144B600B7D14F /* MergeKnownObjectsTask.m in Sources */,
733A93121671ED9800734F0A /* LinkKnownObjectsTask.m in Sources */,
+ 7335020F167601D100C514AB /* FetchDocumentationTask.m in Sources */,
+ 73A23633167877D6009AA844 /* MemberInfoBase.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
12 appledoc/Common/GBSettings+Appledoc.h
@@ -37,6 +37,7 @@
#pragma mark - Comments
+@property (nonatomic, assign) BOOL searchForMissingComments;
@property (nonatomic, copy) NSString *crossRefsFormat;
#pragma mark - Debugging aid
@@ -47,11 +48,6 @@
@property (nonatomic, assign) NSUInteger loggingLevel;
@property (nonatomic, assign) NSUInteger loggingFormat;
-@property (nonatomic, assign) BOOL loggingInternalEnabled;
-@property (nonatomic, assign) BOOL loggingCommonEnabled;
-@property (nonatomic, assign) BOOL loggingStoreEnabled;
-@property (nonatomic, assign) BOOL loggingParsingEnabled;
-@property (nonatomic, assign) BOOL loggingProcessingEnabled;
@end
@@ -67,6 +63,7 @@ extern const struct GBOptions {
__unsafe_unretained NSString *ignoredPaths;
__unsafe_unretained NSString *templatesPath;
+ __unsafe_unretained NSString *searchMissingComments;
__unsafe_unretained NSString *crossRefsFormat;
__unsafe_unretained NSString *printSettings;
@@ -75,9 +72,4 @@ extern const struct GBOptions {
__unsafe_unretained NSString *loggingLevel;
__unsafe_unretained NSString *loggingFormat;
- __unsafe_unretained NSString *loggingInternalEnabled;
- __unsafe_unretained NSString *loggingCommonEnabled;
- __unsafe_unretained NSString *loggingStoreEnabled;
- __unsafe_unretained NSString *loggingParsingEnabled;
- __unsafe_unretained NSString *loggingProcessingEnabled;
} GBOptions;
View
12 appledoc/Common/GBSettings+Appledoc.m
@@ -36,6 +36,7 @@ + (id)appledocSettingsWithName:(NSString *)name parent:(GBSettings *)parent {
#pragma mark - Comments
+GB_SYNTHESIZE_BOOL(searchForMissingComments, setSearchForMissingComments, GBOptions.searchMissingComments);
GB_SYNTHESIZE_COPY(NSString *, crossRefsFormat, setCrossRefsFormat, GBOptions.crossRefsFormat)
#pragma mark - Debugging aid
@@ -46,11 +47,6 @@ + (id)appledocSettingsWithName:(NSString *)name parent:(GBSettings *)parent {
GB_SYNTHESIZE_UINT(loggingFormat, setLoggingFormat, GBOptions.loggingFormat)
GB_SYNTHESIZE_UINT(loggingLevel, setLoggingLevel, GBOptions.loggingLevel)
-GB_SYNTHESIZE_BOOL(loggingInternalEnabled, setLoggingInternalEnabled, GBOptions.loggingInternalEnabled)
-GB_SYNTHESIZE_BOOL(loggingCommonEnabled, setLoggingCommonEnabled, GBOptions.loggingCommonEnabled)
-GB_SYNTHESIZE_BOOL(loggingStoreEnabled, setLoggingStoreEnabled, GBOptions.loggingStoreEnabled)
-GB_SYNTHESIZE_BOOL(loggingParsingEnabled, setLoggingParsingEnabled, GBOptions.loggingParsingEnabled)
-GB_SYNTHESIZE_BOOL(loggingProcessingEnabled, setLoggingProcessingEnabled, GBOptions.loggingProcessingEnabled)
@end
@@ -66,6 +62,7 @@ + (id)appledocSettingsWithName:(NSString *)name parent:(GBSettings *)parent {
.templatesPath = @"templates",
.ignoredPaths = @"ignore",
+ .searchMissingComments = @"search-comments",
.crossRefsFormat = @"crossrefs",
.printSettings = @"print-settings",
@@ -74,9 +71,4 @@ + (id)appledocSettingsWithName:(NSString *)name parent:(GBSettings *)parent {
.loggingLevel = @"verbose",
.loggingFormat = @"log-format",
- .loggingInternalEnabled = @"log-internal",
- .loggingCommonEnabled = @"log-common",
- .loggingStoreEnabled = @"log-store",
- .loggingParsingEnabled = @"log-parsing",
- .loggingProcessingEnabled = @"log-processing",
};
View
4 appledoc/Common/GBSettings+Helpers.m
@@ -28,10 +28,8 @@ @implementation GBSettings (Helpers)
- (void)applyFactoryDefaults {
self.projectVersion = @"1.0";
self.crossRefsFormat = @"plain";
+ self.searchForMissingComments = YES;
self.loggingFormat = 0;
- self.loggingCommonEnabled = YES;
- self.loggingStoreEnabled = NO;
- self.loggingParsingEnabled = NO;
}
- (BOOL)applyGlobalSettingsFromCmdLineSettings:(GBSettings *)settings {
View
17 appledoc/Processing/FetchDocumentationTask.h
@@ -0,0 +1,17 @@
+//
+// FetchDocumentationTask.h
+// appledoc
+//
+// Created by Tomaz Kragelj on 10.12.12.
+// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
+//
+
+#import "ProcessorTask.h"
+
+/** Fetches documentation from other instances of objects.
+
+ The purpose of this class is to fill out documentation of objects from the rest of the objects in the store. For example, it copies documentation of overriden methods from super classes or adopted protocols. This allows users to simplify and DRY their code while still keeping full documentation.
+ */
+@interface FetchDocumentationTask : ProcessorTask
+
+@end
View
137 appledoc/Processing/FetchDocumentationTask.m
@@ -0,0 +1,137 @@
+//
+// FetchDocumentationTask.m
+// appledoc
+//
+// Created by Tomaz Kragelj on 10.12.12.
+// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
+//
+
+#import "Objects.h"
+#import "Store.h"
+#import "FetchDocumentationTask.h"
+
+typedef void(^GBFetchBlock)(id member);
+
+@implementation FetchDocumentationTask
+
+- (GBResult)runTask {
+ if (!self.settings.searchForMissingComments) return GBResultOk;
+ LogDebug(@"Fetching documentation from related objects...");
+ [self handleClassesFromStore:self.store];
+ [self handleExtensionsFromStore:self.store];
+ [self handleCategoriesFromStore:self.store];
+ [self handleProtocolsFromStore:self.store];
+ return GBResultOk;
+}
+
+#pragma mark - Top level objects handling
+
+- (void)handleClassesFromStore:(Store *)store {
+ LogDebug(@"Handling classes...");
+ __weak FetchDocumentationTask *bself = self;
+ [store.storeClasses enumerateObjectsUsingBlock:^(ClassInfo *class, NSUInteger idx, BOOL *stop) {
+ LogDebug(@"Handling %@...", class);
+ [bself fetchDocumentationFromAdoptedProtocolsOf:class missingBlock:^(id member) {
+ // Note that we want to log undocumented members; users may disable warnings but if they turn verbosity to debug, they should still see what's going on.
+ LogDebug(@"Documentation for %@ not found in adopted protocols, checking superclasses...", member);
+ [bself fetchDocumentationFromSuperClassesOf:class forMember:member];
+ }];
+ }];
+}
+
+- (void)handleExtensionsFromStore:(Store *)store {
+ LogDebug(@"Handling extensions...");
+ [self fetchDocumentationFromAdoptedProtocolsForInterfaces:store.storeExtensions];
+}
+
+- (void)handleCategoriesFromStore:(Store *)store {
+ LogDebug(@"Handling categories...");
+ [self fetchDocumentationFromAdoptedProtocolsForInterfaces:store.storeCategories];
+}
+
+- (void)handleProtocolsFromStore:(Store *)store {
+ LogDebug(@"Handling protocols...");
+ [self fetchDocumentationFromAdoptedProtocolsForInterfaces:store.storeProtocols];
+}
+
+#pragma mark - Adopted protocols handling
+
+- (void)fetchDocumentationFromAdoptedProtocolsForInterfaces:(NSArray *)interfaces {
+ __weak FetchDocumentationTask *bself = self;
+ [interfaces enumerateObjectsUsingBlock:^(InterfaceInfoBase *interface, NSUInteger idx, BOOL *stop) {
+ LogDebug(@"Handling %@...", interface);
+ [bself fetchDocumentationFromAdoptedProtocolsOf:interface missingBlock:^(id member) {
+ // Similar to handleClassesFromStore: we want to always log undocumented members as debug messages...
+ LogDebug(@"Member %@ is undocumented!", member);
+ [bself reportUndocumentedMember:member];
+ }];
+ }];
+}
+
+- (void)fetchDocumentationFromAdoptedProtocolsOf:(InterfaceInfoBase *)interface missingBlock:(GBFetchBlock)handler {
+ [self fetchDocumentationFromAdoptedProtocolsOf:interface members:@selector(interfaceClassMethods) missingBlock:handler];
+ [self fetchDocumentationFromAdoptedProtocolsOf:interface members:@selector(interfaceInstanceMethods) missingBlock:handler];
+ [self fetchDocumentationFromAdoptedProtocolsOf:interface members:@selector(interfaceProperties) missingBlock:handler];
+}
+
+- (void)fetchDocumentationFromAdoptedProtocolsOf:(InterfaceInfoBase *)interface members:(SEL)selector missingBlock:(GBFetchBlock)handler {
+ __weak FetchDocumentationTask *bself = self;
+ NSArray *interfaceMembers = [interface performSelector:selector];
+ [interfaceMembers enumerateObjectsUsingBlock:^(ObjectInfoBase *member, NSUInteger idx, BOOL *stop) {
+ if (member.comment) return;
+ [interface.interfaceAdoptedProtocols enumerateObjectsUsingBlock:^(ObjectLinkInfo *adoptedProtocolLink, NSUInteger i, BOOL *istop) {
+ ProtocolInfo *adoptedProtocol = adoptedProtocolLink.linkToObject;
+ if (!adoptedProtocol) return;
+ NSArray *adoptedMembers = [adoptedProtocol performSelector:selector];
+ [adoptedMembers enumerateObjectsUsingBlock:^(ObjectInfoBase *adoptedMember, NSUInteger j, BOOL *jstop) {
+ if (!adoptedMember.comment) return;
+ if (![adoptedMember.uniqueObjectID isEqualToString:member.uniqueObjectID]) return;
+ [bself copyDocumentationFrom:adoptedMember to:member];
+ *jstop = YES;
+ *istop = YES;
+ }];
+ }];
+ if (!member.comment) handler(member);
+ }];
+}
+
+#pragma mark - Super classes handling
+
+- (void)fetchDocumentationFromSuperClassesOf:(ClassInfo *)class forMember:(id)member {
+ ClassInfo *superClass = class.classSuperClass.linkToObject;
+ while (superClass) {
+ LogDebug(@"Checking super class %@...", superClass);
+ if ([self fetchDocumentationFromSuperClassMembers:superClass.interfaceClassMethods forMember:member]) break;
+ if ([self fetchDocumentationFromSuperClassMembers:superClass.interfaceInstanceMethods forMember:member]) break;
+ if ([self fetchDocumentationFromSuperClassMembers:superClass.interfaceProperties forMember:member]) break;
+ superClass = superClass.classSuperClass.linkToObject;
+ }
+ if (![member comment]) {
+ LogDebug(@"Member %@ is undocumented!", [member descriptionWithParent]);
+ [self reportUndocumentedMember:member];
+ }
+}
+
+- (BOOL)fetchDocumentationFromSuperClassMembers:(NSArray *)superMembers forMember:(ObjectInfoBase *)member {
+ __weak FetchDocumentationTask *bself = self;
+ [superMembers enumerateObjectsUsingBlock:^(ObjectInfoBase *superMember, NSUInteger idx, BOOL *stop) {
+ if (!superMember.comment) return;
+ if (![superMember.uniqueObjectID isEqualToString:member.uniqueObjectID]) return;
+ [bself copyDocumentationFrom:superMember to:member];
+ }];
+}
+
+#pragma mark - Copying documentation
+
+- (void)copyDocumentationFrom:(MemberInfoBase *)source to:(MemberInfoBase *)dest {
+ LogVerbose(@"Fetching documentation for %@ from %@.", [dest descriptionWithParent], [source descriptionWithParent]);
+ dest.comment = source.comment;
+}
+
+#pragma mark - Undocumented objects handling
+
+- (void)reportUndocumentedMember:(id)object {
+ LogWarn(@"%@ is undocumented!", [object descriptionWithParent]);
+}
+
+@end
View
14 appledoc/Processing/LinkKnownObjectsTask.m
@@ -24,7 +24,7 @@ - (GBResult)runTask {
#pragma mark - Top level objects handling
- (void)handleClassesFromStore:(Store *)store {
- LogDebug(@"Preparing links for classes...");
+ LogDebug(@"Handling classes...");
__weak LinkKnownObjectsTask *bself = self;
[store.storeClasses enumerateObjectsUsingBlock:^(ClassInfo *class, NSUInteger idx, BOOL *stop) {
LogDebug(@"Handling %@...", class);
@@ -34,7 +34,7 @@ - (void)handleClassesFromStore:(Store *)store {
}
- (void)handleExtensionsFromStore:(Store *)store {
- LogDebug(@"Preparing links for classes...");
+ LogDebug(@"Handling extensions...");
__weak LinkKnownObjectsTask *bself = self;
[store.storeExtensions enumerateObjectsUsingBlock:^(CategoryInfo *extension, NSUInteger idx, BOOL *stop) {
LogDebug(@"Handling %@...", extension);
@@ -44,7 +44,7 @@ - (void)handleExtensionsFromStore:(Store *)store {
}
- (void)handleCategoriesFromStore:(Store *)store {
- LogDebug(@"Preparing links for classes...");
+ LogDebug(@"Handling categories...");
__weak LinkKnownObjectsTask *bself = self;
[store.storeCategories enumerateObjectsUsingBlock:^(CategoryInfo *category, NSUInteger idx, BOOL *stop) {
LogDebug(@"Handling %@...", category);
@@ -54,7 +54,7 @@ - (void)handleCategoriesFromStore:(Store *)store {
}
- (void)handleProtocolsFromStore:(Store *)store {
- LogDebug(@"Preparing links for classes...");
+ LogDebug(@"Handling protocols...");
__weak LinkKnownObjectsTask *bself = self;
[store.storeProtocols enumerateObjectsUsingBlock:^(ProtocolInfo *class, NSUInteger idx, BOOL *stop) {
LogDebug(@"Handling %@...", class);
@@ -69,7 +69,7 @@ - (void)handleSuperClassesForClass:(ClassInfo *)class store:(Store *)store {
[store.storeClasses enumerateObjectsUsingBlock:^(ClassInfo *testedClass, NSUInteger idx, BOOL *stop) {
if (testedClass == class) return;
if (![testedClass.nameOfClass isEqualToString:class.nameOfSuperClass]) return;
- LogDebug(@"Found link to super class %@.", testedClass);
+ LogVerbose(@"Found link to super class %@.", testedClass);
class.classSuperClass.linkToObject = testedClass;
*stop = YES;
}];
@@ -79,7 +79,7 @@ - (void)handleExtendedClassesForCategory:(CategoryInfo *)category store:(Store *
if (category.categoryClass.nameOfObject.length == 0) return;
[store.storeClasses enumerateObjectsUsingBlock:^(ClassInfo *testedClass, NSUInteger idx, BOOL *stop) {
if (![testedClass.nameOfClass isEqualToString:category.nameOfClass]) return;
- LogDebug(@"Found link to extended class %@.", testedClass);
+ LogVerbose(@"Found link to extended class %@.", testedClass);
category.categoryClass.linkToObject = testedClass;
*stop = YES;
}];
@@ -90,7 +90,7 @@ - (void)handleAdoptedProtocolsForInterface:(InterfaceInfoBase *)interface store:
[interface.interfaceAdoptedProtocols enumerateObjectsUsingBlock:^(ObjectLinkInfo *link, NSUInteger idx, BOOL *stop) {
[store.storeProtocols enumerateObjectsUsingBlock:^(ProtocolInfo *protocol, NSUInteger idx, BOOL *stop) {
if (![protocol.nameOfProtocol isEqualToString:link.nameOfObject]) return;
- LogDebug(@"Found link to %@.", protocol);
+ LogVerbose(@"Found link to %@.", protocol);
link.linkToObject = protocol;
*stop = YES;
}];
View
1 appledoc/Processing/Processor.h
@@ -21,6 +21,7 @@
@property (nonatomic, strong) ProcessorTask *linkKnownObjectsTask;
@property (nonatomic, strong) ProcessorTask *mergeKnownObjectsTask;
+@property (nonatomic, strong) ProcessorTask *fetchDocumentationTask;
@property (nonatomic, strong) ProcessorCommentTask *splitCommentToSectionsTask;
@property (nonatomic, strong) ProcessorCommentTask *registerCommentComponentsTask;
@property (nonatomic, strong) ProcessorCommentTask *detectCrossReferencesTask;
View
14 appledoc/Processing/Processor.m
@@ -8,7 +8,9 @@
#import "Objects.h"
#import "Store.h"
+#import "LinkKnownObjectsTask.h"
#import "MergeKnownObjectsTask.h"
+#import "FetchDocumentationTask.h"
#import "SplitCommentToSectionsTask.h"
#import "RegisterCommentComponentsTask.h"
#import "DetectCrossReferencesTask.h"
@@ -20,9 +22,10 @@ @implementation Processor
- (NSInteger)runTask {
LogNormal(@"Processing...");
- __block GBResult result = GBResultOk;
+ GBResult result = GBResultOk;
GB_PROCESS([self.linkKnownObjectsTask runTask]);
GB_PROCESS([self.mergeKnownObjectsTask runTask]);
+ GB_PROCESS([self.fetchDocumentationTask runTask]);
GB_PROCESS([self processInterfaces:self.store.storeClasses]);
GB_PROCESS([self processInterfaces:self.store.storeExtensions]);
GB_PROCESS([self processInterfaces:self.store.storeCategories]);
@@ -78,7 +81,7 @@ - (NSInteger)processCommentForObject:(ObjectInfoBase *)object context:(ObjectInf
- (ProcessorTask *)linkKnownObjectsTask {
if (_linkKnownObjectsTask) return _linkKnownObjectsTask;
LogDebug(@"Initializing link known objects task due to first access...");
- _linkKnownObjectsTask = [[ProcessorTask alloc] initWithStore:self.store settings:self.settings];
+ _linkKnownObjectsTask = [[LinkKnownObjectsTask alloc] initWithStore:self.store settings:self.settings];
return _linkKnownObjectsTask;
}
@@ -89,6 +92,13 @@ - (ProcessorTask *)mergeKnownObjectsTask {
return _mergeKnownObjectsTask;
}
+- (ProcessorTask *)fetchDocumentationTask {
+ if (_fetchDocumentationTask) return _fetchDocumentationTask;
+ LogDebug(@"Initializing fetch documentation task due to first access...");
+ _fetchDocumentationTask = [[FetchDocumentationTask alloc] initWithStore:self.store settings:self.settings];
+ return _fetchDocumentationTask;
+}
+
- (ProcessorCommentTask *)splitCommentToSectionsTask {
if (_splitCommentToSectionsTask) return _splitCommentToSectionsTask;
LogDebug(@"Initializing split comment to sections task due to first acces...");
View
2 appledoc/Store/InterfaceInfoBase.m
@@ -109,6 +109,7 @@ - (void)beginPropertyDefinition {
LogVerbose(@"Starting property definition...");
PropertyInfo *info = [[PropertyInfo alloc] initWithRegistrar:self.objectRegistrar];
info.sourceToken = self.currentSourceInfo;
+ info.memberParent = self;
[[self.interfaceMethodGroups.lastObject methodGroupMethods] addObject:info];
[self.interfaceMethodsAndPropertiesInRegistrationOrder addObject:info];
[self.interfaceProperties addObject:info];
@@ -124,6 +125,7 @@ - (void)beginMethodDefinitionWithType:(NSString *)type {
MethodInfo *info = [[MethodInfo alloc] initWithRegistrar:self.objectRegistrar];
info.sourceToken = self.currentSourceInfo;
info.methodType = type;
+ info.memberParent = self;
[[self.interfaceMethodGroups.lastObject methodGroupMethods] addObject:info];
[self.interfaceMethodsAndPropertiesInRegistrationOrder addObject:info];
[[self methodsArrayForType:type] addObject:info];
View
21 appledoc/Store/MemberInfoBase.h
@@ -0,0 +1,21 @@
+//
+// MemberInfoBase.h
+// appledoc
+//
+// Created by Tomaz Kragelj on 12.12.12.
+// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
+//
+
+#import "ObjectInfoBase.h"
+
+@class InterfaceInfoBase;
+
+/** Specifies common attributes of an InterfaceInfoBase member.
+ */
+@interface MemberInfoBase : ObjectInfoBase
+
+- (NSString *)descriptionWithParent;
+
+@property (nonatomic, assign) InterfaceInfoBase *memberParent;
+
+@end
View
17 appledoc/Store/MemberInfoBase.m
@@ -0,0 +1,17 @@
+//
+// MemberInfoBase.m
+// appledoc
+//
+// Created by Tomaz Kragelj on 12.12.12.
+// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
+//
+
+#import "MemberInfoBase.h"
+
+@implementation MemberInfoBase
+
+- (NSString *)descriptionWithParent {
+ return [NSString stringWithFormat:@"[%@ %@]", self.memberParent, self.uniqueObjectID];
+}
+
+@end
View
5 appledoc/Store/MethodInfo.h
@@ -6,19 +6,20 @@
// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
//
-#import "ObjectInfoBase.h"
+#import "MemberInfoBase.h"
@class TypeInfo;
@class DescriptorsInfo;
/** Holds data for a class or interface Objective C method.
*/
-@interface MethodInfo : ObjectInfoBase
+@interface MethodInfo : MemberInfoBase
@property (nonatomic, copy) NSString *methodType;
@property (nonatomic, strong) TypeInfo *methodResult;
@property (nonatomic, strong) DescriptorsInfo *methodDescriptors;
@property (nonatomic, strong) NSMutableArray *methodArguments;
+@property (nonatomic, readonly, copy) NSString *methodSelector;
@property (nonatomic, readonly) BOOL isClassMethod;
@property (nonatomic, readonly) BOOL isInstanceMethod;
View
21 appledoc/Store/MethodInfo.m
@@ -12,11 +12,13 @@
#import "CommentInfo.h"
#import "TypeInfo.h"
#import "DescriptorsInfo.h"
+#import "InterfaceInfoBase.h"
#import "MethodArgumentInfo.h"
#import "MethodInfo.h"
@interface MethodInfo ()
-@property (nonatomic, strong) NSString *methodSelector;
+@property (nonatomic, readwrite, copy) NSString *methodSelector;
+@property (nonatomic, readonly) NSString *methodPrefix;
@end
#pragma mark -
@@ -57,13 +59,20 @@ - (NSString *)methodSelector {
return _methodSelector;
}
+- (NSString *)methodPrefix {
+ return (self.methodType == GBStoreTypes.classMethod) ? @"+" : @"-";
+}
+
+- (NSString *)descriptionWithParent {
+ return [NSString stringWithFormat:@"%@[%@ %@]", self.methodPrefix, self.memberParent.uniqueObjectID, self.methodSelector];
+}
+
- (NSString *)uniqueObjectID {
- return self.methodSelector;
+ return [NSString stringWithFormat:@"%@%@", self.methodPrefix, self.methodSelector];
}
- (NSString *)objectCrossRefPathTemplate {
- NSString *prefix = (self.methodType == GBStoreTypes.classMethod) ? @"+" : @"-";
- return [NSString stringWithFormat:@"#%@%@", prefix, self.methodSelector];
+ return [NSString stringWithFormat:@"#%@", self.uniqueObjectID];
}
- (BOOL)isClassMethod {
@@ -116,7 +125,7 @@ @implementation MethodInfo (Logging)
- (NSString *)description {
if (!_methodArguments) return @"method";
NSMutableString *result = [NSMutableString string];
- [result appendString:self.isClassMethod ? @"+" : @"-"];
+ [result appendString:self.methodPrefix];
if (_methodArguments) {
[self.methodArguments enumerateObjectsUsingBlock:^(MethodArgumentInfo *argument, NSUInteger idx, BOOL *stop) {
if (idx > 0) [result appendString:@" "];
@@ -128,7 +137,7 @@ - (NSString *)description {
- (NSString *)debugDescription {
NSMutableString *result = [self descriptionStringWithComment];
- [result appendString:self.isClassMethod ? @"+ " : @"- "];
+ [result appendString:self.methodPrefix];
if (_methodResult) [result appendFormat:@"(%@)", self.methodResult];
if (_methodArguments) {
[self.methodArguments enumerateObjectsUsingBlock:^(MethodArgumentInfo *argument, NSUInteger idx, BOOL *stop) {
View
4 appledoc/Store/PropertyInfo.h
@@ -6,15 +6,15 @@
// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
//
-#import "ObjectInfoBase.h"
+#import "MemberInfoBase.h"
@class AttributesInfo;
@class DescriptorsInfo;
@class TypeInfo;
/** Holds data for an Objective C property.
*/
-@interface PropertyInfo : ObjectInfoBase
+@interface PropertyInfo : MemberInfoBase
- (NSString *)propertyGetterSelector;
- (NSString *)propertySetterSelector;
View
10 appledoc/main.m
@@ -25,20 +25,16 @@ static void registerOptionDefinitions(GBOptionsHelper *options) {
{ 0, nil, @"PATHS", GBOptionSeparator },
{ 0, GBOptions.inputPaths, @"[a] Array of input paths for global and project settings", GBValueRequired|GBOptionNoCmdLine|GBOptionInvisible },
- { 't', GBOptions.templatesPath, @"Template files path", GBValueRequired },
{ 'i', GBOptions.ignoredPaths, @"[a] Ignore given path", GBValueRequired },
+ { 't', GBOptions.templatesPath, @"Template files path", GBValueRequired },
{ 0, nil, @"COMMENTS", GBOptionSeparator },
+ { 0, GBOptions.searchMissingComments, @"[b] Search for missing comments", GBValueNone },
{ 0, GBOptions.crossRefsFormat, @"Cross references format", GBValueRequired },
{ 0, nil, @"LOGGING", GBOptionSeparator },
- { 0, GBOptions.loggingLevel, @"Log verbosity", GBValueOptional },
+ { 0, GBOptions.loggingLevel, @"Log verbosity (1-2)", GBValueOptional },
{ 0, GBOptions.loggingFormat, @"Log format (0-3)", GBValueRequired },
- { 0, GBOptions.loggingCommonEnabled, @"[b] Enable common logging", GBValueNone|GBOptionNoHelp },
- { 0, GBOptions.loggingStoreEnabled, @"[b] Enable store logging", GBValueNone|GBOptionNoHelp },
- { 0, GBOptions.loggingParsingEnabled, @"[b] Enable parser logging", GBValueNone|GBOptionNoHelp },
- { 0, GBOptions.loggingProcessingEnabled, @"[b] Enable processing logging", GBValueNone|GBOptionNoHelp },
- { 0, GBOptions.loggingInternalEnabled, @"[b] Enable internal logging", GBValueNone|GBOptionNoHelp },
{ 0, nil, @"MISCELLANEOUS", GBOptionSeparator },
{ 0, GBOptions.printSettings, @"[b] Print settings for current run", GBValueNone },

0 comments on commit 89fc82c

Please sign in to comment.