Skip to content

Commit 5bb038a

Browse files
committed
Merge pull request onevcat#67 from onevcat/adison-master
Adison master
2 parents 3d1b611 + 4d3064d commit 5bb038a

5 files changed

Lines changed: 641 additions & 41 deletions

File tree

VVDocumenter-Xcode/Commenter/VVBaseCommenter.m

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,38 @@ -(NSString *) startComment
4545
NSString *descriptionTag =
4646
[[VVDocumenterSetting defaultSetting] briefDescription] && !self.forSwift ? @"@brief " : @"";
4747

48+
NSString *authorInfo = @"";
49+
50+
if ([[VVDocumenterSetting defaultSetting] useAuthorInformation] && !self.forSwift) {
51+
NSMutableString *authorCotent = @"".mutableCopy;
52+
53+
if ([[VVDocumenterSetting defaultSetting] authorInformation].length > 0) {
54+
[authorCotent appendString:[[VVDocumenterSetting defaultSetting] authorInformation]];
55+
}
56+
57+
if ([[VVDocumenterSetting defaultSetting] useDateInformation]) {
58+
NSString *formatString = [[VVDocumenterSetting defaultSetting] dateInformationFormat];
59+
if ([formatString length] <= 0) {
60+
formatString = @"MM-dd-YYYY HH:MM:ss";
61+
}
62+
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
63+
[formatter setDateFormat:formatString];
64+
65+
if (authorCotent.length > 0) {
66+
[authorCotent appendString:@", "];
67+
}
68+
[authorCotent appendString:[formatter stringFromDate:[NSDate date]]];
69+
}
70+
71+
authorInfo = [NSString stringWithFormat:@"%@@Author %@\n%@\n", self.prefixString, authorCotent, self.prefixString];
72+
}
73+
4874
if ([[VVDocumenterSetting defaultSetting] useHeaderDoc]) {
49-
return [NSString stringWithFormat:@"%@/*!\n%@%@<#Description#>\n", self.indent, self.prefixString, descriptionTag];
75+
return [NSString stringWithFormat:@"%@/*!\n%@%@%@<#Description#>\n", self.indent, authorInfo, self.prefixString, descriptionTag];
5076
} else if ([[VVDocumenterSetting defaultSetting] prefixWithSlashes]) {
51-
return [NSString stringWithFormat:@"%@%@<#Description#>\n", self.prefixString, descriptionTag];
77+
return [NSString stringWithFormat:@"%@%@%@<#Description#>\n", self.prefixString, authorInfo, descriptionTag];
5278
} else {
53-
return [NSString stringWithFormat:@"%@/**\n%@%@<#Description#>\n", self.indent, self.prefixString, descriptionTag];
79+
return [NSString stringWithFormat:@"%@/**\n%@%@%@<#Description#>\n", self.indent, authorInfo, self.prefixString, descriptionTag];
5480
}
5581
}
5682

VVDocumenter-Xcode/Setting/VVDSettingPanelWindowController.m

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ @interface VVDSettingPanelWindowController ()<NSTextFieldDelegate>
2626
@property (weak) IBOutlet NSButton *btnUseHeaderDoc;
2727
@property (weak) IBOutlet NSButton *btnBlankLinesBetweenSections;
2828
@property (weak) IBOutlet NSButton *btnAlightArgumentComments;
29+
@property (weak) IBOutlet NSButton *btnUseAuthorInformation;
30+
@property (weak) IBOutlet NSButton *btnUseDateInformation;
31+
@property (weak) IBOutlet NSTextField *tfAuthoInformation;
32+
@property (weak) IBOutlet NSTextField *tfDateInformaitonFormat;
33+
2934
@end
3035

3136
@implementation VVDSettingPanelWindowController
@@ -53,7 +58,11 @@ - (void)windowDidLoad
5358
self.btnUseHeaderDoc.state = (NSCellStateValue)[[VVDocumenterSetting defaultSetting] useHeaderDoc];
5459
self.btnBlankLinesBetweenSections.state = (NSCellStateValue)[[VVDocumenterSetting defaultSetting] blankLinesBetweenSections];
5560
self.btnAlightArgumentComments.state = (NSCellStateValue)[[VVDocumenterSetting defaultSetting] alignArgumentComments];
56-
61+
self.btnUseAuthorInformation.state = (NSCellStateValue)[[VVDocumenterSetting defaultSetting] useAuthorInformation];
62+
self.tfAuthoInformation.stringValue = [[VVDocumenterSetting defaultSetting] authorInformation];
63+
self.btnUseDateInformation.state = (NSCellStateValue)[[VVDocumenterSetting defaultSetting] useDateInformation];
64+
self.tfDateInformaitonFormat.stringValue = [[VVDocumenterSetting defaultSetting] dateInformationFormat];
65+
5766
if ([[VVDocumenterSetting defaultSetting] prefixWithStar]) {
5867
[self.mtxPrefixOptions selectCell:self.btnPrefixWithStar];
5968
} else if ([[VVDocumenterSetting defaultSetting] prefixWithSlashes]) {
@@ -71,6 +80,8 @@ - (void)windowDidLoad
7180
[self syncSpaceCount];
7281

7382
self.tfTrigger.delegate = self;
83+
self.tfDateInformaitonFormat.delegate = self;
84+
self.tfAuthoInformation.delegate = self;
7485
}
7586

7687
- (IBAction)stepperPressed:(id)sender {
@@ -89,7 +100,11 @@ - (IBAction)btnResetPressed:(id)sender {
89100
[[VVDocumenterSetting defaultSetting] setUseHeaderDoc:NO];
90101
[[VVDocumenterSetting defaultSetting] setBlankLinesBetweenSections:YES];
91102
[[VVDocumenterSetting defaultSetting] setAlignArgumentComments:YES];
92-
103+
[[VVDocumenterSetting defaultSetting] setUseAuthorInformation:NO];
104+
[[VVDocumenterSetting defaultSetting] setAuthorInformation:VVDDefaultAuthorString];
105+
[[VVDocumenterSetting defaultSetting] setUseDateInformation:NO];
106+
[[VVDocumenterSetting defaultSetting] setDateInformationFormat:VVDDefaultDateInfomationFormat];
107+
93108
self.btnUseSpaces.state = NSOnState;
94109
[self updateUseSpace:self.btnUseSpaces.state];
95110
self.btnPrefixWithWhitespace.state = NSOffState;
@@ -101,7 +116,11 @@ - (IBAction)btnResetPressed:(id)sender {
101116
self.btnUseHeaderDoc.state = NSOffState;
102117
self.btnBlankLinesBetweenSections.state = NSOnState;
103118
self.btnAlightArgumentComments.state = NSOnState;
104-
119+
self.btnUseAuthorInformation.state = NSOffState;
120+
self.tfAuthoInformation.stringValue = VVDDefaultAuthorString;
121+
self.btnUseDateInformation.state = NSOffState;
122+
self.tfDateInformaitonFormat.stringValue = VVDDefaultDateInfomationFormat;
123+
105124
self.btnPrefixWithSlashes.enabled = YES;
106125

107126
[self syncSpaceCount];
@@ -128,6 +147,14 @@ - (IBAction)btnBriefDescriptionPressed:(id)sender {
128147
[[VVDocumenterSetting defaultSetting] setBriefDescription:self.btnBriefDescription.state];
129148
}
130149

150+
- (IBAction)btnUseAuthorInformationPressed:(id)sender {
151+
[[VVDocumenterSetting defaultSetting] setUseAuthorInformation:self.btnUseAuthorInformation.state];
152+
}
153+
154+
- (IBAction)btnUseDateInformationPressed:(id)sender {
155+
[[VVDocumenterSetting defaultSetting] setUseDateInformation:self.btnUseDateInformation.state];
156+
}
157+
131158
-(void) syncSpaceCount
132159
{
133160
NSInteger spaceCount = [[VVDocumenterSetting defaultSetting] spaceCount];
@@ -147,6 +174,12 @@ - (void)controlTextDidChange:(NSNotification *)notification
147174
if([notification object] == self.tfTrigger) {
148175
[[VVDocumenterSetting defaultSetting] setTriggerString:self.tfTrigger.stringValue];
149176
}
177+
if([notification object] == self.tfAuthoInformation) {
178+
[[VVDocumenterSetting defaultSetting] setAuthorInformation:self.tfAuthoInformation.stringValue];
179+
}
180+
if([notification object] == self.tfDateInformaitonFormat) {
181+
[[VVDocumenterSetting defaultSetting] setDateInformationFormat:self.tfDateInformaitonFormat.stringValue];
182+
}
150183
}
151184

152185
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor

0 commit comments

Comments
 (0)