Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Heya, I made the html refs appledoc does generate mirror apple's style. #295

Merged
merged 3 commits into from

3 participants

@beelsebob

I still need to make it generate references for things like Classes, but this is a good first step.

@Kapeli

Just a for what it's worth: this will break the Table of Contents in Dash.

@beelsebob can't you change Stash so it can parse appledoc's anchors as they are now? It's very hard for me to change Dash, because I'd have to support 2 different versions (some users will use the old appledoc-style version, some users will have the new one).

I'm happy to provide the code for parsing appledoc anchors, if you want.

Alternatively, you could have it add new Apple-style anchors, as well as old appledoc anchors.

@beelsebob

The issue with changing Stash is that Apple's anchors encode more information than appledoc's – Stash's indexing process strictly searches for <a name="//apple_ref/.../"> tags, and nothing else, and indexes what they are based on what the anchor name says they are. I added a hack to Stash that allows it to index appledoc generated docs, but it can't display a symbol type icon with them because it simply marks all these symbols as unknown platfrom; unkwon language; unknown symbol type.

This also has the unfortunate consequence that for now, Stash doesn't detect classes in appledoc generated docsets either... Hence the plan to make appledoc generate anchors for them too.

What's the issue with Dash's ToC? Surely if it can parse apple's documentation it can parse appledoc's if they use this format too?

@tomaz
Owner

While I agree on using more standard anchors, I don't want to break existing solutions. My proposal is to add additional cmd line switch that would allow choosing output mode. I'd go with something that can be extended later on, like --mode. If not used, current mode would be used, then you can implement --mode stash that would include changes from this pull request. Shouldn't be that difficult - what do you think?

@beelsebob

I think that's a pretty sane option. I think I'd prefer --mirror-apple-anchors or something along those lines, as this really isn't something specific to Stash, it's simply a case of making appledoc behave more like Apple's documentation.

I'd also suggest that over time this should be moved to being the default option, just with a bit of warning so that other tool authors can get their tools updated to read apple-like docs.

@beelsebob

Just a headsup, hold on on accepting this pull request for one more reason. I managed to get protocols and categories backwards >.<

@Kapeli

I don't think adding a switch is best, for user's sake. Adding a switch which basically means either you get full support for that docset in Dash or in Stash, is not optimal.

I think this could be a viable option: add both old-style appledoc anchors and Apple-style ones, one after the other on the documentation page. I will update Dash so that it will support both styles. This way, if you decide to go for Apple-only after a while, all should be ok. Also, it will allow Stash users to benefit from appledoc docsets right now.

Currently, grabbing the type information from appledoc pages is trivial.

However, I believe you intend on adding support for Typedefs and other types and, in that case, Apple-style anchors would benefit Dash as well, because it would allow it to support Typedefs and whatever types you'll add, from the start.

@beelsebob

Just to be clear, at the moment, this only works for methods. I'll be going through adding anchors to other things like classes/categories/protocols tomorrow.

For now, there's a patch that adds a switch, a patch to generate both anchors would be a bit more work, but I can see it being valuable, yes.

@beelsebob

Just thinking a bit further. Adding both kinds of anchors would cause some nasty code in Stash (and probably Dash), in having to guess whether the docset had apple style references, appledoc style or both, and hence filter down which anchors to pay attention to.

On the other hand, using an option means that unless (for example) facebook become aware of the switch, and deliberately set it or unset it, one or other of Stash or Dash won't be able to properly index the docs.

I think the ideal outcome from my point of view would be to wait for Dash to support apple style references, then (assuming no one else says they need to support it), move appledoc over straight away.

@Kapeli

Dash will support Apple style anchors in the next update (as well as old anchors, in order to help users transition while they update appledoc). I will post here when the update is released on the App Store (my estimate is around the 20th of January).

@tomaz
Owner

I agree on simplifying cmd line, it's become quite bloated with time. When working on GUI apps, I tend to have many options that can change behavior, but only expose the most important ones to settings views. The rest are only available through Terminal (I mainly work on Cocoa). I have them at sensible defaults though. Didn't find such solution for foundation tools yet. So for the moment I still find adding new cmd line switch better than hard coding functionality.

I'd still go with string cmd line switch so we can reuse the same switch for future changes (thus keeping cmd line simpler). I agree on keeping it more generic. Hiw do you find --html-anchors appledoc and --html-anchors apple? This can easily be extended with additional styles if needed. Additionally it's clear the switch affects HTML output.

On the second thought, using such solution for this case would require developers invoking appledoc twice if they would like to support both Dash and Stash, so it's clearly not the best solution. For 3.0 I'd go with a more generic approach. I think long term it's better to adopt DocSet style anchors, then the same style would be used in both HTML and DocSet xml. But I can add specific behavior for better importing to Dash/Stash etc. For example through easily parsable external file (xml, json or similar) or similar. This would separate integration into such tools from actual html - parsing html is not very reliable and can easily break with new styles. I'm open for suggestions on this part (it's no rush though, 3.0 is still a long time ahead :)

BTW I really like conversation on this pull request! So far I simply accepted everything anyone contributed - found it hard to say no to nice folks who took some of their time to implement a feature... But it happened many times that new features broke existing ones, or they used older code base so new stuff that was added in between was now gone. And ultimately, I have to support everything :) For 3.0 I'll be much more strict about it... As minimum I hope to have such constructive debate on each pull request :)

@beelsebob

A sane option for cleaning up your command line flags would be config files, no? I certainly was wishing for a config file when I set up my command line for CoreParse, which has really quite a lot of --ignore flags in it. Anyway, that's a bit OT.

I prefer your non-boolean flags too, I'll fiddle with that today, along with adding anchors in other places. Could we perhaps go for those, but make the default be --html-anchors apple. Then merge this patch only come 20th Jan (or whenever the Dash update is released)?

@Kapeli

On the second thought, using such solution for this case would require developers invoking appledoc twice if they would like to support both Dash and Stash, so it's clearly not the best solution

This shouldn't be a problem, as Dash will support both styles.

But I can add specific behavior for better importing to Dash/Stash etc. For example through easily parsable external file (xml, json or similar) or similar. This would separate integration into such tools from actual html - parsing html is not very reliable and can easily break with new styles

Dash parses the html only for the in-page table of contents. It doesn't parse html in order to build the main index. This is something that Dash does on each page load and will have to do it regardless of an external main index, because it needs to interact with the DOM to know the position of the anchors inside the page for future features (docset annotations).

@tomaz
Owner

Config files are supported by appledoc. There are two levels: global settings file which should be located on the same path as templates, and project settings file, which should be located on one of input paths. Settings are overriden in the following order: factory defaults - global settings - project settings - cmd line. When refactoring this part for 3.0, I made it separate library, see GBCli. It's very simple to setup such hierarchy.

As per default to apple: no, any new feature added should not break existing setups. While appledoc was new, this wasn't so much of a problem, but nowadays many people rely on it to work in particular way, so changing that may affect them. We can make it default for 3.0 though; I'm willing to break functionality with major releases if it makes sense.

@tomaz
Owner

Forgot about this during holidays... Can I merge it or do you have some restraints?

@beelsebob

You can merge it in its current state, it's stable like this, and provides some benefit. I had intended to get to doing anchors for classes, interfaces and categories, but have not got there yet – it took more code reading than I expected.

@tomaz tomaz merged commit 05d4d44 into tomaz:master
@tomaz
Owner

Just merged.

@Kapeli

Dash 1.7.5 has been accepted on the App Store and will be available shortly, adding support for Apple-style anchors in parallel with current anchors. Feel free to default to Apple-style anchors or use them exclusively whenever you feel it's right :)

@wearhere wearhere referenced this pull request in omz/Dash-Plugin-for-Xcode
Closed

Dash creates results for application classes and methods. #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
7 Application/GBAppledocApplication.m
@@ -39,6 +39,7 @@
static NSString *kGBArgCreateDocSet = @"create-docset";
static NSString *kGBArgInstallDocSet = @"install-docset";
static NSString *kGBArgPublishDocSet = @"publish-docset";
+static NSString *kGBArgHTMLAnchorFormat = @"html-anchors";
static NSString *kGBArgKeepIntermediateFiles = @"keep-intermediate-files";
static NSString *kGBArgExitCodeThreshold = @"exit-threshold";
@@ -266,6 +267,7 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
{ kGBArgCreateDocSet, 'd', DDGetoptNoArgument },
{ kGBArgInstallDocSet, 'n', DDGetoptNoArgument },
{ kGBArgPublishDocSet, 'u', DDGetoptNoArgument },
+ { kGBArgHTMLAnchorFormat, 0, DDGetoptRequiredArgument },
{ GBNoArg(kGBArgCreateHTML), 0, DDGetoptNoArgument },
{ GBNoArg(kGBArgCreateDocSet), 0, DDGetoptNoArgument },
{ GBNoArg(kGBArgInstallDocSet), 0, DDGetoptNoArgument },
@@ -765,6 +767,9 @@ - (void)setPublishDocset:(BOOL)value {
// self.settings.installDocSet = YES;
}
}
+- (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]; }
@@ -905,6 +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", 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));
@@ -969,6 +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(@" ", 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
19 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,6 +222,16 @@ extern id kGBCustomDocumentIndexDescKey;
*/
@property (assign) BOOL publishDocSet;
+/** 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/`.
+
+ @see createDocSet
+ */
+@property (assign) GBHTMLAnchorFormat htmlAnchorFormat;
+
/** Specifies whether intermediate files should be kept in `outputPath` or not.
If `YES`, all intermediate files (i.e. HTML files and documentation set files) are kept in output path. If `NO`, only final results are kept. This setting not only affects how the files are being handled, it also affects performance. If intermediate files are not kept, appledoc moves files between various generation phases, otherwise it copies them. So it's prefferable to leave this option to `NO`. This option only affects output files, input source files are always left intact!
View
27 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,6 +101,7 @@ - (id)init {
self.createDocSet = YES;
self.installDocSet = YES;
self.publishDocSet = NO;
+ self.htmlAnchorFormat = GBHTMLAnchorFormatAppleDoc;
self.repeatFirstParagraphForMemberDescription = YES;
self.preprocessHeaderDoc = NO;
self.printInformationBlockTitles = YES;
@@ -373,7 +392,12 @@ - (NSString *)htmlReferenceForMember:(GBModelBase *)member prefixedWith:(NSStrin
NSParameterAssert(prefix != nil);
if ([member isKindOfClass:[GBMethodData class]]) {
GBMethodData *method = (GBMethodData *)member;
- return [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 @"";
}
@@ -623,6 +647,7 @@ - (NSString *)versionIdentifier {
@synthesize createDocSet;
@synthesize installDocSet;
@synthesize publishDocSet;
+@synthesize htmlAnchorFormat;
@synthesize keepIntermediateFiles;
@synthesize cleanupOutputPathBeforeRunning;
@synthesize treatDocSetIndexingErrorsAsFatals;
View
4 Model/GBMethodData.h
@@ -119,6 +119,10 @@ typedef NSUInteger GBMethodType;
*/
@property (retain) GBMethodSectionData *methodSection;
+/** A string representing the type of the method
+ */
+@property (readonly) NSString *methodTypeString;
+
///---------------------------------------------------------------------------------------
/// @name Helper properties
///---------------------------------------------------------------------------------------
View
17 Model/GBMethodData.m
@@ -10,6 +10,8 @@
#import "GBMethodArgument.h"
#import "GBMethodSectionData.h"
#import "GBMethodData.h"
+#import "GBClassData.h"
+#import "GBCategoryData.h"
#import "RegexKitLite.h"
@interface GBMethodData ()
@@ -365,6 +367,21 @@ - (NSString *)description {
#pragma mark Properties
+- (NSString *)methodTypeString {
+ BOOL isInterfaceParent = (![self.parentObject isKindOfClass:[GBClassData class]] &&
+ ![self.parentObject isKindOfClass:[GBCategoryData class]]);
+ switch (self.methodType)
+ {
+ case GBMethodTypeClass:
+ return isInterfaceParent ? @"intfcm" : @"clm";
+ case GBMethodTypeInstance:
+ return isInterfaceParent ? @"intfm" : @"instm";
+ case GBMethodTypeProperty:
+ return isInterfaceParent ? @"intfp" : @"instp";
+ }
+ return @"";
+}
+
- (BOOL)isInstanceMethod {
return (self.methodType == GBMethodTypeInstance);
}
View
100 Testing/GBApplicationSettingsProviderTesting.m
@@ -167,8 +167,11 @@ - (void)testHtmlReferenceNameForObject_shouldReturnProperValueForDocuments {
- (void)testHtmlReferenceNameForObject_shouldReturnProperValueForMethods {
// setup
- GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
- settings.outputPath = @"anything :)";
+ GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
+ GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
+ settings1.outputPath = @"anything :)";
+ settings2.outputPath = @"anything :)";
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBMethodArgument *argument = [GBMethodArgument methodArgumentWithName:@"method"];
GBMethodData *method1 = [GBTestObjectsRegistry instanceMethodWithArguments:argument, nil];
GBMethodData *method2 = [GBTestObjectsRegistry instanceMethodWithNames:@"doSomething", @"withVars", nil];
@@ -178,47 +181,65 @@ - (void)testHtmlReferenceNameForObject_shouldReturnProperValueForMethods {
[class.methods registerMethod:method2];
[class.methods registerMethod:property];
// execute & verify
- assertThat([settings htmlReferenceNameForObject:method1], is(@"//api/name/method"));
- assertThat([settings htmlReferenceNameForObject:method2], is(@"//api/name/doSomething:withVars:"));
- assertThat([settings htmlReferenceNameForObject:property], is(@"//api/name/value"));
+ assertThat([settings1 htmlReferenceNameForObject:method1], is(@"//api/name/method"));
+ assertThat([settings1 htmlReferenceNameForObject:method2], is(@"//api/name/doSomething:withVars:"));
+ assertThat([settings1 htmlReferenceNameForObject:property], is(@"//api/name/value"));
+ assertThat([settings2 htmlReferenceNameForObject:method1], is(@"//apple_ref/occ/instm/Class/method"));
+ assertThat([settings2 htmlReferenceNameForObject:method2], is(@"//apple_ref/occ/instm/Class/doSomething:withVars:"));
+ assertThat([settings2 htmlReferenceNameForObject:property], is(@"//apple_ref/occ/instp/Class/value"));
}
#pragma mark HTML href references handling - index
- (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForClassFromIndex {
// setup
- GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
- settings.outputPath = @"anything :)";
+ GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
+ GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
+ settings1.outputPath = @"anything :)";
+ settings2.outputPath = @"anything :)";
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBClassData *class = [GBClassData classDataWithName:@"Class"];
GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
[class.methods registerMethod:method];
// execute & verify
- assertThat([settings htmlReferenceForObject:class fromSource:nil], is(@"Classes/Class.html"));
- assertThat([settings htmlReferenceForObject:method fromSource:nil], is(@"Classes/Class.html#//api/name/method:"));
+ assertThat([settings1 htmlReferenceForObject:class fromSource:nil], is(@"Classes/Class.html"));
+ assertThat([settings1 htmlReferenceForObject:method fromSource:nil], is(@"Classes/Class.html#//api/name/method:"));
+ assertThat([settings2 htmlReferenceForObject:class fromSource:nil], is(@"Classes/Class.html"));
+ assertThat([settings2 htmlReferenceForObject:method fromSource:nil], is(@"Classes/Class.html#//apple_ref/occ/instm/Class/method:"));
}
- (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForCategoryFromIndex {
// setup
- GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
- settings.outputPath = @"anything :)";
+ GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
+ GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
+ settings1.outputPath = @"anything :)";
+ settings2.outputPath = @"anything :)";
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
[category.methods registerMethod:method];
// execute & verify
- assertThat([settings htmlReferenceForObject:category fromSource:nil], is(@"Categories/Class+Category.html"));
- assertThat([settings htmlReferenceForObject:method fromSource:nil], is(@"Categories/Class+Category.html#//api/name/method:"));
+ assertThat([settings1 htmlReferenceForObject:category fromSource:nil], is(@"Categories/Class+Category.html"));
+ assertThat([settings1 htmlReferenceForObject:method fromSource:nil], is(@"Categories/Class+Category.html#//api/name/method:"));
+ assertThat([settings2 htmlReferenceForObject:category fromSource:nil], is(@"Categories/Class+Category.html"));
+ assertThat([settings2 htmlReferenceForObject:method fromSource:nil], is(@"Categories/Class+Category.html#//apple_ref/occ/instm/Class(Category)/method:"));
}
- (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForProtocolFromIndex {
// setup
- GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
- settings.outputPath = @"anything :)";
+ GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
+ GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
+ settings1.outputPath = @"anything :)";
+ settings2.outputPath = @"anything :)";
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
[protocol.methods registerMethod:method];
// execute & verify
- assertThat([settings htmlReferenceForObject:protocol fromSource:nil], is(@"Protocols/Protocol.html"));
- assertThat([settings htmlReferenceForObject:method fromSource:nil], is(@"Protocols/Protocol.html#//api/name/method:"));
+ assertThat([settings1 htmlReferenceForObject:protocol fromSource:nil], is(@"Protocols/Protocol.html"));
+ assertThat([settings1 htmlReferenceForObject:method fromSource:nil], is(@"Protocols/Protocol.html#//api/name/method:"));
+ assertThat([settings2 htmlReferenceForObject:protocol fromSource:nil], is(@"Protocols/Protocol.html"));
+ assertThat([settings2 htmlReferenceForObject:method fromSource:nil], is(@"Protocols/Protocol.html#//apple_ref/occ/intfm/Protocol/method:"));
}
- (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForDocumentFromIndex {
@@ -346,35 +367,50 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForCustomDoc
- (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelObjectToItsMemberReference {
// setup
- GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
- settings.outputPath = @"anything :)";
+ GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
+ GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
+ settings1.outputPath = @"anything :)";
+ settings2.outputPath = @"anything :)";
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBClassData *class = [GBClassData classDataWithName:@"Class"];
GBMethodData *method = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
[class.methods registerMethod:method];
// execute & verify
- assertThat([settings htmlReferenceForObject:method fromSource:class], is(@"#//api/name/value"));
- assertThat([settings htmlReferenceForObject:class fromSource:method], is(@"Class.html"));
+ assertThat([settings1 htmlReferenceForObject:method fromSource:class], is(@"#//api/name/value"));
+ assertThat([settings1 htmlReferenceForObject:class fromSource:method], is(@"Class.html"));
+ assertThat([settings2 htmlReferenceForObject:method fromSource:class], is(@"#//apple_ref/occ/instp/Class/value"));
+ assertThat([settings2 htmlReferenceForObject:class fromSource:method], is(@"Class.html"));
}
- (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelObjectToSameTypeRemoteMemberReference {
// setup
- GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
- settings.outputPath = @"anything :)";
+ GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
+ GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
+ settings1.outputPath = @"anything :)";
+ settings2.outputPath = @"anything :)";
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBClassData *class1 = [GBClassData classDataWithName:@"Class1"];
GBClassData *class2 = [GBClassData classDataWithName:@"Class2"];
GBMethodData *method = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
[class1.methods registerMethod:method];
// execute & verify
- assertThat([settings htmlReferenceForObject:method fromSource:class2], is(@"../Classes/Class1.html#//api/name/value"));
- assertThat([settings htmlReferenceForObject:method fromSource:class1], is(@"#//api/name/value"));
- assertThat([settings htmlReferenceForObject:class1 fromSource:method], is(@"Class1.html"));
- assertThat([settings htmlReferenceForObject:class2 fromSource:method], is(@"../Classes/Class2.html"));
+ assertThat([settings1 htmlReferenceForObject:method fromSource:class2], is(@"../Classes/Class1.html#//api/name/value"));
+ assertThat([settings1 htmlReferenceForObject:method fromSource:class1], is(@"#//api/name/value"));
+ assertThat([settings1 htmlReferenceForObject:class1 fromSource:method], is(@"Class1.html"));
+ assertThat([settings1 htmlReferenceForObject:class2 fromSource:method], is(@"../Classes/Class2.html"));
+ assertThat([settings2 htmlReferenceForObject:method fromSource:class2], is(@"../Classes/Class1.html#//apple_ref/occ/instp/Class1/value"));
+ assertThat([settings2 htmlReferenceForObject:method fromSource:class1], is(@"#//apple_ref/occ/instp/Class1/value"));
+ assertThat([settings2 htmlReferenceForObject:class1 fromSource:method], is(@"Class1.html"));
+ assertThat([settings2 htmlReferenceForObject:class2 fromSource:method], is(@"../Classes/Class2.html"));
}
- (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelObjectToDifferentTypeRemoteMemberReference {
// setup
- GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
- settings.outputPath = @"anything :)";
+ GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
+ GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
+ settings1.outputPath = @"anything :)";
+ settings2.outputPath = @"anything :)";
+ settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
GBClassData *class = [GBClassData classDataWithName:@"Class"];
GBCategoryData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
GBMethodData *method1 = [GBTestObjectsRegistry propertyMethodWithArgument:@"value1"];
@@ -382,8 +418,10 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelO
[class.methods registerMethod:method1];
[protocol.methods registerMethod:method2];
// execute & verify
- assertThat([settings htmlReferenceForObject:method1 fromSource:protocol], is(@"../Classes/Class.html#//api/name/value1"));
- assertThat([settings htmlReferenceForObject:method2 fromSource:class], is(@"../Protocols/Protocol.html#//api/name/value2"));
+ assertThat([settings1 htmlReferenceForObject:method1 fromSource:protocol], is(@"../Classes/Class.html#//api/name/value1"));
+ assertThat([settings1 htmlReferenceForObject:method2 fromSource:class], is(@"../Protocols/Protocol.html#//api/name/value2"));
+ assertThat([settings2 htmlReferenceForObject:method1 fromSource:protocol], is(@"../Classes/Class.html#//apple_ref/occ/instp/Class/value1"));
+ assertThat([settings2 htmlReferenceForObject:method2 fromSource:class], is(@"../Protocols/Protocol.html#//apple_ref/occ/intfp/Protocol/value2"));
}
#pragma mark Template files handling
View
11 Testing/GBApplicationTesting.m
@@ -212,6 +212,17 @@ - (void)testPublishDocSet_shouldAssignValueToSettings {
assertThatBool(settings2.publishDocSet, equalToBool(NO));
}
+- (void)testUseAppleAnchors_shouldAssignValueToSettings {
+ // setup & execute
+ GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--html-anchors", @"appledoc", nil];
+ GBApplicationSettingsProvider *settings2 = [self settingsByRunningWithArgs:@"--html-anchors", @"apple", nil];
+ GBApplicationSettingsProvider *settings3 = [self settingsByRunningWithArgs:nil];
+ // verify
+ assertThatBool(settings1.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatAppleDoc));
+ assertThatBool(settings2.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatApple));
+ assertThatBool(settings3.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatAppleDoc));
+}
+
- (void)testKeepIntermediateFiles_shouldAssignValueToSettings {
// setup & execute
GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--keep-intermediate-files", nil];
Something went wrong with that request. Please try again.