Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #315 from andreiaf/master

Fixed Xcode crush on ALT+double-click and resolve QuickHelp lookup problem (#235, #289, #315). Fixed #318 for incorrectly formatted setter in @property
  • Loading branch information...
commit 204f5728382f954e066b38beb6ca63ac1d5a2c72 2 parents 30a0119 + 657afd7
@tomaz authored
View
58 Generating/GBDocSetOutputGenerator.m
@@ -29,6 +29,7 @@ - (void)addTokensXmlModelObjectDataForPropertySetterAndGetter:(GBModelBase *)pro
- (void)initializeSimplifiedObjects;
- (NSArray *)simplifiedObjectsFromObjects:(NSArray *)objects value:(NSString *)value index:(NSUInteger *)index;
- (NSString *)tokenIdentifierForObject:(GBModelBase *)object;
+-(void) addGetterSetterToMethods:(GBMethodData *)property for:(NSString *)name withReturnResult:(NSArray*)results withTypes:(NSArray *)types withArguments:(NSArray *)arguments withData:(NSDictionary *)data toArray:(NSMutableArray *)members;
@property (retain) NSArray *documents;
@property (retain) NSArray *classes;
@@ -36,6 +37,8 @@ - (NSString *)tokenIdentifierForObject:(GBModelBase *)object;
@property (retain) NSArray *protocols;
@property (readonly) NSMutableSet *temporaryFiles;
+@property (retain) id sectionID; //tmp for class's refid
+
@end
#pragma mark -
@@ -230,6 +233,8 @@ - (BOOL)processTokensXmlForObjects:(NSArray *)objects type:(NSString *)type temp
// Prepare template variables for object. Note that we reuse the ID assigned while creating the data for Nodes.xml.
NSMutableDictionary *objectData = [NSMutableDictionary dictionaryWithCapacity:2];
[objectData setObject:[simplifiedObjectData objectForKey:@"id"] forKey:@"refid"];
+ // save refid
+ _sectionID = [objectData objectForKey:@"refid"];
[self addTokensXmlModelObjectDataForObject:topLevelObject toData:objectData];
// Prepare the list of all members.
@@ -237,7 +242,7 @@ - (BOOL)processTokensXmlForObjects:(NSArray *)objects type:(NSString *)type temp
for (GBMethodData *method in methodsProvider.methods) {
NSMutableDictionary *data = [NSMutableDictionary dictionaryWithCapacity:4];
[data setObject:[self.settings htmlReferenceNameForObject:method] forKey:@"anchor"];
- [self addTokensXmlModelObjectDataForObject:method toData:data];
+ [self addTokensXmlModelObjectDataForObject:method toData:data];
[self addTokensXmlModelObjectDataForPropertySetterAndGetter:method withData:data toArray:membersData];
[membersData addObject:data];
}
@@ -289,6 +294,7 @@ - (void)addTokensXmlModelObjectDataForObject:(GBModelBase *)object toData:(NSMut
if ([object isKindOfClass:[GBMethodData class]]) {
GBMethodData *method = (GBMethodData *)object;
[data setObject:method.formattedComponents forKey:@"formattedComponents"];
+ [data setObject:_sectionID forKey:@"refid"];
if (method.comment) {
if (method.comment.hasMethodParameters) {
NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:[method.comment.methodParameters count]];
@@ -319,26 +325,42 @@ - (void)addTokensXmlModelObjectDataForPropertySetterAndGetter:(GBModelBase *)met
GBMethodData *property = (GBMethodData *)method;
if (!property.isProperty) return;
- // Setter: returns void, has an argument of the same type as the property, use property's setterSelector as name and avoid duplication of the colon by trimming it. Copy source infos from property.
+ // Setter: returns void, has an argument of the same type as the property, use property's setterSelector as name and avoid duplication of the colon by trimming it. Copy source infos from property.
NSArray *setterResults = [NSArray arrayWithObjects:@"void", nil];
NSArray *setterTypes = [property methodResultTypes];
NSString *setterName = [property propertySetterSelector];
- setterName = [setterName stringByTrimmingCharactersInSet:[NSCharacterSet punctuationCharacterSet]];
- NSArray *setterArgs = [NSArray arrayWithObject:[GBMethodArgument methodArgumentWithName:setterName types:setterTypes var:@"val"]];
- GBMethodData *setterMethod = [GBMethodData methodDataWithType:GBMethodTypeInstance result:setterResults arguments:setterArgs];
- GBLogDebug(@"Adding setter method %@ for property: %@", setterMethod, property);
- setterMethod.parentObject = property.parentObject;
- setterMethod.comment = property.comment;
- for (GBSourceInfo *info in property.sourceInfos) {
- [setterMethod registerSourceInfo:info];
- }
-
- // Add Setter to XML and also copy anchor from property, override declaration with @property one.
- NSMutableDictionary *setterData = [NSMutableDictionary dictionaryWithCapacity:4];
- [setterData setObject:[self.settings htmlReferenceNameForObject:property] forKey:@"anchor"];
- [self addTokensXmlModelObjectDataForObject:setterMethod toData:setterData];
- [setterData setObject:[data objectForKey:@"formattedComponents"] forKey:@"formattedComponents"];
- [members addObject:setterData];
+ setterName = [setterName stringByTrimmingCharactersInSet:[NSCharacterSet punctuationCharacterSet]];
+ NSArray *setterArgs = [NSArray arrayWithObject:[GBMethodArgument methodArgumentWithName:setterName types:setterTypes var:@"val"]];
+ [self addGetterSetterToMethods:property for:setterName withReturnResult:setterResults withTypes:setterTypes withArguments:setterArgs withData:data toArray:members];
+
+ // Getter: returns the same as property, use property's getterSelector as name, takes no arguments. Copy source infos from property.
+ NSArray *getterResults = [NSArray arrayWithObjects:property.methodReturnType, nil];
+ NSArray *getterTypes = [property methodResultTypes];
+ NSString *getterName = [property propertyGetterSelector];
+ NSArray *getterArgs = [NSArray arrayWithObject:[GBMethodArgument methodArgumentWithName:getterName types:getterTypes var:nil]];
+ [self addGetterSetterToMethods:property for:getterName withReturnResult:getterResults withTypes:getterTypes withArguments:getterArgs withData:data toArray:members];
+}
+
+-(void) addGetterSetterToMethods:(GBMethodData *)property
+ for:(NSString *)name
+ withReturnResult:(NSArray*)results
+ withTypes:(NSArray *)types
+ withArguments:(NSArray *)arguments
+ withData:(NSDictionary *)data
+ toArray:(NSMutableArray *)members
+{
+ GBMethodData *method = [GBMethodData methodDataWithType:GBMethodTypeInstance result:results arguments:arguments];
+ method.parentObject = property.parentObject;
+ method.comment = property.comment;
+ for (GBSourceInfo *info in property.sourceInfos) {
+ [method registerSourceInfo:info];
+ }
+ NSMutableDictionary *methodData = [NSMutableDictionary dictionaryWithCapacity:4];
+ [methodData setObject:[self.settings htmlReferenceNameForObject:property] forKey:@"anchor"];
+ [self addTokensXmlModelObjectDataForObject:method toData:methodData];
+ [methodData setObject:[data objectForKey:@"formattedComponents"] forKey:@"formattedComponents"];
+ [members addObject:methodData];
+
}
- (NSString *)tokenIdentifierForObject:(GBModelBase *)object {
View
14 Model/GBMethodData.m
@@ -136,18 +136,28 @@ - (NSArray *)formattedComponents {
// Add the list of attributes.
if ([self.methodAttributes count] > 0) {
__block BOOL isSetterOrGetter = NO;
+ __block BOOL hasSetter = NO;
[result addObject:[self formattedComponentWithValue:@"("]];
[self.methodAttributes enumerateObjectsUsingBlock:^(NSString *attribute, NSUInteger idx, BOOL *stop) {
- [result addObject:[self formattedComponentWithValue:attribute]];
+ if(hasSetter && [attribute isEqualToString:@":"]) //remove previously added "," and " " to keep clean setter=xxx:
+ {
+ [result removeLastObject];
+ [result removeLastObject];
+ hasSetter = NO;
+ }
+ [result addObject:[self formattedComponentWithValue:attribute]];
if ([attribute isEqualToString:@"setter"] || [attribute isEqualToString:@"getter"]) {
isSetterOrGetter = YES;
+ if ([attribute isEqualToString:@"setter"]) {
+ hasSetter = YES;
+ }
return;
}
if (isSetterOrGetter) {
if ([attribute isEqualToString:@"="]) return;
isSetterOrGetter = NO;
}
- if (idx < [self.methodAttributes count]-1) {
+ if (idx < [self.methodAttributes count]-1 ) {
[result addObject:[self formattedComponentWithValue:@","]];
[result addObject:[self formattedComponentWithValue:@" "]];
}
View
1  Templates/docset/Contents/Resources/tokens-template.xml
@@ -25,6 +25,7 @@
</Parameters>{{/hasParameters}}
{{#returnValue}}<ReturnValue>{{>Abstract}}</ReturnValue>{{/returnValue}}
{{#anchor}}<Anchor>{{anchor}}</Anchor>{{/anchor}}
+ {{#refid}}<NodeRef refid="{{refid}}"/>{{/refid}}
</Token>
{{/members}}
</File>
View
46 XcodeIntegrationScript.markdown
@@ -0,0 +1,46 @@
+Sample script to Enamble Xcode integration
+==========================================
+
+appledoc can be integrated with Xcode in many ways. Below is one of those to get you up and running quickly on Xcode 4.6
+
+1. Select top of your project in Project Navigator
+2. Click Add Target
+3. Depending on your project type (IOS or OS X) choose Aggregate Template
+4. Create new target. I suggest to call it Documentation
+5. Click on Build Phases and add new Build Phase based on Script
+6. Paste the script below into the script window
+7. Adjust variables in section "Start Constants" as required
+8. Uncomment correct 'target' for your project and comment out another one depending on your project type.
+9. Adjust path to appledoc binary and appledoc's command-line switches if required
+10. When you ready to generate a docset from your project, build Documentation target.
+11. Docset will be installed into new loction and will become available to Xcode immediately.
+12. To refresh Quick Help (ALT+Click) and (ALT+double-click) you may need to restart Xcode to refresh its index cache.
+
+
+
+#appledoc Xcode script
+# Start constants
+company="ACME";
+companyID="com.ACME";
+companyURL="http://ACME.com";
+target="iphoneos";
+#target="macosx";
+outputPath="~/help";
+# End constants
+/usr/local/bin/appledoc \
+--project-name "${PROJECT_NAME}" \
+--project-company "${company}" \
+--company-id "${companyID}" \
+--docset-atom-filename "${company}.atom" \
+--docset-feed-url "${companyURL}/${company}/%DOCSETATOMFILENAME" \
+--docset-package-url "${companyURL}/${company}/%DOCSETPACKAGEFILENAME" \
+--docset-fallback-url "${companyURL}/${company}" \
+--output "${outputPath}" \
+--publish-docset \
+--docset-platform-family "${target}" \
+--logformat xcode \
+--keep-intermediate-files \
+--no-repeat-first-par \
+--no-warn-invalid-crossref \
+--exit-threshold 2 \
+"${PROJECT_DIR}"
View
2  appledoc.xcodeproj/project.pbxproj
@@ -527,6 +527,7 @@
73FC742B11FE274300AAD0B9 /* GBMethodArgument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBMethodArgument.h; sourceTree = "<group>"; };
73FC742C11FE274300AAD0B9 /* GBMethodArgument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBMethodArgument.m; sourceTree = "<group>"; };
73FC743511FE2CEB00AAD0B9 /* GBMethodDataTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBMethodDataTesting.m; sourceTree = "<group>"; };
+ 75C6C0D416CAA8D900E254F7 /* XcodeIntegrationScript.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = XcodeIntegrationScript.markdown; sourceTree = "<group>"; };
8DD76FA10486AA7600D96B5E /* appledoc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = appledoc; sourceTree = BUILT_PRODUCTS_DIR; };
B4D1FFC015FF5F05009736E2 /* crypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = crypt.h; sourceTree = "<group>"; };
B4D1FFC115FF5F05009736E2 /* ioapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ioapi.c; sourceTree = "<group>"; };
@@ -594,6 +595,7 @@
B4D1FFF615FF643D009736E2 /* install-appledoc.sh */,
73EA656912B7944E00398BD1 /* Readme.markdown */,
73EEB7A812CA2BE700E546DB /* Developer Notes.markdown */,
+ 75C6C0D416CAA8D900E254F7 /* XcodeIntegrationScript.markdown */,
739038301319926400B9CA74 /* AppledocSettings.plist */,
73D54C9011F8D18300CCDDB0 /* Classes */,
739AD36F1254449D00B642C3 /* Templates */,
Please sign in to comment.
Something went wrong with that request. Please try again.