Skip to content

Commit

Permalink
Now does deprecated methods... sorta
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Gordon authored and Alex Gordon committed Jun 5, 2010
1 parent ff013fb commit 375b125
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 46 deletions.
2 changes: 1 addition & 1 deletion IGKScraper.h
Expand Up @@ -32,7 +32,7 @@
NSString *developerDirectory;
}

- (id)initWithDocsetURL:(NSURL *)theDocsetURL managedObjectContext:(NSManagedObjectContext *)moc launchController:(IGKLaunchController*)lc dbQueue:(dispatch_queue_t)dbq;
- (id)initWithDocsetURL:(NSURL *)theDocsetURL managedObjectContext:(NSManagedObjectContext *)moc launchController:(IGKLaunchController*)lc dbQueue:(dispatch_queue_t)dbq developerDirectory:(NSString *)devDir;

- (void)findPathCount;
- (BOOL)findPaths;
Expand Down
62 changes: 26 additions & 36 deletions IGKScraper.m
Expand Up @@ -20,7 +20,7 @@ - (NSUInteger)backgroundSearch:(NSManagedObject *)docset;

+ (NSArray *)pathOfDeprecationAppendiciesForPath:(NSString *)indexPath;

- (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)relativeExtractPath docset:(NSManagedObject *)docset isDeprecationAppendix:(BOOL)isDeprecationAppendix mainObjectIn:(NSManagedObject *)mainObjectIn mainObjectOut:(NSManagedObject **)mainObjectOut;
- (NSManagedObject *)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)relativeExtractPath docset:(NSManagedObject *)docset isDeprecationAppendix:(BOOL)isDeprecationAppendix mainObjectIn:(NSManagedObject *)mainObjectIn;
- (NSManagedObject *)addRecordNamed:(NSString *)recordName entityName:(NSString *)entityName desc:(NSString *)recordDesc sourcePath:(NSString *)recordPath;

@end
Expand Down Expand Up @@ -224,20 +224,21 @@ - (void)index
for (NSString *relativeExtractPath in paths)
{
NSString *indexPath = [docsetPathWithPrefix stringByAppendingPathComponent:relativeExtractPath];
NSManagedObject *mainObject = nil;
[self extractPath:indexPath relativeExtractPath:relativeExtractPath docset:scraperDocset isDeprecationAppendix:NO mainObjectIn:nil mainObjectOut:&mainObject];

//Try to find matching deprecated appendicies
NSArray *deprecationAppendicies = [[self class] pathOfDeprecationAppendiciesForPath:indexPath];
for (NSString *deprecationAppendixPath in deprecationAppendicies)
NSManagedObject *mainObject = [self extractPath:indexPath relativeExtractPath:relativeExtractPath docset:scraperDocset isDeprecationAppendix:NO mainObjectIn:nil];

//Try to find matching deprecated appendicies
if (mainObject)
{
NSLog(@"mainObject = %@", mainObject);
[self extractPath:[[indexPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:deprecationAppendixPath]
relativeExtractPath:[[relativeExtractPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:deprecationAppendixPath]
docset:scraperDocset
isDeprecationAppendix:YES
mainObjectIn:mainObject
mainObjectOut:NULL];
NSArray *deprecationAppendicies = [[self class] pathOfDeprecationAppendiciesForPath:indexPath];
for (NSString *deprecationAppendixPath in deprecationAppendicies)
{
[self extractPath:[[[indexPath stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:deprecationAppendixPath]
relativeExtractPath:[[[relativeExtractPath stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:deprecationAppendixPath]
docset:scraperDocset
isDeprecationAppendix:YES
mainObjectIn:mainObject];
}
}

pathsCounter += 1;
Expand All @@ -250,7 +251,10 @@ - (void)index
}
+ (NSArray *)pathOfDeprecationAppendiciesForPath:(NSString *)indexPath
{
NSString *deprecationAppendiciesFolder = [[indexPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"DeprecationAppendix"];
if (![[indexPath pathComponents] containsObject:@"Reference"])
return nil;

NSString *deprecationAppendiciesFolder = [[[indexPath stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"DeprecationAppendix"];

NSError *err = nil;
NSArray *appendixPaths = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:deprecationAppendiciesFolder error:&err];
Expand All @@ -268,19 +272,14 @@ + (NSArray *)pathOfDeprecationAppendiciesForPath:(NSString *)indexPath
return deprecationAppendicies;
}

- (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)relativeExtractPath docset:(NSManagedObject *)docset isDeprecationAppendix:(BOOL)isDeprecationAppendix mainObjectIn:(NSManagedObject *)mainObjectIn mainObjectOut:(NSManagedObject **)mainObjectOut
{
if (isDeprecationAppendix)
{
NSLog(@"Deprecation appendix '%@'", extractPath);
}

- (NSManagedObject *)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)relativeExtractPath docset:(NSManagedObject *)docset isDeprecationAppendix:(BOOL)isDeprecationAppendix mainObjectIn:(NSManagedObject *)mainObjectIn
{
//Let's try to extract the class's name (assuming it is a class of course)
NSError *error = nil;
NSString *contents = [NSString stringWithContentsOfFile:extractPath encoding:NSUTF8StringEncoding error:&error];
if (error || !contents)
{
return NO;
return nil;
}


Expand All @@ -289,7 +288,7 @@ - (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)rela
NSArray *className_captures = [contents captureComponentsMatchedByRegex:regex_className];
if ([className_captures count] < 3)
{
return NO;
return nil;
}

NSString *type = [className_captures objectAtIndex:2];
Expand Down Expand Up @@ -349,7 +348,7 @@ - (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)rela
else if (!isDeprecationAppendix)
{
// bail
return NO;
return nil;
}

//Superclass
Expand Down Expand Up @@ -409,6 +408,7 @@ - (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)rela

/* The interesting captures are 3 & 4, and 5 & 6 */
NSArray *items = [contents arrayOfCaptureComponentsMatchedByRegex:linkRegex];
__block NSManagedObject *obj = mainObjectIn;

dispatch_sync(dbQueue, ^{

Expand All @@ -426,7 +426,6 @@ - (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)rela
NSEntityDescription *unionEntity = nil;

//If this isn't a deprecation appendix, create a parent object
NSManagedObject *obj = mainObjectIn;
if (entityName && isDeprecationAppendix == NO)
{
obj = [self addRecordNamed:name entityName:entityName desc:@"" sourcePath:relativeExtractPath];
Expand All @@ -445,12 +444,6 @@ - (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)rela
}
}

if (mainObjectOut)
*mainObjectOut = obj;

if (mainObjectOut)
NSLog(@"mainObjectOut = %d, *mainObjectOut = %d, obj = %d", mainObjectOut, *mainObjectOut, obj);

int lastWasProperty = 0;
for (NSArray *captures in items)
{
Expand Down Expand Up @@ -490,9 +483,6 @@ - (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)rela
if (isDeprecationAppendix)
[newMethod setValue:[NSNumber numberWithBool:YES] forKey:@"isDeprecated"];

if (isDeprecationAppendix)
NSLog(@"newMethod = %@", newMethod);

if (!isProperty)
[newMethod setValue:[NSNumber numberWithBool:isInstanceMethod] forKey:@"isInstanceMethod"];

Expand Down Expand Up @@ -630,8 +620,8 @@ - (BOOL)extractPath:(NSString *)extractPath relativeExtractPath:(NSString *)rela
}

});
return YES;

return obj;
}

- (NSManagedObject *)addRecordNamed:(NSString *)recordName entityName:(NSString *)entityName desc:(NSString *)recordDesc sourcePath:(NSString *)recordPath
Expand Down
12 changes: 10 additions & 2 deletions IGKSometimesCenteredTextCell.h
Expand Up @@ -10,13 +10,21 @@

//This isn't hacky at all. Not... at... all...

@interface IGKSometimesCenteredTextCell : NSTextFieldCell {
@interface IGKStrikethroughTextCell : NSTextFieldCell {
BOOL hasStrikethrough;
}

@property (assign) BOOL hasStrikethrough;

@end

@interface IGKSometimesCenteredTextCell : IGKStrikethroughTextCell {

}

@end

@interface IGKSometimesCenteredTextCell2 : NSTextFieldCell {
@interface IGKSometimesCenteredTextCell2 : IGKStrikethroughTextCell {

}

Expand Down
31 changes: 25 additions & 6 deletions IGKSometimesCenteredTextCell.m
Expand Up @@ -9,6 +9,20 @@
#import "IGKSometimesCenteredTextCell.h"


@implementation IGKStrikethroughTextCell

+ (void)drawStrikethroughInRect:(NSRect)rect
{
[[NSColor redColor] set];

rect.origin.y = rect.size.height / 2.0;
rect.size.height = 1.0;

NSRectFillUsingOperation(rect, NSCompositeSourceOver);
}

@end

@implementation IGKSometimesCenteredTextCell

/*
Expand All @@ -30,6 +44,9 @@ - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
cellFrame.origin.y += [self tag];
[super drawWithFrame:cellFrame inView:controlView];

if (hasStrikethrough)
[self drawStrikethroughInRect:cellFrame];
}


Expand All @@ -38,15 +55,17 @@ - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
@implementation IGKSometimesCenteredTextCell2

- (NSRect)titleRectForBounds:(NSRect)theRect {
NSRect titleFrame = [super titleRectForBounds:theRect];
NSSize titleSize = [[self attributedStringValue] size];
titleFrame.origin.y += [self tag];
return titleFrame;
NSRect titleFrame = [super titleRectForBounds:theRect];
NSSize titleSize = [[self attributedStringValue] size];
titleFrame.origin.y += [self tag];
return titleFrame;
}

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSRect titleRect = [self titleRectForBounds:cellFrame];
[[self attributedStringValue] drawInRect:titleRect];
NSRect titleRect = [self titleRectForBounds:cellFrame];
[[self attributedStringValue] drawInRect:titleRect];
if (hasStrikethrough)
[self drawStrikethroughInRect:cellFrame];
}

@end
2 changes: 1 addition & 1 deletion IGKWordMembership.m
Expand Up @@ -41,7 +41,7 @@ - (NSString *)addHyperlinksToPassage:(NSString *)passage
[newString appendString:[passage substringWithRange:NSMakeRange(NSMaxRange(previousRange), inbetweenLength)]];
}

if ([words containsObject:substring])
if ([substring length] > 1 && [words containsObject:substring])
{
[newString appendString:@"<a href='http://ingr-link/"];
[newString appendString:substring];
Expand Down

0 comments on commit 375b125

Please sign in to comment.