Permalink
Browse files

Introduced GBObjectDataProviding protocol for unified top-level objec…

…ts providers.

This should simplify comments "current context" processing which is needed for properly detecting and handling links.
  • Loading branch information...
1 parent 80f7f88 commit ecfd3217235d9e979c195ffc8c898531ac863ced @tomaz committed Sep 7, 2010
View
@@ -196,8 +196,8 @@ - (void)registerSpecialFromString:(NSString *)string type:(GBSpecialItemType)typ
#pragma mark Processing paragraph text
- (void)registerTextFromString:(NSString *)string toParagraph:(GBCommentParagraph *)paragraph {
- // Get and register all components.
- NSArray *components = [self textComponentsFromString:string];
+ // Get all components (as GBParagraphItem instances). Then post-process them for links and finaly register everything.
+ NSMutableArray *components = [[self textComponentsFromString:string] mutableCopy];
[components enumerateObjectsUsingBlock:^(GBParagraphItem *component, NSUInteger idx, BOOL *stop) {
[paragraph registerItem:component];
}];
View
@@ -17,10 +17,12 @@ @interface GBProcessor ()
- (void)processClasses;
- (void)processCategories;
- (void)processProtocols;
+- (void)processDataProvider:(id<GBObjectDataProviding>)provider withComment:(GBComment *)comment;
- (void)processAdoptedProtocolsFromProvider:(GBAdoptedProtocolsProvider *)provider;
- (void)processMethodsFromProvider:(GBMethodsProvider *)provider;
- (void)processComment:(GBComment *)comment;
@property (retain) GBCommentsProcessor *commentsProcessor;
+@property (retain) id<GBObjectDataProviding> currentContext;
@property (retain) id<GBApplicationSettingsProviding> settings;
@property (retain) id<GBStoreProviding> store;
@@ -47,11 +49,13 @@ - (id)initWithSettingsProvider:(id)settingsProvider {
}
return self;
}
+
#pragma mark Processing handling
- (void)processObjectsFromStore:(id<GBStoreProviding>)store {
NSParameterAssert(store != nil);
GBLogVerbose(@"Processing objects from %@...", store);
+ self.currentContext = nil;
self.store = store;
[self processClasses];
[self processCategories];
@@ -62,35 +66,33 @@ - (void)processClasses {
// No need to process ivars as they are not used for output.
for (GBClassData *class in self.store.classes) {
GBLogInfo(@"Processing class %@...", class);
- [self processAdoptedProtocolsFromProvider:class.adoptedProtocols];
- [self processComment:class.comment];
- [self processMethodsFromProvider:class.methods];
+ [self processDataProvider:class withComment:class.comment];
}
}
- (void)processCategories {
for (GBCategoryData *category in self.store.categories) {
GBLogInfo(@"Processing category %@...", category);
- [self processAdoptedProtocolsFromProvider:category.adoptedProtocols];
- [self processComment:category.comment];
- [self processMethodsFromProvider:category.methods];
+ [self processDataProvider:category withComment:category.comment];
}
}
- (void)processProtocols {
for (GBProtocolData *protocol in self.store.protocols) {
GBLogInfo(@"Processing protocol %@...", protocol);
- [self processAdoptedProtocolsFromProvider:protocol.adoptedProtocols];
- [self processComment:protocol.comment];
- [self processMethodsFromProvider:protocol.methods];
+ [self processDataProvider:protocol withComment:protocol.comment];
}
}
-- (void)processMethodsFromProvider:(GBMethodsProvider *)provider {
- for (GBMethodData *method in provider.methods) {
- GBLogVerbose(@"Processing method %@...", method);
- [self processComment:method.comment];
- }
+#pragma mark Common data processing
+
+- (void)processDataProvider:(id<GBObjectDataProviding>)provider withComment:(GBComment *)comment {
+ // Set current context then process all data.
+ self.currentContext = provider;
+ [self processAdoptedProtocolsFromProvider:provider.adoptedProtocols];
+ [self processComment:comment];
+ [self processMethodsFromProvider:provider.methods];
+ self.currentContext = nil;
}
- (void)processAdoptedProtocolsFromProvider:(GBAdoptedProtocolsProvider *)provider {
@@ -107,6 +109,13 @@ - (void)processAdoptedProtocolsFromProvider:(GBAdoptedProtocolsProvider *)provid
}
}
+- (void)processMethodsFromProvider:(GBMethodsProvider *)provider {
+ for (GBMethodData *method in provider.methods) {
+ GBLogVerbose(@"Processing method %@...", method);
+ [self processComment:method.comment];
+ }
+}
+
#pragma mark Comments processing
- (void)processComment:(GBComment *)comment {
@@ -118,6 +127,7 @@ - (void)processComment:(GBComment *)comment {
#pragma mark Properties
@synthesize commentsProcessor;
+@synthesize currentContext;
@synthesize settings;
@synthesize store;
View
@@ -7,13 +7,14 @@
//
#import "GBModelBase.h"
+#import "GBObjectDataProviding.h"
@class GBAdoptedProtocolsProvider;
@class GBMethodsProvider;
/** Describes a category.
*/
-@interface GBCategoryData : GBModelBase {
+@interface GBCategoryData : GBModelBase <GBObjectDataProviding> {
@private
NSString *_categoryName;
NSString *_className;
View
@@ -7,14 +7,15 @@
//
#import "GBModelBase.h"
+#import "GBObjectDataProviding.h"
@class GBAdoptedProtocolsProvider;
@class GBIvarsProvider;
@class GBMethodsProvider;
/** Describes a class.
*/
-@interface GBClassData : GBModelBase {
+@interface GBClassData : GBModelBase <GBObjectDataProviding> {
@private
NSString *_className;
GBAdoptedProtocolsProvider *_adoptedProtocols;
@@ -0,0 +1,27 @@
+//
+// GBObjectDataProviding.h
+// appledoc
+//
+// Created by Tomaz Kragelj on 7.9.10.
+// Copyright 2010 Gentle Bytes. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@class GBAdoptedProtocolsProvider;
+@class GBMethodsProvider;
+@class GBComment;
+
+/** Defines the requirements for object data providers.
+
+ Object data providers are responsible for providing various bits of data from top level store objects.
+ */
+@protocol GBObjectDataProviding
+
+/** Object's adopted protocols, available via `GBAdoptedProtocolsProvider`. */
+@property (readonly) GBAdoptedProtocolsProvider *adoptedProtocols;
+
+/** Object's methods, available via `GBMethodsProvider`. */
+@property (readonly) GBMethodsProvider *methods;
+
+@end
View
@@ -7,12 +7,13 @@
//
#import "GBModelBase.h"
+#import "GBObjectDataProviding.h"
@class GBAdoptedProtocolsProvider;
@class GBMethodsProvider;
/** Describes a protocol. */
-@interface GBProtocolData : GBModelBase {
+@interface GBProtocolData : GBModelBase <GBObjectDataProviding> {
@private
NSString *_protocolName;
GBAdoptedProtocolsProvider *_adoptedProtocols;
@@ -172,6 +172,7 @@
7377404112301AC700E29F1E /* GBParagraphDecoratorItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBParagraphDecoratorItem.h; sourceTree = "<group>"; };
7377404212301AC700E29F1E /* GBParagraphDecoratorItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBParagraphDecoratorItem.m; sourceTree = "<group>"; };
7377404512301CDC00E29F1E /* GBCommentsProcessor-DecoratorItemsTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBCommentsProcessor-DecoratorItemsTesting.m"; sourceTree = "<group>"; };
+ 73A32FB112364BC100040070 /* GBObjectDataProviding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBObjectDataProviding.h; sourceTree = "<group>"; };
73AAACD1122F8E8B00EAF358 /* GBCommentsProcessor-BugsTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBCommentsProcessor-BugsTesting.m"; sourceTree = "<group>"; };
73AAACFC122F904400EAF358 /* GBCommentsProcessor-ExamplesTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBCommentsProcessor-ExamplesTesting.m"; sourceTree = "<group>"; };
73CF8130122D3824005B7E26 /* RegexKitLite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegexKitLite.m; sourceTree = "<group>"; };
@@ -500,6 +501,7 @@
isa = PBXGroup;
children = (
73FC6DE311FCD09400AAD0B9 /* GBStoreProviding.h */,
+ 73A32FB112364BC100040070 /* GBObjectDataProviding.h */,
73FC6E0D11FCD54400AAD0B9 /* GBStore.h */,
73FC6E0E11FCD54400AAD0B9 /* GBStore.m */,
73FC6E8511FCD93A00AAD0B9 /* GBClassData.h */,

0 comments on commit ecfd321

Please sign in to comment.