Permalink
Browse files

Refactored description blocks documentation extraction.

Instead of forcing the XMLBasedOutputGenerator subclasses dealing with the underlying XML structure (which was the main reason behind the creation of the XMLBasedOutputGenerator class), the subclasses can use extraction methods in the same way as for handling the rest of the output.
  • Loading branch information...
1 parent b1fc06f commit 26c268f5f394b76b232dc20c4b158a525eed24fe @tomaz committed Jun 18, 2009
View
@@ -164,6 +164,8 @@ line of text. At least with current browser width. And yea, because I'm not onli
the moment, I cannot use lorem ipsum for that. And I also don't know it from the memory.
There's much more important stuff to remember than that... Except for the cases like this
where the text is actually needed. Well, looks like my imagination is still working...
+
+Here's an example of how to get @b strong or @a emphasized items.
@param param The parameter.
@param value The value.
View
@@ -133,7 +133,11 @@
</xsl:template>
<xsl:template match="bold">
- <bold><xsl:apply-templates/></bold>
+ <strong><xsl:apply-templates/></strong>
+ </xsl:template>
+
+ <xsl:template match="emphasis">
+ <emphasis><xsl:apply-templates/></emphasis>
</xsl:template>
<xsl:template match="para">
View
@@ -276,10 +276,14 @@ dl.parameterList dd {
padding-top: 0.3em;
}
-.emphasize {
+.strong {
font-weight: bold;
}
+.emphasize {
+ font-style: italic;
+}
+
/* @end */
/* @group Tooltips */
View
@@ -135,8 +135,7 @@ of the given data.
@param item The description item which brief subcsection to append.
@exception NSException Thrown if appending fails.
@see appendDetailedDescriptionToData:fromItem:
-@see appendDescriptionToData:fromParagraphs:
-@see appendDescriptionToData:fromParagraph:
+@see appendDescriptionToData:fromDescription:
*/
- (void) appendBriefDescriptionToData:(NSMutableData*) data
fromItem:(id) item;
@@ -151,27 +150,11 @@ of the given data.
@param item The description item which detailed subcsection to append.
@exception NSException Thrown if appending fails.
@see appendBriefDescriptionToData:fromItem:
-@see appendDescriptionToData:fromParagraphs:
-@see appendDescriptionToData:fromParagraph:
+@see appendDescriptionToData:fromDescription:
*/
- (void) appendDetailedDescriptionToData:(NSMutableData*) data
fromItem:(id) item;
-/** converts the description data from the given paragraphs to proper XHTML format and
-appends it to the given data.
-
-This method is useful for items which contents should be treated as standard descriptions.
-
-@param data The array of paragraphs to append.
-@param paragraphs The array of paragraphs to convert and append. If @c nil nothing will happen.
-@exception NSException Thrown if conversion fails.
-@see appendBriefDescriptionToData:fromItem:
-@see appendDetailedDescriptionToData:fromItem:
-@see appendDescriptionToData:fromParagraph:
-*/
-- (void) appendDescriptionToData:(NSMutableData*) data
- fromParagraphs:(NSArray*) paragraphs;
-
/** Converts the description data from the given paragraph to proper XHTML format and
appends it to the given data.
@@ -184,10 +167,9 @@ data XML structure is exposed to the class.
@exception NSException Thrown if convertion fails.
@see appendBriefDescriptionToData:fromItem:
@see appendDetailedDescriptionToData:fromItem:
-@see appendDescriptionToData:fromParagraphs:
*/
- (void) appendDescriptionToData:(NSMutableData*) data
- fromParagraph:(id) item;
+ fromDescription:(id) item;
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Helper methods
View
@@ -397,8 +397,11 @@ - (void) appendObjectMemberSectionToData:(NSMutableData*) data
[self appendString:@" <dd>" toData:data];
id descriptionItem = [self extractObjectParameterDescriptionNode:parameterItem];
- NSArray* paragraphs = [self extractParagraphsFromItem:descriptionItem];
- [self appendDescriptionToData:data fromParagraphs:paragraphs];
+ NSArray* descriptions = [self extractDescriptionsFromItem:descriptionItem];
+ for (id description in descriptions)
+ {
+ [self appendDescriptionToData:data fromDescription:description];
+ }
[self appendLine:@"</dd>" toData:data];
}
[self appendLine:@" </dl>" toData:data];
@@ -413,8 +416,11 @@ - (void) appendObjectMemberReturnToData:(NSMutableData*) data
if (returnItem)
{
[self appendLine:@" <h5>Return value</h5>" toData:data];
- NSArray* paragraphs = [self extractParagraphsFromItem:returnItem];
- [self appendDescriptionToData:data fromParagraphs:paragraphs];
+ NSArray* descriptions = [self extractDescriptionsFromItem:returnItem];
+ for (id description in descriptions)
+ {
+ [self appendDescriptionToData:data fromDescription:description];
+ }
}
}
@@ -425,7 +431,7 @@ - (void) appendObjectMemberDiscussionToData:(NSMutableData*) data
id descriptionItem = [self extractObjectMemberDescriptionItem:item];
if (descriptionItem)
{
- NSArray* paragraphs = [self extractDetailParagraphsFromItem:descriptionItem];
+ NSArray* paragraphs = [self extractDetailDescriptionsFromItem:descriptionItem];
if (paragraphs && [self isDescriptionUsed:paragraphs])
{
[self appendLine:@" <h5>Discussion</h5>" toData:data];
@@ -448,8 +454,11 @@ - (void) appendObjectMemberWarningToData:(NSMutableData*) data
[self appendLine:@" <h5>Warning</h5>" toData:data];
// Append the actual text.
- NSArray* paragraphs = [self extractParagraphsFromItem:warningItem];
- [self appendDescriptionToData:data fromParagraphs:paragraphs];
+ NSArray* descriptions = [self extractDescriptionsFromItem:warningItem];
+ for (id description in descriptions)
+ {
+ [self appendDescriptionToData:data fromDescription:description];
+ }
// Append footer if bordered appearance is desired.
if (cmd.xhtmlUseBorderedWarnings)
@@ -471,8 +480,11 @@ - (void) appendObjectMemberBugToData:(NSMutableData*) data
[self appendLine:@" <h5>Bug</h5>" toData:data];
// Append the actual text.
- NSArray* paragraphs = [self extractParagraphsFromItem:bugItem];
- [self appendDescriptionToData:data fromParagraphs:paragraphs];
+ NSArray* descriptions = [self extractDescriptionsFromItem:bugItem];
+ for (id description in descriptions)
+ {
+ [self appendDescriptionToData:data fromDescription:description];
+ }
// Append footer if bordered appearance is desired.
if (cmd.xhtmlUseBorderedWarnings)
@@ -492,7 +504,7 @@ - (void) appendObjectMemberSeeAlsoToData:(NSMutableData*) data
for (id item in items)
{
[self appendString:@" <li><code>" toData:data];
- [self appendDescriptionToData:data fromParagraph:item];
+ [self appendDescriptionToData:data fromDescription:item];
[self appendLine:@"</code></li>" toData:data];
}
[self appendLine:@" </ul>" toData:data];
@@ -739,63 +751,94 @@ - (void) appendHierarchyGroupItemToData:(NSMutableData*) data
- (void) appendBriefDescriptionToData:(NSMutableData*) data
fromItem:(id) item
{
- NSArray* paragraphs = [self extractBriefParagraphsFromItem:item];
- [self appendDescriptionToData:data fromParagraphs:paragraphs];
+ NSArray* descriptions = [self extractBriefDescriptionsFromItem:item];
+ for (id description in descriptions)
+ {
+ [self appendDescriptionToData:data fromDescription:description];
+ }
}
//----------------------------------------------------------------------------------------
- (void) appendDetailedDescriptionToData:(NSMutableData*) data
fromItem:(id) item
{
- NSArray* paragraphs = [self extractDetailParagraphsFromItem:item];
- [self appendDescriptionToData:data fromParagraphs:paragraphs];
-}
-
-//----------------------------------------------------------------------------------------
-- (void) appendDescriptionToData:(NSMutableData*) data
- fromParagraphs:(NSArray*) paragraphs
-{
- if (paragraphs)
+ NSArray* descriptions = [self extractDetailDescriptionsFromItem:item];
+ for (id description in descriptions)
{
- for (id paragraph in paragraphs)
- {
- [self appendDescriptionToData:data fromParagraph:paragraph];
- }
+ [self appendDescriptionToData:data fromDescription:description];
}
}
-
//----------------------------------------------------------------------------------------
- (void) appendDescriptionToData:(NSMutableData*) data
- fromParagraph:(id) item
+ fromDescription:(id) item
{
- if (item)
+ int type = [self extractDescriptionType:item];
+ switch (type)
{
- NSString* result = [self extractParagraphText:item];
-
- // Handle simple tags replacements.
- result = [result stringByReplacingOccurrencesOfString:@"<para>" withString:@"<p>"];
- result = [result stringByReplacingOccurrencesOfString:@"</para>" withString:@"</p>"];
- result = [result stringByReplacingOccurrencesOfString:@"<ref id" withString:@"<a href"];
- result = [result stringByReplacingOccurrencesOfString:@"</ref>" withString:@"</a>"];
- result = [result stringByReplacingOccurrencesOfString:@"<list>" withString:@"<ul>"];
- result = [result stringByReplacingOccurrencesOfString:@"</list>" withString:@"</ul>"];
- result = [result stringByReplacingOccurrencesOfString:@"<item>" withString:@"<li>"];
- result = [result stringByReplacingOccurrencesOfString:@"</item>" withString:@"</li>"];
-
- // Handle replacements with spans.
- result = [result stringByReplacingOccurrencesOfString:@"<bold>" withString:@"<span class=\"emphasize\">"];
- result = [result stringByReplacingOccurrencesOfString:@"</bold>" withString:@"</span>"];
-
- // Handle the example section.
- NSString* exampleTag = [NSString stringWithFormat:@"<div%@><pre>",
- cmd.xhtmlUseBorderedExamples ?
- @" class=\"example\"" :
- @""];
- result = [result stringByReplacingOccurrencesOfString:@"<example>" withString:exampleTag];
- result = [result stringByReplacingOccurrencesOfString:@"</example>" withString:@"</pre></div>"];
-
- [self appendLine:result toData:data];
+ case kTKDescriptionParagraphStart:
+ [self appendString:@"<p>" toData:data];
+ break;
+ case kTKDescriptionParagraphEnd:
+ [self appendLine:@"</p>" toData:data];
+ break;
+
+ case kTKDescriptionCodeStart:
+ [self appendString:@"<code>" toData:data];
+ break;
+ case kTKDescriptionCodeEnd:
+ [self appendString:@"</code>" toData:data];
+ break;
+
+ case kTKDescriptionListStart:
+ [self appendLine:@"<ul>" toData:data];
+ break;
+ case kTKDescriptionListEnd:
+ [self appendLine:@"</ul>" toData:data];
+ break;
+ case kTKDescriptionListItemStart:
+ [self appendString:@"<li>" toData:data];
+ break;
+ case kTKDescriptionListItemEnd:
+ [self appendLine:@"</li>" toData:data];
+ break;
+
+ case kTKDescriptionStrongStart:
+ [self appendString:@"<span class=\"strong\">" toData:data];
+ break;
+ case kTKDescriptionStrongEnd:
+ [self appendString:@"</span>" toData:data];
+ break;
+
+ case kTKDescriptionEmphasisStart:
+ [self appendString:@"<span class=\"emphasize\">" toData:data];
+ break;
+ case kTKDescriptionEmphasisEnd:
+ [self appendString:@"</span>" toData:data];
+ break;
+
+ case kTKDescriptionExampleStart:
+ if (cmd.xhtmlUseBorderedExamples)
+ [self appendString:@"<div class=\"example\"><pre>" toData:data];
+ else
+ [self appendString:@"<div><pre>" toData:data];
+ break;
+ case kTKDescriptionExampleEnd:
+ [self appendLine:@"</pre></div>" toData:data];
+ break;
+
+ case kTKDescriptionReferenceStart:
+ [self appendString:@"<a href=\"" toData:data];
+ [self appendString:[self extractDescriptionReference:item] toData:data];
+ [self appendString:@"\">" toData:data];
+ break;
+ case kTKDescriptionReferenceEnd:
+ [self appendString:@"</a>" toData:data];
+ break;
+
+ case kTKDescriptionText:
+ [self appendString:[self extractDescriptionText:item] toData:data];
+ break;
}
}
Oops, something went wrong.

0 comments on commit 26c268f

Please sign in to comment.