Permalink
Browse files

Swap around HTML anchor format argument to be more flexble.

  • Loading branch information...
1 parent bfcadb2 commit 63ec2a2c95f1513073102448975842ce7cc27271 @beelsebob beelsebob committed Dec 28, 2012
View
13 Application/GBAppledocApplication.m
@@ -39,7 +39,7 @@
static NSString *kGBArgCreateDocSet = @"create-docset";
static NSString *kGBArgInstallDocSet = @"install-docset";
static NSString *kGBArgPublishDocSet = @"publish-docset";
-static NSString *kGBArgUseAppleAnchors = @"use-apple-anchors";
+static NSString *kGBArgHTMLAnchorFormat = @"html-anchors";
static NSString *kGBArgKeepIntermediateFiles = @"keep-intermediate-files";
static NSString *kGBArgExitCodeThreshold = @"exit-threshold";
@@ -267,7 +267,7 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
{ kGBArgCreateDocSet, 'd', DDGetoptNoArgument },
{ kGBArgInstallDocSet, 'n', DDGetoptNoArgument },
{ kGBArgPublishDocSet, 'u', DDGetoptNoArgument },
- { kGBArgUseAppleAnchors, 0, DDGetoptNoArgument },
+ { kGBArgHTMLAnchorFormat, 0, DDGetoptRequiredArgument },
{ GBNoArg(kGBArgCreateHTML), 0, DDGetoptNoArgument },
{ GBNoArg(kGBArgCreateDocSet), 0, DDGetoptNoArgument },
{ GBNoArg(kGBArgInstallDocSet), 0, DDGetoptNoArgument },
@@ -767,13 +767,14 @@ - (void)setPublishDocset:(BOOL)value {
// self.settings.installDocSet = YES;
}
}
-- (void)setUseAppleAnchors:(BOOL)value { self.settings.useAppleAnchors = value; }
+- (void)setHtmlAnchors:(NSString *)value {
+ self.settings.htmlAnchorFormat = GBHTMLAnchorFormatFromNSString(value);
+}
- (void)setNoCleanOutput:(BOOL)value { self.settings.cleanupOutputPathBeforeRunning = !value; }
- (void)setNoCreateHtml:(BOOL)value { [self setCreateHtml:!value]; }
- (void)setNoCreateDocset:(BOOL)value { [self setCreateDocset:!value]; }
- (void)setNoInstallDocset:(BOOL)value { [self setInstallDocset:!value]; }
- (void)setNoPublishDocset:(BOOL)value { [self setPublishDocset:!value]; }
-- (void)setNoUseAppleAnchors:(BOOL)value { [self setUseAppleAnchors:!value]; }
- (void)setCrossrefFormat:(NSString *)value { self.settings.commentComponents.crossReferenceMarkersTemplate = value; }
- (void)setExplicitCrossref:(BOOL)value { self.settings.commentComponents.crossReferenceMarkersTemplate = value ? @"<%@>" : @"<?%@>?"; }
@@ -909,7 +910,7 @@ - (void)printSettingsAndArguments:(NSArray *)arguments {
ddprintf(@"--%@ = %@\n", kGBArgCreateDocSet, PRINT_BOOL(self.settings.createDocSet));
ddprintf(@"--%@ = %@\n", kGBArgInstallDocSet, PRINT_BOOL(self.settings.installDocSet));
ddprintf(@"--%@ = %@\n", kGBArgPublishDocSet, PRINT_BOOL(self.settings.publishDocSet));
- ddprintf(@"--%@ = %@\n", kGBArgUseAppleAnchors, PRINT_BOOL(self.settings.useAppleAnchors));
+ ddprintf(@"--%@ = %@\n", kGBArgHTMLAnchorFormat, NSStringFromGBHTMLAnchorFormat(self.settings.htmlAnchorFormat));
ddprintf(@"--%@ = %@\n", kGBArgKeepIntermediateFiles, PRINT_BOOL(self.settings.keepIntermediateFiles));
ddprintf(@"--%@ = %@\n", kGBArgKeepUndocumentedObjects, PRINT_BOOL(self.settings.keepUndocumentedObjects));
ddprintf(@"--%@ = %@\n", kGBArgKeepUndocumentedMembers, PRINT_BOOL(self.settings.keepUndocumentedMembers));
@@ -974,7 +975,7 @@ - (void)printHelp {
PRINT_USAGE(@"-d,", kGBArgCreateDocSet, @"", @"[b] Create documentation set");
PRINT_USAGE(@"-n,", kGBArgInstallDocSet, @"", @"[b] Install documentation set to Xcode");
PRINT_USAGE(@"-u,", kGBArgPublishDocSet, @"", @"[b] Prepare DocSet for publishing");
- PRINT_USAGE(@" ", kGBArgUseAppleAnchors, @"", @"[b] Use apple style anchors in docsets");
+ PRINT_USAGE(@" ", kGBArgHTMLAnchorFormat, @"<string>", @"[*] The html anchor format to use in DocSet HTML.");
PRINT_USAGE(@" ", kGBArgCleanOutput, @"", @"[b] Remove contents of output path before starting !!CAUTION!!");
ddprintf(@"\n");
ddprintf(@"OPTIONS\n");
View
18 Application/GBApplicationSettingsProvider.h
@@ -13,6 +13,15 @@
extern id kGBCustomDocumentIndexDescKey;
+typedef enum
+{
+ GBHTMLAnchorFormatAppleDoc = 0,
+ GBHTMLAnchorFormatApple
+} GBHTMLAnchorFormat;
+
+GBHTMLAnchorFormat GBHTMLAnchorFormatFromNSString(NSString *formatString);
+NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
+
#pragma mark -
/** Main application settings provider.
@@ -213,12 +222,15 @@ extern id kGBCustomDocumentIndexDescKey;
*/
@property (assign) BOOL publishDocSet;
-/** Specifies whether docSets should use the Apple or appledoc anchor format.
+/** Specifies the format docsets should use for their html anchors.
+
+ If `appledoc`, docset HTML files will use the format `//api/name/symbol_name` for anchor names.
+
+ If `apple`, docset HTML files will use the format `//apple_ref/occ/symbol_type/parent_symbol/symbol_name/`.
- If `YES`, docset HTML files will use the format `//apple_ref/occ/symbol_type/parent_symbol/symbol_name/` for anchor names. Otherwise the format `//api/name/symbol_name` will be used.
@see createDocSet
*/
-@property (assign) BOOL useAppleAnchors;
+@property (assign) GBHTMLAnchorFormat htmlAnchorFormat;
/** Specifies whether intermediate files should be kept in `outputPath` or not.
View
31 Application/GBApplicationSettingsProvider.m
@@ -28,6 +28,24 @@
NSString *kGBCustomDocumentIndexDescKey = @"index-description";
+GBHTMLAnchorFormat GBHTMLAnchorFormatFromNSString(NSString *formatString) {
+ NSString *lowercaseFormatString = [formatString lowercaseString];
+ if ([lowercaseFormatString isEqualToString:@"apple"]) {
+ return GBHTMLAnchorFormatApple;
+ }
+ // We default to appledoc format if the option is not recognised
+ return GBHTMLAnchorFormatAppleDoc;
+}
+
+NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format) {
+ switch (format) {
+ case GBHTMLAnchorFormatAppleDoc:
+ return @"appledoc";
+ case GBHTMLAnchorFormatApple:
+ return @"apple";
+ }
+}
+
#pragma mark -
@interface GBApplicationSettingsProvider ()
@@ -83,7 +101,7 @@ - (id)init {
self.createDocSet = YES;
self.installDocSet = YES;
self.publishDocSet = NO;
- self.useAppleAnchors = NO;
+ self.htmlAnchorFormat = GBHTMLAnchorFormatAppleDoc;
self.repeatFirstParagraphForMemberDescription = YES;
self.preprocessHeaderDoc = NO;
self.printInformationBlockTitles = YES;
@@ -374,9 +392,12 @@ - (NSString *)htmlReferenceForMember:(GBModelBase *)member prefixedWith:(NSStrin
NSParameterAssert(prefix != nil);
if ([member isKindOfClass:[GBMethodData class]]) {
GBMethodData *method = (GBMethodData *)member;
- return (useAppleAnchors ?
- [NSString stringWithFormat:@"%@//apple_ref/occ/%@/%@/%@", prefix, [method methodTypeString], [method parentObject], method.methodSelector] :
- [NSString stringWithFormat:@"%@//api/name/%@", prefix, method.methodSelector]);
+ switch (htmlAnchorFormat) {
+ case GBHTMLAnchorFormatApple:
+ return [NSString stringWithFormat:@"%@//apple_ref/occ/%@/%@/%@", prefix, [method methodTypeString], [method parentObject], method.methodSelector];
+ case GBHTMLAnchorFormatAppleDoc:
+ return [NSString stringWithFormat:@"%@//api/name/%@", prefix, method.methodSelector];
+ }
}
return @"";
}
@@ -626,7 +647,7 @@ - (NSString *)versionIdentifier {
@synthesize createDocSet;
@synthesize installDocSet;
@synthesize publishDocSet;
-@synthesize useAppleAnchors;
+@synthesize htmlAnchorFormat;
@synthesize keepIntermediateFiles;
@synthesize cleanupOutputPathBeforeRunning;
@synthesize treatDocSetIndexingErrorsAsFatals;
View
2 Model/GBMethodData.m
@@ -11,7 +11,7 @@
#import "GBMethodSectionData.h"
#import "GBMethodData.h"
#import "GBClassData.h"
-#import "GBProtocolData.h"
+#import "GBCategoryData.h"
#import "RegexKitLite.h"
@interface GBMethodData ()
View
14 Testing/GBApplicationSettingsProviderTesting.m
@@ -171,7 +171,7 @@ - (void)testHtmlReferenceNameForObject_shouldReturnProperValueForMethods {
GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
settings1.outputPath = @"anything :)";
settings2.outputPath = @"anything :)";
- settings2.useAppleAnchors = YES;
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBMethodArgument *argument = [GBMethodArgument methodArgumentWithName:@"method"];
GBMethodData *method1 = [GBTestObjectsRegistry instanceMethodWithArguments:argument, nil];
GBMethodData *method2 = [GBTestObjectsRegistry instanceMethodWithNames:@"doSomething", @"withVars", nil];
@@ -197,7 +197,7 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForClassFrom
GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
settings1.outputPath = @"anything :)";
settings2.outputPath = @"anything :)";
- settings2.useAppleAnchors = YES;
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBClassData *class = [GBClassData classDataWithName:@"Class"];
GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
[class.methods registerMethod:method];
@@ -214,7 +214,7 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForCategoryF
GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
settings1.outputPath = @"anything :)";
settings2.outputPath = @"anything :)";
- settings2.useAppleAnchors = YES;
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
[category.methods registerMethod:method];
@@ -231,7 +231,7 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForProtocolF
GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
settings1.outputPath = @"anything :)";
settings2.outputPath = @"anything :)";
- settings2.useAppleAnchors = YES;
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
[protocol.methods registerMethod:method];
@@ -371,7 +371,7 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelO
GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
settings1.outputPath = @"anything :)";
settings2.outputPath = @"anything :)";
- settings2.useAppleAnchors = YES;
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBClassData *class = [GBClassData classDataWithName:@"Class"];
GBMethodData *method = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
[class.methods registerMethod:method];
@@ -388,7 +388,7 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelO
GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
settings1.outputPath = @"anything :)";
settings2.outputPath = @"anything :)";
- settings2.useAppleAnchors = YES;
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBClassData *class1 = [GBClassData classDataWithName:@"Class1"];
GBClassData *class2 = [GBClassData classDataWithName:@"Class2"];
GBMethodData *method = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
@@ -410,7 +410,7 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelO
GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
settings1.outputPath = @"anything :)";
settings2.outputPath = @"anything :)";
- settings2.useAppleAnchors = YES;
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBClassData *class = [GBClassData classDataWithName:@"Class"];
GBCategoryData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
GBMethodData *method1 = [GBTestObjectsRegistry propertyMethodWithArgument:@"value1"];
View
10 Testing/GBApplicationTesting.m
@@ -214,11 +214,13 @@ - (void)testPublishDocSet_shouldAssignValueToSettings {
- (void)testUseAppleAnchors_shouldAssignValueToSettings {
// setup & execute
- GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--use-apple-anchors", nil];
- GBApplicationSettingsProvider *settings2 = [self settingsByRunningWithArgs:@"--no-use-apple-anchors", nil];
+ GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--html-anchors", @"appledoc", nil];
+ GBApplicationSettingsProvider *settings2 = [self settingsByRunningWithArgs:@"--html-anchors", @"apple", nil];
+ GBApplicationSettingsProvider *settings3 = [self settingsByRunningWithArgs:nil];
// verify
- assertThatBool(settings1.useAppleAnchors, equalToBool(YES));
- assertThatBool(settings2.useAppleAnchors, equalToBool(NO));
+ assertThatBool(settings1.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatAppleDoc));
+ assertThatBool(settings2.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatApple));
+ assertThatBool(settings3.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatAppleDoc));
}
- (void)testKeepIntermediateFiles_shouldAssignValueToSettings {

0 comments on commit 63ec2a2

Please sign in to comment.