Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ability to parse @deprecated block

@deprecated content will be added to the abstract block as "(<b class="deprecated">Deprecated:</b><span class="deprecated"> deprecated message here</span>)"

Signed-off-by: Bilge Taylan Ulusoy <bilge.ulusoy@me.com>
  • Loading branch information...
commit a81fdb653380e49b4bd3a53c32fdfc67cacfaeee 1 parent 8cc62e1
Bilge Taylan Ulusoy bulusoy authored
3  Application/GBCommentComponentsProvider.h
View
@@ -51,6 +51,9 @@
/** Returns the regex used for matching bug section with capture 1 containing directive and capture 2 description text. */
@property (readonly) NSString *bugSectionRegex;
+/** Returns the regex used for matching deprecated section with capture 1 containing directive and capture 2 description text. */
+@property (readonly) NSString *deprecatedSectionRegex;
+
/** Returns the regex used for matching note section with capture 1 containing directive and capture 2 description text. */
@property (readonly) NSString *noteSectionRegex;
4 Application/GBCommentComponentsProvider.m
View
@@ -64,6 +64,10 @@ - (NSString *)bugSectionRegex {
GBRETURN_ON_DEMAND([self descriptionCaptureRegexForKeyword:@"bug"]);
}
+- (NSString *)deprecatedSectionRegex {
+ GBRETURN_ON_DEMAND([self descriptionCaptureRegexForKeyword:@"deprecated"]);
+}
+
#pragma mark Method specific detection
- (NSString *)methodGroupRegex {
21 Processing/GBCommentsProcessor.m
View
@@ -65,6 +65,7 @@ - (BOOL)findCommentBlockInLines:(NSArray *)lines blockRange:(NSRange *)blockRang
- (BOOL)processWarningBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange;
- (BOOL)processBugBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange;
+- (BOOL)processDeprecatedBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange;
- (BOOL)processParamBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange;
- (BOOL)processExceptionBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange;
- (BOOL)processReturnBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange;
@@ -205,6 +206,7 @@ - (void)processCommentBlockInLines:(NSArray *)lines blockRange:(NSRange)blockRan
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;
+ if ([self processDeprecatedBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
if ([self processParamBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
if ([self processExceptionBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
if ([self processReturnBlockInString:string lines:lines blockRange:blockRange shortRange:shortRange]) return;
@@ -311,6 +313,24 @@ - (BOOL)processWarningBlockInString:(NSString *)string lines:(NSArray *)lines bl
return YES;
}
+- (BOOL)processDeprecatedBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange {
+ NSArray *components = [string captureComponentsMatchedByRegex:self.components.deprecatedSectionRegex];
+ if ([components count] == 0) return NO;
+
+ // Get data from captures. Index 1 is directive, index 2 description text.
+ NSString *directive = [components objectAtIndex:1];
+ NSString *description = [components objectAtIndex:2];
+ GBLogDebug(@"- Registering DEPRECATED block %@ at %@...", [description normalizedDescription], self.currentSourceInfo);
+ [self registerShortDescriptionFromLines:lines range:shortRange removePrefix:directive];
+
+ // Convert to markdown and register everything. We always use the whole text for directive.
+ GBCommentComponent *component = [self commentComponentByPreprocessingString:description withFlags:0];
+ component.stringValue = [self.currentComment.shortDescription.stringValue stringByAppendingFormat:@" (%@)", string];
+ component.markdownValue = [self.currentComment.shortDescription.markdownValue stringByAppendingFormat:@" (<b class=\"deprecated\">Deprecated:</b><span class=\"deprecated\"> %@</span>)", description];
+ self.currentComment.shortDescription = component;
+ return YES;
+}
+
- (BOOL)processBugBlockInString:(NSString *)string lines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange {
NSArray *components = [string captureComponentsMatchedByRegex:self.components.bugSectionRegex];
if ([components count] == 0) return NO;
@@ -527,6 +547,7 @@ - (BOOL)isLineMatchingDirectiveStatement:(NSString *)string {
if ([string isMatchedByRegex:self.components.noteSectionRegex]) return YES;
if ([string isMatchedByRegex:self.components.warningSectionRegex]) return YES;
if ([string isMatchedByRegex:self.components.bugSectionRegex]) return YES;
+ if ([string isMatchedByRegex:self.components.deprecatedSectionRegex]) return YES;
if ([string isMatchedByRegex:self.components.parameterDescriptionRegex]) return YES;
if ([string isMatchedByRegex:self.components.exceptionDescriptionRegex]) return YES;
if ([string isMatchedByRegex:self.components.returnDescriptionRegex]) return YES;
Please sign in to comment.
Something went wrong with that request. Please try again.