diff --git a/CHDocumentationBrowser.xib b/CHDocumentationBrowser.xib index 72f6774..cdaba58 100644 --- a/CHDocumentationBrowser.xib +++ b/CHDocumentationBrowser.xib @@ -23,13 +23,13 @@ YES - - - - + + - + + + YES @@ -66,7 +66,7 @@ IGKWindow {1.79769e+308, 1.79769e+308} - {700, 500} + {500, 300} 256 @@ -74,7 +74,7 @@ {{0, 0}, {1680, 1028}} - {700, 522} + {500, 322} {1.79769e+308, 1.79769e+308} @@ -3872,7 +3872,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA {196, 240} {{202, 428}, {480, 270}} - {700, 500} + {500, 300} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/IGKArrayController.m b/IGKArrayController.m index 29a12c0..76a87a0 100644 --- a/IGKArrayController.m +++ b/IGKArrayController.m @@ -87,7 +87,7 @@ - (void)fetch:(void (^)(NSArray *managedObjectIDs, BOOL fetchContainsVip))comple } - (void)refresh { - [self refreshAndSelectFirst:YES renderSelection:NO]; + [self refreshAndSelectFirst:YES renderSelection:YES]; } - (void)refreshAndSelectFirst:(BOOL)selectFirst renderSelection:(BOOL)renderSelection { @@ -112,7 +112,7 @@ - (void)refreshAndSelectFirst:(BOOL)selectFirst renderSelection:(BOOL)renderSele [tableView scrollRowToVisible:0]; if (renderSelection) - [[tableView delegate] tableViewSelectionDidChange:nil]; + [[tableView delegate] tableViewSelectionDidChange:[NSNotification notificationWithName:NSTableViewSelectionDidChangeNotification object:tableView]]; } }]; } diff --git a/IGKScraper.m b/IGKScraper.m index 1401f0e..8b2d6c8 100644 --- a/IGKScraper.m +++ b/IGKScraper.m @@ -581,34 +581,58 @@ - (void)scrape //Depending on the type of obj, we will need to parse it differently NSEntityDescription *entity = [transientObject entity]; - if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"ObjCAbstractMethodContainer" inManagedObjectContext:transientContext]]) + if ([transientObject isKindOfEntityNamed:@"ObjCAbstractMethodContainer"]) { [self scrapeAbstractMethodContainer]; } - else if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"ObjCMethod" inManagedObjectContext:transientContext]]) + else if ([transientObject isKindOfEntityNamed:@"ObjCMethod"]) { [self scrapeMethod]; } - else if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"CFunction" inManagedObjectContext:transientContext]]) + else if ([transientObject isKindOfEntityNamed:@"CFunction"]) { [self scrapeApplecode:@"c/func"]; } - else if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"CTypedef" inManagedObjectContext:transientContext]]) + else if ([transientObject isKindOfEntityNamed:@"CTypedef"]) { [self scrapeApplecode:@"c/tdef"]; } - else if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"CStruct" inManagedObjectContext:transientContext]]) + else if ([transientObject isKindOfEntityNamed:@"CStruct"]) { [self scrapeApplecode:@"c/tdef"]; } + else if ([transientObject isKindOfEntityNamed:@"CEnum"]) + { + [self scrapeApplecode:@"c/tdef"]; + } + else if ([transientObject isKindOfEntityNamed:@"CMacro"]) + { + [self scrapeApplecode:@"c/macro"]; + } + else if ([transientObject isKindOfEntityNamed:@"CConstant"]) + { + [self scrapeApplecodes:[NSArray arrayWithObjects:@"c/econst", @"c/data", @"c/tag", nil]]; + } + else if ([transientObject isKindOfEntityNamed:@"CGlobal"]) + { + [self scrapeApplecode:@"c/constant_group"]; + } } - (void)scrapeApplecode:(NSString *)applecode +{ + [self scrapeApplecodes:[NSArray arrayWithObject:applecode]]; +} +- (void)scrapeApplecodes:(NSArray *)applecodes { NSError *err = nil; NSArray *methodNodes = [[doc rootElement] nodesForXPath:@"//a" error:&err]; - NSString *fullApplecodePattern = [NSString stringWithFormat:@"//apple_ref/%@*", applecode]; + NSMutableArray *fullApplecodePatterns = [[NSMutableArray alloc] init]; + for (NSString *applecode in applecodes) + { + [fullApplecodePatterns addObject:[NSString stringWithFormat:@"//apple_ref/%@*", applecode]]; + } //Search through all anchors in the document, and record their parent elements NSMutableSet *containersSet = [[NSMutableSet alloc] init]; @@ -624,19 +648,24 @@ - (void)scrapeApplecode:(NSString *)applecode NSString *strval = [el commentlessStringValue]; //(instm|clm|intfm|intfcm|intfp|instp) - if ([strval isLike:fullApplecodePattern]) + for (NSString *fullApplecodePattern in fullApplecodePatterns) { - NSString *methodName = [transientObject valueForKey:@"name"]; - - //This is a bit ropey - if ([strval isLike:[@"*" stringByAppendingString:methodName]]) + if ([strval isLike:fullApplecodePattern]) { - [containersSet addObject:[a parent]]; + NSString *methodName = [transientObject valueForKey:@"name"]; - NSArray *children = [[a parent] children]; - NSInteger index = [children indexOfObject:a]; - if (index != -1) - [self scrapeMethodChildren:children index:index managedObject:transientObject]; + //This is a bit ropey + if ([strval isLike:[@"*" stringByAppendingString:methodName]]) + { + [containersSet addObject:[a parent]]; + + NSArray *children = [[a parent] children]; + NSInteger index = [children indexOfObject:a]; + if (index != -1) + [self scrapeMethodChildren:children index:index managedObject:transientObject]; + + break; + } } } } diff --git a/IGKWindowController.h b/IGKWindowController.h index ae5bb72..19d2e1e 100644 --- a/IGKWindowController.h +++ b/IGKWindowController.h @@ -98,7 +98,9 @@ typedef enum { BOOL awaken; BOOL shouldIndex; BOOL isIndexing; - + + NSManagedObjectID *currentObjectIDInBrowser; + NSArray *selectedFilterDocset; } diff --git a/IGKWindowController.m b/IGKWindowController.m index 02fff68..61e2e68 100644 --- a/IGKWindowController.m +++ b/IGKWindowController.m @@ -506,6 +506,8 @@ - (IBAction)changeSelectedFilterDocset:(id)sender - (void)setBrowserActive:(BOOL)active { + currentObjectIDInBrowser = nil; + if (active) { id superview = [noselectionView superview]; @@ -634,6 +636,7 @@ - (void)sideSearchTableChangedSelection //If there's no selection, switch to the no selection search page else if ([sideSearchController selection] == nil) { + currentObjectIDInBrowser = nil; acceptableDisplayTypes = 0; [self setBrowserActive:NO]; @@ -683,9 +686,15 @@ - (void)loadDocIntoBrowser if (![[self currentArrayController] selection]) return; + NSManagedObject *currentSelectionObject = [[self currentArrayController] selection]; + if (currentObjectIDInBrowser && [[currentSelectionObject objectID] isEqual:currentObjectIDInBrowser]) + return; + + currentObjectIDInBrowser = [currentSelectionObject objectID]; + IGKHTMLGenerator *generator = [[IGKHTMLGenerator alloc] init]; [generator setContext:[[[NSApp delegate] valueForKey:@"kitController"] managedObjectContext]]; - [generator setManagedObject:[[self currentArrayController] selection]]; + [generator setManagedObject:currentSelectionObject]; [generator setDisplayTypeMask:[self tableOfContentsSelectedDisplayTypeMask]]; acceptableDisplayTypes = [generator acceptableDisplayTypes];