Permalink
Browse files

Implemented settings for enabling or disabling validation warnings.

  • Loading branch information...
1 parent 14ca270 commit b427cd7e97117e6ed364e5d9b883e342865aebe9 @tomaz committed Dec 13, 2010
@@ -37,6 +37,8 @@
static NSString *kGBArgKeepMergedCategoriesSections = @"keep-merged-sections";
static NSString *kGBArgPrefixMergedCategoriesSectionsWithCategoryName = @"prefix-merged-sections";
+static NSString *kGBArgWarnOnMissingOutputPath = @"warn-missing-output-path";
+static NSString *kGBArgWarnOnMissingCompanyIdentifier = @"warn-missing-company-id";
static NSString *kGBArgWarnOnUndocumentedObject = @"warn-undocumented-object";
static NSString *kGBArgWarnOnUndocumentedMember = @"warn-undocumented-member";
@@ -208,8 +210,12 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
{ GBNoArg(kGBArgKeepMergedCategoriesSections), 0, DDGetoptNoArgument },
{ GBNoArg(kGBArgPrefixMergedCategoriesSectionsWithCategoryName), 0, DDGetoptNoArgument },
+ { kGBArgWarnOnMissingOutputPath, 0, DDGetoptNoArgument },
+ { kGBArgWarnOnMissingCompanyIdentifier, 0, DDGetoptNoArgument },
{ kGBArgWarnOnUndocumentedObject, 0, DDGetoptNoArgument },
{ kGBArgWarnOnUndocumentedMember, 0, DDGetoptNoArgument },
+ { GBNoArg(kGBArgWarnOnMissingOutputPath), 0, DDGetoptNoArgument },
+ { GBNoArg(kGBArgWarnOnMissingCompanyIdentifier), 0, DDGetoptNoArgument },
{ GBNoArg(kGBArgWarnOnUndocumentedObject), 0, DDGetoptNoArgument },
{ GBNoArg(kGBArgWarnOnUndocumentedMember), 0, DDGetoptNoArgument },
@@ -345,7 +351,9 @@ - (void)validateSettingsAndArguments:(NSArray *)arguments {
// If output path is not given, revert to current path, but do warn the user.
if ([self.settings.outputPath length] == 0) {
self.settings.outputPath = [self.fileManager currentDirectoryPath];
- ddprintf(@"WARN: --%@ argument or global setting not given, will output to current dir '%@'!\n", kGBArgOutputPath, self.settings.outputPath);
+ if (self.settings.warnOnMissingOutputPathArgument) {
+ ddprintf(@"WARN: --%@ argument or global setting not given, will output to current dir '%@'!\n", kGBArgOutputPath, self.settings.outputPath);
+ }
}
// If company identifier is not given and we have docset enabled, prepare one from company name, but do warn the user.
@@ -354,7 +362,9 @@ - (void)validateSettingsAndArguments:(NSArray *)arguments {
value = [value stringByReplacingOccurrencesOfString:@" " withString:@""];
value = [value lowercaseString];
self.settings.companyIdentifier = value;
- ddprintf(@"WARN: --%@ argument or global setting not given, but creating DocSet is enabled, will use '%@'!\n", kGBArgCompanyIdentifier, self.settings.companyIdentifier);
+ if (self.settings.warnOnMissingCompanyIdentifier) {
+ ddprintf(@"WARN: --%@ argument or global setting not given, but creating DocSet is enabled, will use '%@'!\n", kGBArgCompanyIdentifier, self.settings.companyIdentifier);
+ }
}
}
@@ -400,8 +410,12 @@ - (void)setNoMergeCategories:(BOOL)value { self.settings.mergeCategoriesToClasse
- (void)setNoKeepMergedSections:(BOOL)value { self.settings.keepMergedCategoriesSections = !value; }
- (void)setNoPrefixMergedSections:(BOOL)value { self.settings.prefixMergedCategoriesSectionsWithCategoryName = !value; }
+- (void)setWarnMissingOutputPath:(BOOL)value { self.settings.warnOnMissingOutputPathArgument = value; }
+- (void)setWarnMissingCompanyId:(BOOL)value { self.settings.warnOnMissingCompanyIdentifier = value; }
- (void)setWarnUndocumentedObject:(BOOL)value { self.settings.warnOnUndocumentedObject = value; }
- (void)setWarnUndocumentedMember:(BOOL)value { self.settings.warnOnUndocumentedMember = value; }
+- (void)setNoWarnMissingOutputPath:(BOOL)value { self.settings.warnOnMissingOutputPathArgument = !value; }
+- (void)setNoWarnMissingCompanyId:(BOOL)value { self.settings.warnOnMissingCompanyIdentifier = !value; }
- (void)setNoWarnUndocumentedObject:(BOOL)value { self.settings.warnOnUndocumentedObject = !value; }
- (void)setNoWarnUndocumentedMember:(BOOL)value { self.settings.warnOnUndocumentedMember = !value; }
@@ -468,6 +482,8 @@ - (void)printHelp {
PRINT_USAGE(@" ", kGBArgPrefixMergedCategoriesSectionsWithCategoryName, @"<bool>", @"Prefix merged sections with category name");
ddprintf(@"\n");
ddprintf(@"WARNINGS\n");
+ PRINT_USAGE(@" ", kGBArgWarnOnMissingOutputPath, @"<bool>", @"Warn if output path is not given");
+ PRINT_USAGE(@" ", kGBArgWarnOnMissingCompanyIdentifier, @"<bool>", @"Warn if company ID is not given");
PRINT_USAGE(@" ", kGBArgWarnOnUndocumentedObject, @"<bool>", @"Warn on undocumented object");
PRINT_USAGE(@" ", kGBArgWarnOnUndocumentedMember, @"<bool>", @"Warn on undocumented member");
ddprintf(@"\n");
@@ -25,7 +25,6 @@
*/
+ (id)provider;
-
///---------------------------------------------------------------------------------------
/// @name Project values handling
///---------------------------------------------------------------------------------------
@@ -216,6 +215,22 @@
/// @name Warnings handling
///---------------------------------------------------------------------------------------
+/** Indicates whether appledoc will warn if `--output` argument is not given.
+
+ Although appledoc still generates output in current directory, it's better to warn the user as in most cases this is not what she wants (for example if appledoc is invoked from Xcode build script, current working directory might point to some unpredicted location). appledoc also writes the exact path that will be used for generating output.
+
+ Note that in case documentation set is installed to Xcode, setting output path is irrelevant as all files from output are moved to locations Xcode uses for finding documentation sets.
+ */
+@property (assign) BOOL warnOnMissingOutputPathArgument;
+
+/** Indicates whether appledoc will warn if `--company-id` argument is not given.
+
+ Although appledoc deducts this information from other values, it's better to warn the user as deducted information doesn't necessarily produce correct results.
+
+ Note that the warning is only issued if documentation set creation is requested.
+ */
+@property (assign) BOOL warnOnMissingCompanyIdentifier;
+
/** Indicates whether appledoc will warn if it encounters an undocumented class, category or protocol.
@see warnOnUndocumentedMember
@@ -61,6 +61,8 @@ - (id)init {
self.keepMergedCategoriesSections = NO;
self.prefixMergedCategoriesSectionsWithCategoryName = NO;
+ self.warnOnMissingOutputPathArgument = YES;
+ self.warnOnMissingCompanyIdentifier = YES;
self.warnOnUndocumentedObject = YES;
self.warnOnUndocumentedMember = YES;
@@ -321,6 +323,8 @@ - (NSString *)description {
@synthesize createDocSet;
@synthesize installDocSet;
+@synthesize warnOnMissingOutputPathArgument;
+@synthesize warnOnMissingCompanyIdentifier;
@synthesize warnOnUndocumentedObject;
@synthesize warnOnUndocumentedMember;
@@ -182,6 +182,24 @@ - (void)testPrefixMergedCategoriesSectionsWithCategoryName_shouldAssignValueToSe
#pragma mark Warnings settings testing
+- (void)testWarnOnMissingOutputPath_shouldAssignValueToSettings {
+ // setup & execute
+ GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--warn-missing-output-path", nil];
+ GBApplicationSettingsProvider *settings2 = [self settingsByRunningWithArgs:@"--no-warn-missing-output-path", nil];
+ // verify
+ assertThatBool(settings1.warnOnMissingOutputPathArgument, equalToBool(YES));
+ assertThatBool(settings2.warnOnMissingOutputPathArgument, equalToBool(NO));
+}
+
+- (void)testWarnOnMissingCompanyIdentifier_shouldAssignValueToSettings {
+ // setup & execute
+ GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--warn-missing-company-id", nil];
+ GBApplicationSettingsProvider *settings2 = [self settingsByRunningWithArgs:@"--no-warn-missing-company-id", nil];
+ // verify
+ assertThatBool(settings1.warnOnMissingCompanyIdentifier, equalToBool(YES));
+ assertThatBool(settings2.warnOnMissingCompanyIdentifier, equalToBool(NO));
+}
+
- (void)testWarnOnUndocumentedObject_shouldAssignValueToSettings {
// setup & execute
GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--warn-undocumented-object", nil];
@@ -200,7 +218,7 @@ - (void)testWarnOnUndocumentedMember_shouldAssignValueToSettings {
assertThatBool(settings2.warnOnUndocumentedMember, equalToBool(NO));
}
-#pragma Documentation set settings testing
+#pragma mark Documentation set settings testing
- (void)testDocSetBudnleIdentifier_shouldAssignValueToSettings {
// setup & execute

0 comments on commit b427cd7

Please sign in to comment.