diff --git a/VVDocumenter-Xcode/Commenter/VVBaseCommenter.h b/VVDocumenter-Xcode/Commenter/VVBaseCommenter.h index e50f183..4cc5b78 100755 --- a/VVDocumenter-Xcode/Commenter/VVBaseCommenter.h +++ b/VVDocumenter-Xcode/Commenter/VVBaseCommenter.h @@ -14,6 +14,9 @@ @property (nonatomic, copy) NSString *code; @property (nonatomic, strong) NSMutableArray *arguments; @property (nonatomic, assign) BOOL hasReturn; +@property (nonatomic, copy) NSString* briefCommentStart; +@property (nonatomic, copy) NSString* detailedCommentStart; +@property (nonatomic, copy) NSString* structurePrefix ; -(id) initWithIndentString:(NSString *)indent codeString:(NSString *)code; -(NSString *) document; diff --git a/VVDocumenter-Xcode/Commenter/VVBaseCommenter.m b/VVDocumenter-Xcode/Commenter/VVBaseCommenter.m index 0eec7e4..0a95e81 100755 --- a/VVDocumenter-Xcode/Commenter/VVBaseCommenter.m +++ b/VVDocumenter-Xcode/Commenter/VVBaseCommenter.m @@ -24,10 +24,18 @@ -(id) initWithIndentString:(NSString *)indent codeString:(NSString *)code self.code = code; self.arguments = [NSMutableArray array]; self.space = [[VVDocumenterSetting defaultSetting] spacesString]; + VVDDoxygenStyle style = [[VVDocumenterSetting defaultSetting] doxygenStyle]; + self.briefCommentStart = (style == DOXYGEN_STYLE_QT) ? @"//!" : @"///" ; + self.detailedCommentStart = (style == DOXYGEN_STYLE_QT) ? @"/*!\n" : @"/**\n"; + self.structurePrefix = (style == DOXYGEN_STYLE_QT) ? @"\\" : @"@"; } return self; } +-(NSString*) briefComment +{ + return [ NSString stringWithFormat:@"%@%@ <#Brief Description#>.\n",self.indent, self.briefCommentStart ]; +} -(NSString *) startComment { if ([[VVDocumenterSetting defaultSetting] useHeaderDoc]) { @@ -35,7 +43,7 @@ -(NSString *) startComment } else if ([[VVDocumenterSetting defaultSetting] prefixWithSlashes]) { return [NSString stringWithFormat:@"%@<#Description#>\n", self.prefixString]; } else { - return [NSString stringWithFormat:@"%@/**\n%@<#Description#>\n", self.indent, self.prefixString]; + return [NSString stringWithFormat:@"%@%@%@<#Description#>\n", self.indent, self.detailedCommentStart, self.prefixString]; } } @@ -52,7 +60,7 @@ -(NSString *) argumentsComment for (VVArgument *arg in self.arguments) { NSString *paddedName = [arg.name stringByPaddingToLength:longestNameLength withString:@" " startingAtIndex:0]; - [result appendFormat:@"%@@param %@ <#%@ description#>\n", self.prefixString, paddedName, arg.name]; + [result appendFormat:@"%@%@param %@ <#%@ description#>\n", self.prefixString, self.structurePrefix, paddedName, arg.name]; } return result; } @@ -62,7 +70,7 @@ -(NSString *) returnComment if (!self.hasReturn) { return @""; } else { - return [NSString stringWithFormat:@"%@%@@return <#return value description#>\n", self.emptyLine, self.prefixString]; + return [NSString stringWithFormat:@"%@%@%@return <#return value description#>\n", self.emptyLine, self.prefixString, self.structurePrefix ]; } } @@ -86,7 +94,9 @@ -(NSString *) endComment -(NSString *) document { - NSString * comment = [NSString stringWithFormat:@"%@%@%@%@%@", + BOOL includeBriefComment = [[VVDocumenterSetting defaultSetting] includeBriefDescription ]; + NSString * comment = [NSString stringWithFormat:@"%@%@%@%@%@%@", + (includeBriefComment ? [ self briefComment ] : @""), [self startComment], [self argumentsComment], [self returnComment], diff --git a/VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.m b/VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.m index 1f8a1ea..a1b5560 100644 --- a/VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.m +++ b/VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.m @@ -23,6 +23,7 @@ @interface VVDSettingPanelWindowController () @property (weak) IBOutlet NSButtonCell *btnPrefixWithSlashes; @property (assign) IBOutlet NSButton *btnAddSinceToComment; @property (weak) IBOutlet NSButton *btnUseHeaderDoc; +@property (readonly) VVDocumenterSetting* defaults; @end @implementation VVDSettingPanelWindowController @@ -80,6 +81,8 @@ - (IBAction)btnResetPressed:(id)sender { [[VVDocumenterSetting defaultSetting] setPrefixWithSlashes:NO]; [[VVDocumenterSetting defaultSetting] setAddSinceToComments:NO]; [[VVDocumenterSetting defaultSetting] setUseHeaderDoc:NO]; + [[VVDocumenterSetting defaultSetting] setIncludeBriefDescription:NO]; + [[VVDocumenterSetting defaultSetting] setDoxygenStyle:DOXYGEN_STYLE_DEFAULT]; self.btnUseSpaces.state = NSOnState; [self updateUseSpace:self.btnUseSpaces.state]; @@ -159,4 +162,9 @@ - (IBAction)useHeaderDoc:(id)sender { self.btnPrefixWithSlashes.enabled = YES; } } + +-(VVDocumenterSetting*)defaults +{ + return [VVDocumenterSetting defaultSetting]; +} @end diff --git a/VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.xib b/VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.xib index 13830b8..fad9645 100644 --- a/VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.xib +++ b/VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.xib @@ -2,13 +2,13 @@ 1080 - 13A603 - 4514 - 1265 - 695.00 + 13C53 + 5037.2 + 1265.19 + 697.40 com.apple.InterfaceBuilder.CocoaPlugin - 4514 + 5037.2 NSBox @@ -16,10 +16,15 @@ NSButtonCell NSCustomObject NSMatrix + NSMenu + NSMenuItem + NSPopUpButton + NSPopUpButtonCell NSStepper NSStepperCell NSTextField NSTextFieldCell + NSUserDefaultsController NSView NSWindowTemplate @@ -43,7 +48,7 @@ 3 2 - {{508, 391}, {460, 343}} + {{508, 391}, {460, 438}} 544735232 VVDocumenter Setting NSWindow @@ -56,7 +61,7 @@ 268 - {{68, 219}, {212, 35}} + {{68, 314}, {212, 35}} @@ -92,7 +97,7 @@ 268 - {{330, 228}, {60, 17}} + {{330, 323}, {60, 17}} @@ -130,7 +135,7 @@ 268 - {{280, 225}, {37, 22}} + {{280, 320}, {37, 22}} @@ -169,6 +174,7 @@ {{14, 13}, {113, 32}} + _NS:9 YES @@ -190,7 +196,7 @@ 268 - {{67, 306}, {107, 17}} + {{67, 401}, {107, 17}} @@ -212,7 +218,7 @@ 268 - {{280, 303}, {96, 22}} + {{280, 398}, {96, 22}} @@ -235,17 +241,17 @@ 268 - {{79, 260}, {295, 38}} + {{79, 355}, {295, 38}} - + _NS:1535 YES 67108864 272629760 VVDocumenter will inspect the input and insert document comment when it matches this. - + LucidaGrande 12 16 @@ -254,7 +260,7 @@ YES - + 6 System controlShadowColor @@ -270,7 +276,7 @@ 268 - {{313, 222}, {19, 27}} + {{313, 317}, {19, 27}} @@ -290,7 +296,7 @@ 268 - {{68, 198}, {201, 18}} + {{68, 293}, {201, 18}} @@ -317,10 +323,10 @@ 268 - {{68, 168}, {272, 18}} + {{68, 263}, {272, 18}} - + _NS:9 YES @@ -547,16 +553,159 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 0 NO + + + 268 + {{68, 203}, {272, 18}} + + + + _NS:9 + YES + + 67108864 + 268435456 + Include 'brief' comment + + _NS:9 + + 1211912448 + 2 + + + + + 200 + 25 + + NO + + + + 268 + {{68, 231}, {56, 16}} + + + + _NS:1535 + YES + + 67108864 + 272629760 + Doxygen + + _NS:1535 + + YES + + + + NO + 1 + + + + 268 + {{165, 170}, {80, 26}} + + + + _NS:9 + YES + + -2076180416 + 2048 + + _NS:9 + + 109199360 + 129 + + + 400 + 75 + + + Default + + 1048576 + 2147483647 + 1 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + _popUpItemAction: + + + YES + + OtherViews + + + + + Qt + + 1048576 + 2147483647 + + + _popUpItemAction: + 1 + + + + + + -1 + 1 + YES + YES + 2 + + NO + + + + 268 + {{68, 175}, {93, 17}} + + + + _NS:397 + {251, 750} + YES + + 68157504 + 272630784 + Doxygen Style + + _NS:397 + + + + + NO + 1 + - {460, 343} + {460, 438} - {{0, 0}, {1920, 1058}} + {{0, 0}, {2560, 1418}} {10000000000000, 10000000000000} YES + + YES + NO @@ -705,6 +854,14 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 lCp-Ch-TTG + + + useHeaderDoc: + + + + yOV-iG-iAX + delegate @@ -713,6 +870,38 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 4 + + + value: defaults.includeBriefDescription + + + + + + value: defaults.includeBriefDescription + value + defaults.includeBriefDescription + 2 + + + 8VE-qm-f5R + + + + selectedTag: defaults.doxygenStyle + + + + + + selectedTag: defaults.doxygenStyle + selectedTag + defaults.doxygenStyle + 2 + + + Yc5-E8-DgR + @@ -764,6 +953,10 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 + + + + @@ -934,12 +1127,92 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 + + 91w-IX-RNO + + + + + + + + aKC-rk-fUa + + + + + bp3-3a-dTB + + + + + + + + 0Im-jz-uz7 + + + + + 6do-tw-OHM + + + + + TMM-vw-rsF + + + + + + + + JRM-Vs-p26 + + + + + + + + 62t-4S-PcC + + + + + + + + + zeb-dl-xqe + + + + + wSN-NU-iaB + + + + + UI5-pW-pTx + + + + + + + + 5P0-op-xug + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -961,17 +1234,28 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -1097,6 +1381,8 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 YES 3 + {11, 11} + {10, 3} {16, 15} {15, 15} diff --git a/VVDocumenter-Xcode/Setting/VVDocumenterSetting.h b/VVDocumenter-Xcode/Setting/VVDocumenterSetting.h index 1ee43dc..bc1fa96 100644 --- a/VVDocumenter-Xcode/Setting/VVDocumenterSetting.h +++ b/VVDocumenter-Xcode/Setting/VVDocumenterSetting.h @@ -10,6 +10,11 @@ extern NSString *const VVDDefaultTriggerString; +typedef NS_ENUM(NSUInteger, VVDDoxygenStyle) { + DOXYGEN_STYLE_DEFAULT + , DOXYGEN_STYLE_QT +}; + @interface VVDocumenterSetting : NSObject + (VVDocumenterSetting *)defaultSetting; @@ -18,6 +23,12 @@ extern NSString *const VVDDefaultTriggerString; -(BOOL) useSpaces; -(void) setUseSpaces:(BOOL)useSpace; +-(VVDDoxygenStyle) doxygenStyle; +-(void) setDoxygenStyle:(VVDDoxygenStyle)doxygenStyle; + +-(BOOL) includeBriefDescription; +-(void) setIncludeBriefDescription:(BOOL)includeBriefDescription; + -(NSInteger) spaceCount; -(void) setSpaceCount:(NSInteger)spaceCount; diff --git a/VVDocumenter-Xcode/Setting/VVDocumenterSetting.m b/VVDocumenter-Xcode/Setting/VVDocumenterSetting.m index 35417c4..23892b3 100644 --- a/VVDocumenter-Xcode/Setting/VVDocumenterSetting.m +++ b/VVDocumenter-Xcode/Setting/VVDocumenterSetting.m @@ -18,6 +18,9 @@ NSString *const kVVDPrefixWithSlashes = @"com.onevcat.VVDocumenter.prefixWithSlashes"; NSString *const kVVDAddSinceToComments = @"com.onevcat.VVDocumenter.addSinceToComments"; NSString *const kVVDUserHeaderDoc = @"com.onevcat.VVDocumenter.useHeaderDoc"; +NSString *const kVVDDoxygenStyle = @"com.onevcat.VVDocumenter.doxygenStyle"; +NSString *const kVVDIncludeBriefDescription = @"com.onevcat.VVDocumenter.includeBriefDescription"; + @implementation VVDocumenterSetting + (VVDocumenterSetting *)defaultSetting @@ -28,7 +31,8 @@ + (VVDocumenterSetting *)defaultSetting defaultSetting = [[VVDocumenterSetting alloc] init]; NSDictionary *defaults = @{kVVDPrefixWithStar: @YES, - kVVDUseSpaces: @YES}; + kVVDUseSpaces: @YES, + kVVDDoxygenStyle: @(DOXYGEN_STYLE_DEFAULT) }; [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; }); return defaultSetting; @@ -45,6 +49,30 @@ -(void) setUseSpaces:(BOOL)useSpace [[NSUserDefaults standardUserDefaults] synchronize]; } + +-(VVDDoxygenStyle) doxygenStyle +{ + return [[NSUserDefaults standardUserDefaults] integerForKey:kVVDDoxygenStyle]; +} + +-(void) setDoxygenStyle:(VVDDoxygenStyle)doxygenStyle +{ + [[NSUserDefaults standardUserDefaults] setInteger:doxygenStyle forKey:kVVDDoxygenStyle ]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + + +-(BOOL) includeBriefDescription +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:kVVDIncludeBriefDescription]; +} + +-(void) setIncludeBriefDescription:(BOOL)includeBriefDescription +{ + [[NSUserDefaults standardUserDefaults] setBool:includeBriefDescription forKey:kVVDIncludeBriefDescription ]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + -(BOOL) useDvorakLayout { TISInputSourceRef inputSource = TISCopyCurrentKeyboardLayoutInputSource(); diff --git a/VVDocumenter-Xcode/VVDocumenter.h b/VVDocumenter-Xcode/VVDocumenter.h index 5b44e82..f003f8f 100644 --- a/VVDocumenter-Xcode/VVDocumenter.h +++ b/VVDocumenter-Xcode/VVDocumenter.h @@ -9,6 +9,13 @@ #import @interface VVDocumenter : NSObject +/** + * <#Description#> + * + * @param code <#code description#> + * + * @return <#return value description#> + */ -(id) initWithCode:(NSString *)code; -(NSString *) baseIndentation; -(NSString *) document;