Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Parse @discussion @brief @abstract @details #269

Merged
merged 1 commit into from

2 participants

@bulusoy

Ability to parse The following HeaderDoc Tags: @discussion @abstract @brief @details.
Note: These are for Method Comments ONLY!
I'm working for more :)

@bulusoy bulusoy Ability to parse @discussion @abstract @brief @details
Signed-off-by: Bilge Taylan Ulusoy <bilge.ulusoy@me.com>
3f0d4c7
@tomaz tomaz merged commit ce32040 into tomaz:master
@tomaz
Owner

Just merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 30, 2012
  1. @bulusoy

    Ability to parse @discussion @abstract @brief @details

    bulusoy authored
    Signed-off-by: Bilge Taylan Ulusoy <bilge.ulusoy@me.com>
This page is out of date. Refresh to see the latest.
View
3  Application/GBCommentComponentsProvider.h
@@ -77,6 +77,9 @@
/** Returns the regex used for matching cross reference directive with capture 1 containing directive, capture 2 description text. */
@property (readonly) NSString *availabilityRegex;
+@property (readonly) NSString *abstractRegex;
+@property (readonly) NSString *discussionRegex;
+
///---------------------------------------------------------------------------------------
/// @name Markdown specific definitions
///---------------------------------------------------------------------------------------
View
8 Application/GBCommentComponentsProvider.m
@@ -44,6 +44,14 @@ - (id)init {
#pragma mark Sections detection
+- (NSString *)abstractRegex {
+ GBRETURN_ON_DEMAND([self descriptionCaptureRegexForKeyword:@"(abstract|brief)"]);
+}
+
+- (NSString *)discussionRegex {
+ GBRETURN_ON_DEMAND([self descriptionCaptureRegexForKeyword:@"(discussion|details)"]);
+}
+
- (NSString *)noteSectionRegex {
GBRETURN_ON_DEMAND([self descriptionCaptureRegexForKeyword:@"note"]);
}
View
10 Parsing/GBTokenizer.m
@@ -301,10 +301,10 @@ - (NSString *)lineByPreprocessingHeaderDocDirectives:(NSString *)line {
if (!self.settings.preprocessHeaderDoc) return line;
// Remove the entire line when it contains @method or property or class.
- line = [line stringByReplacingOccurrencesOfRegex:@"(?m:@(protocol|method|property|class).*$)" withString:@""];
+ //line = [line stringByReplacingOccurrencesOfRegex:@"(?m:@(protocol|method|property|class).*$)" withString:@""];
// Remove unsupported headerDoc words.
- line = [line stringByReplacingOccurrencesOfRegex:@"(?m:^\\s*@(discussion|abstract))\\s?" withString:@"\n"];
+ //line = [line stringByReplacingOccurrencesOfRegex:@"(?m:^\\s*@(discussion|abstract))\\s?" withString:@"\n"];
// Replace methodgroup with name.
line = [line stringByReplacingOccurrencesOfRegex:@"(?:@(methodgroup|group))" withString:@"@name"];
@@ -326,11 +326,13 @@ - (NSString *)lineByPreprocessingHeaderDocDirectives:(NSString *)line {
*/
+ line = [line stringByReplacingOccurrencesOfRegex:@"(?m:^\\s*@updated).*$?" withString:@"\n"];
+
// Removes any occurance of @brief and it's surrounding whitespace
- line = [line stringByReplacingOccurrencesOfRegex:@"\\s*@brief\\s*" withString:@""];
+ //line = [line stringByReplacingOccurrencesOfRegex:@"\\s*@brief\\s*" withString:@""];
// Replaces any occurance of @details and it's surrounding whitespace with a newline
- line = [line stringByReplacingOccurrencesOfRegex:@"^\\s*@details\\s*" withString:@"\n"];
+ //line = [line stringByReplacingOccurrencesOfRegex:@"^\\s*@details\\s*" withString:@"\n"];
return line;
}
View
73 Processing/GBCommentsProcessor.m
@@ -200,6 +200,8 @@ - (void)processCommentBlockInLines:(NSArray *)lines blockRange:(NSRange)blockRan
NSArray *block = [lines subarrayWithRange:blockRange];
if ([self isLineMatchingDirectiveStatement:[block firstObject]]) {
NSString *string = [self stringByCombiningTrimmedLines:block];
+ if ([self processDiscussionBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
+ if ([self processAbstractBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
if ([self processNoteBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
if ([self processWarningBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
if ([self processBugBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
@@ -229,8 +231,9 @@ - (void)processCommentBlockInLines:(NSArray *)lines blockRange:(NSRange)blockRan
if ([blockString length] == 0) return;
// Process the string and register long description component.
- GBCommentComponent *component = [self commentComponentByPreprocessingString:blockString withFlags:0];
- [self.currentComment.longDescription registerComponent:component];
+ //GBCommentComponent *component = [self commentComponentByPreprocessingString:blockString withFlags:0];
+
+ //[self.currentComment.longDescription registerComponent:component];
}
- (void)registerShortDescriptionFromLines:(NSArray *)lines range:(NSRange)range removePrefix:(NSString *)remove {
@@ -383,7 +386,7 @@ - (BOOL)processAvailabilityBlockInString:(NSString *)string lines:(NSArray *)lin
if ([components count] == 0) return NO;
// Get data from captures. Index 1 is directive, index 2 description text.
- NSString *description = [components objectAtIndex:2];
+ NSString *description = [components objectAtIndex:3];
NSRange range = [string rangeOfString:description];
NSString *prefix = nil;
if (range.location < [string length]) {
@@ -401,6 +404,68 @@ - (BOOL)processAvailabilityBlockInString:(NSString *)string lines:(NSArray *)lin
return YES;
}
+- (BOOL)processDiscussionBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange {
+ NSArray *components = [string captureComponentsMatchedByRegex:self.components.discussionRegex];
+ if ([components count] == 0) return NO;
+
+ // Get data from captures. Index 1 is directive, index 2 description text.
+ NSString *description = [components objectAtIndex:3];
+ NSRange range = [string rangeOfString:description];
+ NSString *prefix = nil;
+ if (range.location < [string length]) {
+ prefix = [string substringToIndex:range.location];
+ } else {
+ prefix = @"";
+ }
+
+ GBLogDebug(@"- Registering discussion description %@ at %@...", [description normalizedDescription], self.currentSourceInfo);
+ [self reserveShortDescriptionFromLines:lines range:shortRange removePrefix:prefix];
+
+ // Prepare object representation from the description and register the result to the comment.
+ GBCommentComponent *component = [self commentComponentByPreprocessingString:description withFlags:0];
+ [self.currentComment.longDescription registerComponent:component];
+ return YES;
+}
+
+- (BOOL)processAbstractBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange {
+ NSArray *components = [string captureComponentsMatchedByRegex:self.components.abstractRegex];
+ if ([components count] == 0) return NO;
+
+ // Get data from captures. Index 1 is directive, index 2 description text.
+ NSString *description = [components objectAtIndex:3];
+ NSRange index;
+ index = [description rangeOfString:@"@discussion"];
+
+ if (index.location == NSNotFound) {
+ index = [description rangeOfString:@"\s+"];
+ }
+
+ NSRange range;
+ @try {
+ description = [description substringToIndex:index.location];
+ }
+ @catch (NSException *exception) {
+
+ }
+ @finally {
+ range = [string rangeOfString:description];
+ }
+ NSString *prefix = nil;
+ if (range.location < [string length]) {
+ prefix = [string substringToIndex:range.location];
+ } else {
+ prefix = @"";
+ }
+
+ GBLogDebug(@"- Registering abstract description %@ at %@...", [description normalizedDescription], self.currentSourceInfo);
+ [self reserveShortDescriptionFromLines:lines range:shortRange removePrefix:prefix];
+
+ // Prepare object representation from the description and register the result to the comment.
+ GBCommentComponent *component = [self commentComponentByPreprocessingString:description withFlags:0];
+ self.currentComment.shortDescription = component;
+ return YES;
+}
+
- (BOOL)processReturnBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange {
NSArray *components = [string captureComponentsMatchedByRegex:self.components.returnDescriptionRegex];
if ([components count] == 0) return NO;
@@ -457,6 +522,8 @@ - (BOOL)processRelatedBlockInString:(NSString *)string lines:(NSArray *)lines bl
}
- (BOOL)isLineMatchingDirectiveStatement:(NSString *)string {
+ if ([string isMatchedByRegex:self.components.discussionRegex]) return YES;
+ if ([string isMatchedByRegex:self.components.abstractRegex]) return YES;
if ([string isMatchedByRegex:self.components.noteSectionRegex]) return YES;
if ([string isMatchedByRegex:self.components.warningSectionRegex]) return YES;
if ([string isMatchedByRegex:self.components.bugSectionRegex]) return YES;
Something went wrong with that request. Please try again.