Skip to content

Commit

Permalink
Refactored template placeholder strings by moving them to global cons…
Browse files Browse the repository at this point in the history
…tants.
  • Loading branch information
tomaz committed Jan 17, 2011
1 parent 7d47416 commit 1f23b3e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 32 deletions.
22 changes: 11 additions & 11 deletions Application/GBAppledocApplication.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -663,17 +663,17 @@ - (void)printHelp {
ddprintf(@"[b] boolean parameter, uses no value, use --no- prefix to negate.\n"); ddprintf(@"[b] boolean parameter, uses no value, use --no- prefix to negate.\n");
ddprintf(@"\n"); ddprintf(@"\n");
ddprintf(@"[*] indicates parameters accepting placeholder strings:\n"); ddprintf(@"[*] indicates parameters accepting placeholder strings:\n");
ddprintf(@"- %%PROJECT replaced with --project-name\n"); ddprintf(@"- %@ replaced with --project-name\n", kGBTemplatePlaceholderProject);
ddprintf(@"- %%PROJECTID replaced with normalized --project-name\n"); ddprintf(@"- %@ replaced with normalized --project-name\n", kGBTemplatePlaceholderProjectID);
ddprintf(@"- %%VERSION replaced with --project-version\n"); ddprintf(@"- %@ replaced with --project-version\n", kGBTemplatePlaceholderVersion);
ddprintf(@"- %%VERSIONID replaced with normalized --project-version\n"); ddprintf(@"- %@ replaced with normalized --project-version\n", kGBTemplatePlaceholderVersionID);
ddprintf(@"- %%COMPANY replaced with --project-company\n"); ddprintf(@"- %@ replaced with --project-company\n", kGBTemplatePlaceholderCompany);
ddprintf(@"- %%COMPANYID replaced with --company-id\n"); ddprintf(@"- %@ replaced with --company-id\n", kGBTemplatePlaceholderCompanyID);
ddprintf(@"- %%YEAR replaced with current year (format yyyy)\n"); ddprintf(@"- %@ replaced with current year (format yyyy)\n", kGBTemplatePlaceholderYear);
ddprintf(@"- %%UPDATEDATE replaced with current date (format yyyy-MM-dd)\n"); ddprintf(@"- %@ replaced with current date (format yyyy-MM-dd)\n", kGBTemplatePlaceholderUpdateDate);
ddprintf(@"- %%DOCSETBUNDLEFILENAME replaced with --docset-bundle-filename\n"); ddprintf(@"- %@ replaced with --docset-bundle-filename\n", kGBTemplatePlaceholderDocSetBundleFilename);
ddprintf(@"- %%DOCSETATOMFILENAME replaced with --docset-atom-filename\n"); ddprintf(@"- %@ replaced with --docset-atom-filename\n", kGBTemplatePlaceholderDocSetAtomFilename);
ddprintf(@"- %%DOCSETPACKAGEFILENAME replaced with --docset-package-filename\n"); ddprintf(@"- %@ replaced with --docset-package-filename\n", kGBTemplatePlaceholderDocSetPackageFilename);
ddprintf(@"\n"); ddprintf(@"\n");
ddprintf(@"==================================================================\n"); ddprintf(@"==================================================================\n");
ddprintf(@"Find more help and tips online:\n"); ddprintf(@"Find more help and tips online:\n");
Expand Down
14 changes: 14 additions & 0 deletions Application/GBApplicationSettingsProvider.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -408,3 +408,17 @@
@property (retain) GBApplicationStringsProvider *stringTemplates; @property (retain) GBApplicationStringsProvider *stringTemplates;


@end @end

#pragma -

extern NSString *kGBTemplatePlaceholderCompanyID;
extern NSString *kGBTemplatePlaceholderProjectID;
extern NSString *kGBTemplatePlaceholderVersionID;
extern NSString *kGBTemplatePlaceholderProject;
extern NSString *kGBTemplatePlaceholderCompany;
extern NSString *kGBTemplatePlaceholderVersion;
extern NSString *kGBTemplatePlaceholderDocSetBundleFilename;
extern NSString *kGBTemplatePlaceholderDocSetAtomFilename;
extern NSString *kGBTemplatePlaceholderDocSetPackageFilename;
extern NSString *kGBTemplatePlaceholderYear;
extern NSString *kGBTemplatePlaceholderUpdateDate;
52 changes: 33 additions & 19 deletions Application/GBApplicationSettingsProvider.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
#import "GBDataObjects.h" #import "GBDataObjects.h"
#import "GBApplicationSettingsProvider.h" #import "GBApplicationSettingsProvider.h"


NSString *kGBTemplatePlaceholderCompanyID = @"%COMPANYID";
NSString *kGBTemplatePlaceholderProjectID = @"%PROJECTID";
NSString *kGBTemplatePlaceholderVersionID = @"%VERSIONID";
NSString *kGBTemplatePlaceholderProject = @"%PROJECT";
NSString *kGBTemplatePlaceholderCompany = @"%COMPANY";
NSString *kGBTemplatePlaceholderVersion = @"%VERSION";
NSString *kGBTemplatePlaceholderDocSetBundleFilename = @"%DOCSETBUNDLEFILENAME";
NSString *kGBTemplatePlaceholderDocSetAtomFilename = @"%DOCSETATOMFILENAME";
NSString *kGBTemplatePlaceholderDocSetPackageFilename = @"%DOCSETPACKAGEFILENAME";
NSString *kGBTemplatePlaceholderYear = @"%YEAR";
NSString *kGBTemplatePlaceholderUpdateDate = @"%UPDATEDATE";

#pragma mark -

@interface GBApplicationSettingsProvider () @interface GBApplicationSettingsProvider ()


+ (NSSet *)nonCopyableProperties; + (NSSet *)nonCopyableProperties;
Expand Down Expand Up @@ -73,8 +87,8 @@ - (id)init {
self.warnOnInvalidCrossReference = YES; self.warnOnInvalidCrossReference = YES;
self.warnOnMissingMethodArgument = YES; self.warnOnMissingMethodArgument = YES;


self.docsetBundleIdentifier = @"%COMPANYID.%PROJECTID"; self.docsetBundleIdentifier = [NSString stringWithFormat:@"%@.%@", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
self.docsetBundleName = @"%PROJECT Documentation"; self.docsetBundleName = [NSString stringWithFormat:@"%@ Documentation", kGBTemplatePlaceholderProject];
self.docsetCertificateIssuer = @""; self.docsetCertificateIssuer = @"";
self.docsetCertificateSigner = @""; self.docsetCertificateSigner = @"";
self.docsetDescription = @""; self.docsetDescription = @"";
Expand All @@ -84,13 +98,13 @@ - (id)init {
self.docsetPackageURL = @""; self.docsetPackageURL = @"";
self.docsetMinimumXcodeVersion = @"3.0"; self.docsetMinimumXcodeVersion = @"3.0";
self.docsetPlatformFamily = @""; self.docsetPlatformFamily = @"";
self.docsetPublisherIdentifier = @"%COMPANYID.documentation"; self.docsetPublisherIdentifier = [NSString stringWithFormat:@"%@.documentation", kGBTemplatePlaceholderCompanyID];
self.docsetPublisherName = @"%COMPANY"; self.docsetPublisherName = [NSString stringWithFormat:@"%@", kGBTemplatePlaceholderCompany];
self.docsetCopyrightMessage = @"Copyright © %YEAR %COMPANY. All rights reserved."; self.docsetCopyrightMessage = [NSString stringWithFormat:@"Copyright © %@ %@. All rights reserved.", kGBTemplatePlaceholderYear, kGBTemplatePlaceholderCompany];


self.docsetBundleFilename = @"%COMPANYID.%PROJECTID.docset"; self.docsetBundleFilename = [NSString stringWithFormat:@"%@.%@.docset", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
self.docsetAtomFilename = @"%COMPANYID.%PROJECTID.atom"; self.docsetAtomFilename = [NSString stringWithFormat:@"%@.%@.atom", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
self.docsetPackageFilename = @"%COMPANYID.%PROJECTID-%VERSIONID.xar"; self.docsetPackageFilename = [NSString stringWithFormat:@"%@.%@-%@.xar", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID, kGBTemplatePlaceholderVersionID];


self.commentComponents = [GBCommentComponentsProvider provider]; self.commentComponents = [GBCommentComponentsProvider provider];
self.stringTemplates = [GBApplicationStringsProvider provider]; self.stringTemplates = [GBApplicationStringsProvider provider];
Expand Down Expand Up @@ -266,17 +280,17 @@ - (BOOL)isTopLevelStoreObject:(id)object {
} }


- (NSString *)stringByReplacingOccurencesOfPlaceholdersInString:(NSString *)string { - (NSString *)stringByReplacingOccurencesOfPlaceholdersInString:(NSString *)string {
string = [string stringByReplacingOccurrencesOfString:@"%COMPANYID" withString:self.companyIdentifier]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderCompanyID withString:self.companyIdentifier];
string = [string stringByReplacingOccurrencesOfString:@"%PROJECTID" withString:self.projectIdentifier]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderProjectID withString:self.projectIdentifier];
string = [string stringByReplacingOccurrencesOfString:@"%VERSIONID" withString:self.versionIdentifier]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderVersionID withString:self.versionIdentifier];
string = [string stringByReplacingOccurrencesOfString:@"%PROJECT" withString:self.projectName]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderProject withString:self.projectName];
string = [string stringByReplacingOccurrencesOfString:@"%COMPANY" withString:self.projectCompany]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderCompany withString:self.projectCompany];
string = [string stringByReplacingOccurrencesOfString:@"%VERSION" withString:self.projectVersion]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderVersion withString:self.projectVersion];
string = [string stringByReplacingOccurrencesOfString:@"%DOCSETBUNDLEFILENAME" withString:self.docsetBundleFilename]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetBundleFilename withString:self.docsetBundleFilename];
string = [string stringByReplacingOccurrencesOfString:@"%DOCSETATOMFILENAME" withString:self.docsetAtomFilename]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetAtomFilename withString:self.docsetAtomFilename];
string = [string stringByReplacingOccurrencesOfString:@"%DOCSETPACKAGEFILENAME" withString:self.docsetPackageFilename]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetPackageFilename withString:self.docsetPackageFilename];
string = [string stringByReplacingOccurrencesOfString:@"%YEAR" withString:[self yearStringFromDate:[NSDate date]]]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderYear withString:[self yearStringFromDate:[NSDate date]]];
string = [string stringByReplacingOccurrencesOfString:@"%UPDATEDATE" withString:[self yearToDayStringFromDate:[NSDate date]]]; string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderUpdateDate withString:[self yearToDayStringFromDate:[NSDate date]]];
return string; return string;
} }


Expand Down
4 changes: 2 additions & 2 deletions Generating/GBHTMLTemplateVariablesProvider.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ - (NSDictionary *)arrayDescriptorForArray:(NSArray *)array {


- (void)addFooterVarsToDictionary:(NSMutableDictionary *)dict { - (void)addFooterVarsToDictionary:(NSMutableDictionary *)dict {
[dict setObject:self.settings.projectCompany forKey:@"copyrightHolder"]; [dict setObject:self.settings.projectCompany forKey:@"copyrightHolder"];
[dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:@"%YEAR"] forKey:@"copyrightDate"]; [dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:kGBTemplatePlaceholderYear] forKey:@"copyrightDate"];
[dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:@"%UPDATEDATE"] forKey:@"lastUpdatedDate"]; [dict setObject:[self.settings stringByReplacingOccurencesOfPlaceholdersInString:kGBTemplatePlaceholderUpdateDate] forKey:@"lastUpdatedDate"];
} }


#pragma mark Properties #pragma mark Properties
Expand Down

0 comments on commit 1f23b3e

Please sign in to comment.