Skip to content

Commit

Permalink
Fixed XHTML see also member section output and refined various smalle…
Browse files Browse the repository at this point in the history
…d details.

The problem was that the code generated empty see also section. The reason was twofold: first the code didn't properly handle references and second, the see also list extraction code in the XMLBasedOutputGenerator(ObjectParsingAPI) category returned custom XML which could not be parsed with existing references handling extraction methods.
  • Loading branch information
tomaz committed Jul 9, 2009
1 parent 26c268f commit 23f72c5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 18 deletions.
2 changes: 1 addition & 1 deletion XHTMLOutputGenerator.h
Expand Up @@ -169,7 +169,7 @@ data XML structure is exposed to the class.
@see appendDetailedDescriptionToData:fromItem: @see appendDetailedDescriptionToData:fromItem:
*/ */
- (void) appendDescriptionToData:(NSMutableData*) data - (void) appendDescriptionToData:(NSMutableData*) data
fromDescription:(id) item; fromDescriptionItem:(id) item;


////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
/// @name Helper methods /// @name Helper methods
Expand Down
43 changes: 29 additions & 14 deletions XHTMLOutputGenerator.m
Expand Up @@ -371,7 +371,7 @@ - (void) appendObjectMemberPrototypeToData:(NSMutableData*) data
} }
} }
} }
[self appendLine:@" </code>" toData:data]; [self appendLine:@"</code>" toData:data];
} }
} }


Expand All @@ -396,11 +396,11 @@ - (void) appendObjectMemberSectionToData:(NSMutableData*) data
[self appendLine:@"</dt>" toData:data]; [self appendLine:@"</dt>" toData:data];


[self appendString:@" <dd>" toData:data]; [self appendString:@" <dd>" toData:data];
id descriptionItem = [self extractObjectParameterDescriptionNode:parameterItem]; id descriptionItem = [self extractObjectParameterDescriptionItem:parameterItem];
NSArray* descriptions = [self extractDescriptionsFromItem:descriptionItem]; NSArray* descriptions = [self extractDescriptionsFromItem:descriptionItem];
for (id description in descriptions) for (id description in descriptions)
{ {
[self appendDescriptionToData:data fromDescription:description]; [self appendDescriptionToData:data fromDescriptionItem:description];
} }
[self appendLine:@"</dd>" toData:data]; [self appendLine:@"</dd>" toData:data];
} }
Expand All @@ -419,7 +419,7 @@ - (void) appendObjectMemberReturnToData:(NSMutableData*) data
NSArray* descriptions = [self extractDescriptionsFromItem:returnItem]; NSArray* descriptions = [self extractDescriptionsFromItem:returnItem];
for (id description in descriptions) for (id description in descriptions)
{ {
[self appendDescriptionToData:data fromDescription:description]; [self appendDescriptionToData:data fromDescriptionItem:description];
} }
} }
} }
Expand Down Expand Up @@ -457,7 +457,7 @@ - (void) appendObjectMemberWarningToData:(NSMutableData*) data
NSArray* descriptions = [self extractDescriptionsFromItem:warningItem]; NSArray* descriptions = [self extractDescriptionsFromItem:warningItem];
for (id description in descriptions) for (id description in descriptions)
{ {
[self appendDescriptionToData:data fromDescription:description]; [self appendDescriptionToData:data fromDescriptionItem:description];
} }


// Append footer if bordered appearance is desired. // Append footer if bordered appearance is desired.
Expand All @@ -483,7 +483,7 @@ - (void) appendObjectMemberBugToData:(NSMutableData*) data
NSArray* descriptions = [self extractDescriptionsFromItem:bugItem]; NSArray* descriptions = [self extractDescriptionsFromItem:bugItem];
for (id description in descriptions) for (id description in descriptions)
{ {
[self appendDescriptionToData:data fromDescription:description]; [self appendDescriptionToData:data fromDescriptionItem:description];
} }


// Append footer if bordered appearance is desired. // Append footer if bordered appearance is desired.
Expand All @@ -504,7 +504,22 @@ - (void) appendObjectMemberSeeAlsoToData:(NSMutableData*) data
for (id item in items) for (id item in items)
{ {
[self appendString:@" <li><code>" toData:data]; [self appendString:@" <li><code>" toData:data];
[self appendDescriptionToData:data fromDescription:item];
NSString* reference = [self extractDescriptionReference:item];
NSString* text = [self extractDescriptionText:item];

if (reference)
{
[self appendString:@"<a href=\"" toData:data];
[self appendString:reference toData:data];
[self appendString:@"\">" toData:data];
}
[self appendString:text toData:data];
if (reference)
{
[self appendString:@"</a>" toData:data];
}

[self appendLine:@"</code></li>" toData:data]; [self appendLine:@"</code></li>" toData:data];
} }
[self appendLine:@" </ul>" toData:data]; [self appendLine:@" </ul>" toData:data];
Expand Down Expand Up @@ -754,7 +769,7 @@ - (void) appendBriefDescriptionToData:(NSMutableData*) data
NSArray* descriptions = [self extractBriefDescriptionsFromItem:item]; NSArray* descriptions = [self extractBriefDescriptionsFromItem:item];
for (id description in descriptions) for (id description in descriptions)
{ {
[self appendDescriptionToData:data fromDescription:description]; [self appendDescriptionToData:data fromDescriptionItem:description];
} }
} }


Expand All @@ -765,13 +780,13 @@ - (void) appendDetailedDescriptionToData:(NSMutableData*) data
NSArray* descriptions = [self extractDetailDescriptionsFromItem:item]; NSArray* descriptions = [self extractDetailDescriptionsFromItem:item];
for (id description in descriptions) for (id description in descriptions)
{ {
[self appendDescriptionToData:data fromDescription:description]; [self appendDescriptionToData:data fromDescriptionItem:description];
} }
} }


//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
- (void) appendDescriptionToData:(NSMutableData*) data - (void) appendDescriptionToData:(NSMutableData*) data
fromDescription:(id) item fromDescriptionItem:(id) item
{ {
int type = [self extractDescriptionType:item]; int type = [self extractDescriptionType:item];
switch (type) switch (type)
Expand Down Expand Up @@ -804,17 +819,17 @@ - (void) appendDescriptionToData:(NSMutableData*) data
break; break;


case kTKDescriptionStrongStart: case kTKDescriptionStrongStart:
[self appendString:@"<span class=\"strong\">" toData:data]; [self appendString:@"<strong>" toData:data];
break; break;
case kTKDescriptionStrongEnd: case kTKDescriptionStrongEnd:
[self appendString:@"</span>" toData:data]; [self appendString:@"</strong>" toData:data];
break; break;


case kTKDescriptionEmphasisStart: case kTKDescriptionEmphasisStart:
[self appendString:@"<span class=\"emphasize\">" toData:data]; [self appendString:@"<em>" toData:data];
break; break;
case kTKDescriptionEmphasisEnd: case kTKDescriptionEmphasisEnd:
[self appendString:@"</span>" toData:data]; [self appendString:@"</em>" toData:data];
break; break;


case kTKDescriptionExampleStart: case kTKDescriptionExampleStart:
Expand Down
2 changes: 1 addition & 1 deletion XMLBasedOutputGenerator+ObjectParsingAPI.h
Expand Up @@ -358,6 +358,6 @@ individual description components.
@param item The parameter item which description item to return. @param item The parameter item which description item to return.
@return Returns the parameter description item or @c nil if not found. @return Returns the parameter description item or @c nil if not found.
*/ */
- (id) extractObjectParameterDescriptionNode:(id) item; - (id) extractObjectParameterDescriptionItem:(id) item;


@end @end
19 changes: 17 additions & 2 deletions XMLBasedOutputGenerator+ObjectParsingAPI.m
Expand Up @@ -136,8 +136,23 @@ - (id) extractObjectMemberBugItem:(id) node
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
- (NSArray*) extractObjectMemberSeeAlsoItems:(id) node - (NSArray*) extractObjectMemberSeeAlsoItems:(id) node
{ {
// Get all see also items, then make sure <ref> subnodes are properly handled.
NSArray* itemNodes = [node nodesForXPath:@"seeAlso/item" error:nil]; NSArray* itemNodes = [node nodesForXPath:@"seeAlso/item" error:nil];
if ([itemNodes count] > 0) return itemNodes; if ([itemNodes count] > 0)
{
NSMutableArray* result = [NSMutableArray array];
for (NSXMLNode* itemNode in itemNodes)
{
NSArray* refNodes = [itemNode nodesForXPath:@"ref" error:nil];
if ([refNodes count] > 0)
{
[result addObject:[refNodes objectAtIndex:0]];
continue;
}
[result addObject:itemNode];
}
return result;
}
return nil; return nil;
} }


Expand Down Expand Up @@ -178,7 +193,7 @@ - (NSString*) extractObjectParameterName:(id) node
} }


//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
- (id) extractObjectParameterDescriptionNode:(id) node - (id) extractObjectParameterDescriptionItem:(id) node
{ {
return [self extractSubitemFromItem:node withName:@"description"]; return [self extractSubitemFromItem:node withName:@"description"];
} }
Expand Down

0 comments on commit 23f72c5

Please sign in to comment.