Permalink
Browse files

Fixed XHTML see also member section output and refined various smalle…

…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...
1 parent 26c268f commit 23f72c5e47a6557c5e2b9282687c9497b35279e3 @tomaz committed Jul 9, 2009
View
@@ -169,7 +169,7 @@ data XML structure is exposed to the class.
@see appendDetailedDescriptionToData:fromItem:
*/
- (void) appendDescriptionToData:(NSMutableData*) data
- fromDescription:(id) item;
+ fromDescriptionItem:(id) item;
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Helper methods
View
@@ -371,7 +371,7 @@ - (void) appendObjectMemberPrototypeToData:(NSMutableData*) data
}
}
}
- [self appendLine:@" </code>" toData:data];
+ [self appendLine:@"</code>" toData:data];
}
}
@@ -396,11 +396,11 @@ - (void) appendObjectMemberSectionToData:(NSMutableData*) data
[self appendLine:@"</dt>" toData:data];
[self appendString:@" <dd>" toData:data];
- id descriptionItem = [self extractObjectParameterDescriptionNode:parameterItem];
+ id descriptionItem = [self extractObjectParameterDescriptionItem:parameterItem];
NSArray* descriptions = [self extractDescriptionsFromItem:descriptionItem];
for (id description in descriptions)
{
- [self appendDescriptionToData:data fromDescription:description];
+ [self appendDescriptionToData:data fromDescriptionItem:description];
}
[self appendLine:@"</dd>" toData:data];
}
@@ -419,7 +419,7 @@ - (void) appendObjectMemberReturnToData:(NSMutableData*) data
NSArray* descriptions = [self extractDescriptionsFromItem:returnItem];
for (id description in descriptions)
{
- [self appendDescriptionToData:data fromDescription:description];
+ [self appendDescriptionToData:data fromDescriptionItem:description];
}
}
}
@@ -457,7 +457,7 @@ - (void) appendObjectMemberWarningToData:(NSMutableData*) data
NSArray* descriptions = [self extractDescriptionsFromItem:warningItem];
for (id description in descriptions)
{
- [self appendDescriptionToData:data fromDescription:description];
+ [self appendDescriptionToData:data fromDescriptionItem:description];
}
// Append footer if bordered appearance is desired.
@@ -483,7 +483,7 @@ - (void) appendObjectMemberBugToData:(NSMutableData*) data
NSArray* descriptions = [self extractDescriptionsFromItem:bugItem];
for (id description in descriptions)
{
- [self appendDescriptionToData:data fromDescription:description];
+ [self appendDescriptionToData:data fromDescriptionItem:description];
}
// Append footer if bordered appearance is desired.
@@ -504,7 +504,22 @@ - (void) appendObjectMemberSeeAlsoToData:(NSMutableData*) data
for (id item in items)
{
[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:@" </ul>" toData:data];
@@ -754,7 +769,7 @@ - (void) appendBriefDescriptionToData:(NSMutableData*) data
NSArray* descriptions = [self extractBriefDescriptionsFromItem:item];
for (id description in descriptions)
{
- [self appendDescriptionToData:data fromDescription:description];
+ [self appendDescriptionToData:data fromDescriptionItem:description];
}
}
@@ -765,13 +780,13 @@ - (void) appendDetailedDescriptionToData:(NSMutableData*) data
NSArray* descriptions = [self extractDetailDescriptionsFromItem:item];
for (id description in descriptions)
{
- [self appendDescriptionToData:data fromDescription:description];
+ [self appendDescriptionToData:data fromDescriptionItem:description];
}
}
//----------------------------------------------------------------------------------------
- (void) appendDescriptionToData:(NSMutableData*) data
- fromDescription:(id) item
+ fromDescriptionItem:(id) item
{
int type = [self extractDescriptionType:item];
switch (type)
@@ -804,17 +819,17 @@ - (void) appendDescriptionToData:(NSMutableData*) data
break;
case kTKDescriptionStrongStart:
- [self appendString:@"<span class=\"strong\">" toData:data];
+ [self appendString:@"<strong>" toData:data];
break;
case kTKDescriptionStrongEnd:
- [self appendString:@"</span>" toData:data];
+ [self appendString:@"</strong>" toData:data];
break;
case kTKDescriptionEmphasisStart:
- [self appendString:@"<span class=\"emphasize\">" toData:data];
+ [self appendString:@"<em>" toData:data];
break;
case kTKDescriptionEmphasisEnd:
- [self appendString:@"</span>" toData:data];
+ [self appendString:@"</em>" toData:data];
break;
case kTKDescriptionExampleStart:
@@ -358,6 +358,6 @@ individual description components.
@param item The parameter item which description item to return.
@return Returns the parameter description item or @c nil if not found.
*/
-- (id) extractObjectParameterDescriptionNode:(id) item;
+- (id) extractObjectParameterDescriptionItem:(id) item;
@end
@@ -136,8 +136,23 @@ - (id) extractObjectMemberBugItem:(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];
- 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;
}
@@ -178,7 +193,7 @@ - (NSString*) extractObjectParameterName:(id) node
}
//----------------------------------------------------------------------------------------
-- (id) extractObjectParameterDescriptionNode:(id) node
+- (id) extractObjectParameterDescriptionItem:(id) node
{
return [self extractSubitemFromItem:node withName:@"description"];
}

0 comments on commit 23f72c5

Please sign in to comment.