Skip to content
This repository

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

Merged
merged 3 commits into from over 1 year ago

3 participants

Tom Davie Bogdan Popescu tomaz
Tom Davie

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

Bogdan Popescu

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.

Tom Davie

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?

Tom Davie

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.

Tom Davie

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

Bogdan Popescu

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.

Tom Davie

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.

Tom Davie

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.

Bogdan Popescu

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 :)

Tom Davie

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)?

Bogdan Popescu

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?

Tom Davie

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 from
tomaz tomaz closed this
tomaz
Owner

Just merged.

Bogdan Popescu

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 :)

Jeffrey Wear 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.
7 Application/GBAppledocApplication.m
@@ -39,6 +39,7 @@
39 39 static NSString *kGBArgCreateDocSet = @"create-docset";
40 40 static NSString *kGBArgInstallDocSet = @"install-docset";
41 41 static NSString *kGBArgPublishDocSet = @"publish-docset";
  42 +static NSString *kGBArgHTMLAnchorFormat = @"html-anchors";
42 43 static NSString *kGBArgKeepIntermediateFiles = @"keep-intermediate-files";
43 44 static NSString *kGBArgExitCodeThreshold = @"exit-threshold";
44 45
@@ -266,6 +267,7 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
266 267 { kGBArgCreateDocSet, 'd', DDGetoptNoArgument },
267 268 { kGBArgInstallDocSet, 'n', DDGetoptNoArgument },
268 269 { kGBArgPublishDocSet, 'u', DDGetoptNoArgument },
  270 + { kGBArgHTMLAnchorFormat, 0, DDGetoptRequiredArgument },
269 271 { GBNoArg(kGBArgCreateHTML), 0, DDGetoptNoArgument },
270 272 { GBNoArg(kGBArgCreateDocSet), 0, DDGetoptNoArgument },
271 273 { GBNoArg(kGBArgInstallDocSet), 0, DDGetoptNoArgument },
@@ -765,6 +767,9 @@ - (void)setPublishDocset:(BOOL)value {
765 767 // self.settings.installDocSet = YES;
766 768 }
767 769 }
  770 +- (void)setHtmlAnchors:(NSString *)value {
  771 + self.settings.htmlAnchorFormat = GBHTMLAnchorFormatFromNSString(value);
  772 +}
768 773 - (void)setNoCleanOutput:(BOOL)value { self.settings.cleanupOutputPathBeforeRunning = !value; }
769 774 - (void)setNoCreateHtml:(BOOL)value { [self setCreateHtml:!value]; }
770 775 - (void)setNoCreateDocset:(BOOL)value { [self setCreateDocset:!value]; }
@@ -905,6 +910,7 @@ - (void)printSettingsAndArguments:(NSArray *)arguments {
905 910 ddprintf(@"--%@ = %@\n", kGBArgCreateDocSet, PRINT_BOOL(self.settings.createDocSet));
906 911 ddprintf(@"--%@ = %@\n", kGBArgInstallDocSet, PRINT_BOOL(self.settings.installDocSet));
907 912 ddprintf(@"--%@ = %@\n", kGBArgPublishDocSet, PRINT_BOOL(self.settings.publishDocSet));
  913 + ddprintf(@"--%@ = %@\n", kGBArgHTMLAnchorFormat, NSStringFromGBHTMLAnchorFormat(self.settings.htmlAnchorFormat));
908 914 ddprintf(@"--%@ = %@\n", kGBArgKeepIntermediateFiles, PRINT_BOOL(self.settings.keepIntermediateFiles));
909 915 ddprintf(@"--%@ = %@\n", kGBArgKeepUndocumentedObjects, PRINT_BOOL(self.settings.keepUndocumentedObjects));
910 916 ddprintf(@"--%@ = %@\n", kGBArgKeepUndocumentedMembers, PRINT_BOOL(self.settings.keepUndocumentedMembers));
@@ -969,6 +975,7 @@ - (void)printHelp {
969 975 PRINT_USAGE(@"-d,", kGBArgCreateDocSet, @"", @"[b] Create documentation set");
970 976 PRINT_USAGE(@"-n,", kGBArgInstallDocSet, @"", @"[b] Install documentation set to Xcode");
971 977 PRINT_USAGE(@"-u,", kGBArgPublishDocSet, @"", @"[b] Prepare DocSet for publishing");
  978 + PRINT_USAGE(@" ", kGBArgHTMLAnchorFormat, @"<string>", @"[*] The html anchor format to use in DocSet HTML.");
972 979 PRINT_USAGE(@" ", kGBArgCleanOutput, @"", @"[b] Remove contents of output path before starting !!CAUTION!!");
973 980 ddprintf(@"\n");
974 981 ddprintf(@"OPTIONS\n");
19 Application/GBApplicationSettingsProvider.h
@@ -13,6 +13,15 @@
13 13
14 14 extern id kGBCustomDocumentIndexDescKey;
15 15
  16 +typedef enum
  17 +{
  18 + GBHTMLAnchorFormatAppleDoc = 0,
  19 + GBHTMLAnchorFormatApple
  20 +} GBHTMLAnchorFormat;
  21 +
  22 +GBHTMLAnchorFormat GBHTMLAnchorFormatFromNSString(NSString *formatString);
  23 +NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
  24 +
16 25 #pragma mark -
17 26
18 27 /** Main application settings provider.
@@ -213,6 +222,16 @@ extern id kGBCustomDocumentIndexDescKey;
213 222 */
214 223 @property (assign) BOOL publishDocSet;
215 224
  225 +/** Specifies the format docsets should use for their html anchors.
  226 +
  227 + If `appledoc`, docset HTML files will use the format `//api/name/symbol_name` for anchor names.
  228 +
  229 + If `apple`, docset HTML files will use the format `//apple_ref/occ/symbol_type/parent_symbol/symbol_name/`.
  230 +
  231 + @see createDocSet
  232 + */
  233 +@property (assign) GBHTMLAnchorFormat htmlAnchorFormat;
  234 +
216 235 /** Specifies whether intermediate files should be kept in `outputPath` or not.
217 236
218 237 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!
27 Application/GBApplicationSettingsProvider.m
@@ -28,6 +28,24 @@
28 28
29 29 NSString *kGBCustomDocumentIndexDescKey = @"index-description";
30 30
  31 +GBHTMLAnchorFormat GBHTMLAnchorFormatFromNSString(NSString *formatString) {
  32 + NSString *lowercaseFormatString = [formatString lowercaseString];
  33 + if ([lowercaseFormatString isEqualToString:@"apple"]) {
  34 + return GBHTMLAnchorFormatApple;
  35 + }
  36 + // We default to appledoc format if the option is not recognised
  37 + return GBHTMLAnchorFormatAppleDoc;
  38 +}
  39 +
  40 +NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format) {
  41 + switch (format) {
  42 + case GBHTMLAnchorFormatAppleDoc:
  43 + return @"appledoc";
  44 + case GBHTMLAnchorFormatApple:
  45 + return @"apple";
  46 + }
  47 +}
  48 +
31 49 #pragma mark -
32 50
33 51 @interface GBApplicationSettingsProvider ()
@@ -83,6 +101,7 @@ - (id)init {
83 101 self.createDocSet = YES;
84 102 self.installDocSet = YES;
85 103 self.publishDocSet = NO;
  104 + self.htmlAnchorFormat = GBHTMLAnchorFormatAppleDoc;
86 105 self.repeatFirstParagraphForMemberDescription = YES;
87 106 self.preprocessHeaderDoc = NO;
88 107 self.printInformationBlockTitles = YES;
@@ -373,7 +392,12 @@ - (NSString *)htmlReferenceForMember:(GBModelBase *)member prefixedWith:(NSStrin
373 392 NSParameterAssert(prefix != nil);
374 393 if ([member isKindOfClass:[GBMethodData class]]) {
375 394 GBMethodData *method = (GBMethodData *)member;
376   - return [NSString stringWithFormat:@"%@//api/name/%@", prefix, method.methodSelector];
  395 + switch (htmlAnchorFormat) {
  396 + case GBHTMLAnchorFormatApple:
  397 + return [NSString stringWithFormat:@"%@//apple_ref/occ/%@/%@/%@", prefix, [method methodTypeString], [method parentObject], method.methodSelector];
  398 + case GBHTMLAnchorFormatAppleDoc:
  399 + return [NSString stringWithFormat:@"%@//api/name/%@", prefix, method.methodSelector];
  400 + }
377 401 }
378 402 return @"";
379 403 }
@@ -623,6 +647,7 @@ - (NSString *)versionIdentifier {
623 647 @synthesize createDocSet;
624 648 @synthesize installDocSet;
625 649 @synthesize publishDocSet;
  650 +@synthesize htmlAnchorFormat;
626 651 @synthesize keepIntermediateFiles;
627 652 @synthesize cleanupOutputPathBeforeRunning;
628 653 @synthesize treatDocSetIndexingErrorsAsFatals;
4 Model/GBMethodData.h
@@ -119,6 +119,10 @@ typedef NSUInteger GBMethodType;
119 119 */
120 120 @property (retain) GBMethodSectionData *methodSection;
121 121
  122 +/** A string representing the type of the method
  123 + */
  124 +@property (readonly) NSString *methodTypeString;
  125 +
122 126 ///---------------------------------------------------------------------------------------
123 127 /// @name Helper properties
124 128 ///---------------------------------------------------------------------------------------
17 Model/GBMethodData.m
@@ -10,6 +10,8 @@
10 10 #import "GBMethodArgument.h"
11 11 #import "GBMethodSectionData.h"
12 12 #import "GBMethodData.h"
  13 +#import "GBClassData.h"
  14 +#import "GBCategoryData.h"
13 15 #import "RegexKitLite.h"
14 16
15 17 @interface GBMethodData ()
@@ -365,6 +367,21 @@ - (NSString *)description {
365 367
366 368 #pragma mark Properties
367 369
  370 +- (NSString *)methodTypeString {
  371 + BOOL isInterfaceParent = (![self.parentObject isKindOfClass:[GBClassData class]] &&
  372 + ![self.parentObject isKindOfClass:[GBCategoryData class]]);
  373 + switch (self.methodType)
  374 + {
  375 + case GBMethodTypeClass:
  376 + return isInterfaceParent ? @"intfcm" : @"clm";
  377 + case GBMethodTypeInstance:
  378 + return isInterfaceParent ? @"intfm" : @"instm";
  379 + case GBMethodTypeProperty:
  380 + return isInterfaceParent ? @"intfp" : @"instp";
  381 + }
  382 + return @"";
  383 +}
  384 +
368 385 - (BOOL)isInstanceMethod {
369 386 return (self.methodType == GBMethodTypeInstance);
370 387 }
100 Testing/GBApplicationSettingsProviderTesting.m
@@ -167,8 +167,11 @@ - (void)testHtmlReferenceNameForObject_shouldReturnProperValueForDocuments {
167 167
168 168 - (void)testHtmlReferenceNameForObject_shouldReturnProperValueForMethods {
169 169 // setup
170   - GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
171   - settings.outputPath = @"anything :)";
  170 + GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
  171 + GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
  172 + settings1.outputPath = @"anything :)";
  173 + settings2.outputPath = @"anything :)";
  174 + settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
172 175 GBMethodArgument *argument = [GBMethodArgument methodArgumentWithName:@"method"];
173 176 GBMethodData *method1 = [GBTestObjectsRegistry instanceMethodWithArguments:argument, nil];
174 177 GBMethodData *method2 = [GBTestObjectsRegistry instanceMethodWithNames:@"doSomething", @"withVars", nil];
@@ -178,47 +181,65 @@ - (void)testHtmlReferenceNameForObject_shouldReturnProperValueForMethods {
178 181 [class.methods registerMethod:method2];
179 182 [class.methods registerMethod:property];
180 183 // execute & verify
181   - assertThat([settings htmlReferenceNameForObject:method1], is(@"//api/name/method"));
182   - assertThat([settings htmlReferenceNameForObject:method2], is(@"//api/name/doSomething:withVars:"));
183   - assertThat([settings htmlReferenceNameForObject:property], is(@"//api/name/value"));
  184 + assertThat([settings1 htmlReferenceNameForObject:method1], is(@"//api/name/method"));
  185 + assertThat([settings1 htmlReferenceNameForObject:method2], is(@"//api/name/doSomething:withVars:"));
  186 + assertThat([settings1 htmlReferenceNameForObject:property], is(@"//api/name/value"));
  187 + assertThat([settings2 htmlReferenceNameForObject:method1], is(@"//apple_ref/occ/instm/Class/method"));
  188 + assertThat([settings2 htmlReferenceNameForObject:method2], is(@"//apple_ref/occ/instm/Class/doSomething:withVars:"));
  189 + assertThat([settings2 htmlReferenceNameForObject:property], is(@"//apple_ref/occ/instp/Class/value"));
184 190 }
185 191
186 192 #pragma mark HTML href references handling - index
187 193
188 194 - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForClassFromIndex {
189 195 // setup
190   - GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
191   - settings.outputPath = @"anything :)";
  196 + GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
  197 + GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
  198 + settings1.outputPath = @"anything :)";
  199 + settings2.outputPath = @"anything :)";
  200 + settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
192 201 GBClassData *class = [GBClassData classDataWithName:@"Class"];
193 202 GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
194 203 [class.methods registerMethod:method];
195 204 // execute & verify
196   - assertThat([settings htmlReferenceForObject:class fromSource:nil], is(@"Classes/Class.html"));
197   - assertThat([settings htmlReferenceForObject:method fromSource:nil], is(@"Classes/Class.html#//api/name/method:"));
  205 + assertThat([settings1 htmlReferenceForObject:class fromSource:nil], is(@"Classes/Class.html"));
  206 + assertThat([settings1 htmlReferenceForObject:method fromSource:nil], is(@"Classes/Class.html#//api/name/method:"));
  207 + assertThat([settings2 htmlReferenceForObject:class fromSource:nil], is(@"Classes/Class.html"));
  208 + assertThat([settings2 htmlReferenceForObject:method fromSource:nil], is(@"Classes/Class.html#//apple_ref/occ/instm/Class/method:"));
198 209 }
199 210
200 211 - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForCategoryFromIndex {
201 212 // setup
202   - GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
203   - settings.outputPath = @"anything :)";
  213 + GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
  214 + GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
  215 + settings1.outputPath = @"anything :)";
  216 + settings2.outputPath = @"anything :)";
  217 + settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
204 218 GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
205 219 GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
206 220 [category.methods registerMethod:method];
207 221 // execute & verify
208   - assertThat([settings htmlReferenceForObject:category fromSource:nil], is(@"Categories/Class+Category.html"));
209   - assertThat([settings htmlReferenceForObject:method fromSource:nil], is(@"Categories/Class+Category.html#//api/name/method:"));
  222 + assertThat([settings1 htmlReferenceForObject:category fromSource:nil], is(@"Categories/Class+Category.html"));
  223 + assertThat([settings1 htmlReferenceForObject:method fromSource:nil], is(@"Categories/Class+Category.html#//api/name/method:"));
  224 + assertThat([settings2 htmlReferenceForObject:category fromSource:nil], is(@"Categories/Class+Category.html"));
  225 + assertThat([settings2 htmlReferenceForObject:method fromSource:nil], is(@"Categories/Class+Category.html#//apple_ref/occ/instm/Class(Category)/method:"));
210 226 }
211 227
212 228 - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForProtocolFromIndex {
213 229 // setup
214   - GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
215   - settings.outputPath = @"anything :)";
  230 + GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
  231 + GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
  232 + settings1.outputPath = @"anything :)";
  233 + settings2.outputPath = @"anything :)";
  234 + settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
216 235 GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
217 236 GBMethodData *method = [GBTestObjectsRegistry instanceMethodWithNames:@"method", nil];
218 237 [protocol.methods registerMethod:method];
219 238 // execute & verify
220   - assertThat([settings htmlReferenceForObject:protocol fromSource:nil], is(@"Protocols/Protocol.html"));
221   - assertThat([settings htmlReferenceForObject:method fromSource:nil], is(@"Protocols/Protocol.html#//api/name/method:"));
  239 + assertThat([settings1 htmlReferenceForObject:protocol fromSource:nil], is(@"Protocols/Protocol.html"));
  240 + assertThat([settings1 htmlReferenceForObject:method fromSource:nil], is(@"Protocols/Protocol.html#//api/name/method:"));
  241 + assertThat([settings2 htmlReferenceForObject:protocol fromSource:nil], is(@"Protocols/Protocol.html"));
  242 + assertThat([settings2 htmlReferenceForObject:method fromSource:nil], is(@"Protocols/Protocol.html#//apple_ref/occ/intfm/Protocol/method:"));
222 243 }
223 244
224 245 - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForDocumentFromIndex {
@@ -346,35 +367,50 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForCustomDoc
346 367
347 368 - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelObjectToItsMemberReference {
348 369 // setup
349   - GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
350   - settings.outputPath = @"anything :)";
  370 + GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
  371 + GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
  372 + settings1.outputPath = @"anything :)";
  373 + settings2.outputPath = @"anything :)";
  374 + settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
351 375 GBClassData *class = [GBClassData classDataWithName:@"Class"];
352 376 GBMethodData *method = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
353 377 [class.methods registerMethod:method];
354 378 // execute & verify
355   - assertThat([settings htmlReferenceForObject:method fromSource:class], is(@"#//api/name/value"));
356   - assertThat([settings htmlReferenceForObject:class fromSource:method], is(@"Class.html"));
  379 + assertThat([settings1 htmlReferenceForObject:method fromSource:class], is(@"#//api/name/value"));
  380 + assertThat([settings1 htmlReferenceForObject:class fromSource:method], is(@"Class.html"));
  381 + assertThat([settings2 htmlReferenceForObject:method fromSource:class], is(@"#//apple_ref/occ/instp/Class/value"));
  382 + assertThat([settings2 htmlReferenceForObject:class fromSource:method], is(@"Class.html"));
357 383 }
358 384
359 385 - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelObjectToSameTypeRemoteMemberReference {
360 386 // setup
361   - GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
362   - settings.outputPath = @"anything :)";
  387 + GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
  388 + GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
  389 + settings1.outputPath = @"anything :)";
  390 + settings2.outputPath = @"anything :)";
  391 + settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
363 392 GBClassData *class1 = [GBClassData classDataWithName:@"Class1"];
364 393 GBClassData *class2 = [GBClassData classDataWithName:@"Class2"];
365 394 GBMethodData *method = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
366 395 [class1.methods registerMethod:method];
367 396 // execute & verify
368   - assertThat([settings htmlReferenceForObject:method fromSource:class2], is(@"../Classes/Class1.html#//api/name/value"));
369   - assertThat([settings htmlReferenceForObject:method fromSource:class1], is(@"#//api/name/value"));
370   - assertThat([settings htmlReferenceForObject:class1 fromSource:method], is(@"Class1.html"));
371   - assertThat([settings htmlReferenceForObject:class2 fromSource:method], is(@"../Classes/Class2.html"));
  397 + assertThat([settings1 htmlReferenceForObject:method fromSource:class2], is(@"../Classes/Class1.html#//api/name/value"));
  398 + assertThat([settings1 htmlReferenceForObject:method fromSource:class1], is(@"#//api/name/value"));
  399 + assertThat([settings1 htmlReferenceForObject:class1 fromSource:method], is(@"Class1.html"));
  400 + assertThat([settings1 htmlReferenceForObject:class2 fromSource:method], is(@"../Classes/Class2.html"));
  401 + assertThat([settings2 htmlReferenceForObject:method fromSource:class2], is(@"../Classes/Class1.html#//apple_ref/occ/instp/Class1/value"));
  402 + assertThat([settings2 htmlReferenceForObject:method fromSource:class1], is(@"#//apple_ref/occ/instp/Class1/value"));
  403 + assertThat([settings2 htmlReferenceForObject:class1 fromSource:method], is(@"Class1.html"));
  404 + assertThat([settings2 htmlReferenceForObject:class2 fromSource:method], is(@"../Classes/Class2.html"));
372 405 }
373 406
374 407 - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelObjectToDifferentTypeRemoteMemberReference {
375 408 // setup
376   - GBApplicationSettingsProvider *settings = [GBApplicationSettingsProvider provider];
377   - settings.outputPath = @"anything :)";
  409 + GBApplicationSettingsProvider *settings1 = [GBApplicationSettingsProvider provider];
  410 + GBApplicationSettingsProvider *settings2 = [GBApplicationSettingsProvider provider];
  411 + settings1.outputPath = @"anything :)";
  412 + settings2.outputPath = @"anything :)";
  413 + settings2.htmlAnchorFormat = GBHTMLAnchorFormatApple;
378 414 GBClassData *class = [GBClassData classDataWithName:@"Class"];
379 415 GBCategoryData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
380 416 GBMethodData *method1 = [GBTestObjectsRegistry propertyMethodWithArgument:@"value1"];
@@ -382,8 +418,10 @@ - (void)testHtmlReferenceForObjectFromSource_shouldReturnProperValueForTopLevelO
382 418 [class.methods registerMethod:method1];
383 419 [protocol.methods registerMethod:method2];
384 420 // execute & verify
385   - assertThat([settings htmlReferenceForObject:method1 fromSource:protocol], is(@"../Classes/Class.html#//api/name/value1"));
386   - assertThat([settings htmlReferenceForObject:method2 fromSource:class], is(@"../Protocols/Protocol.html#//api/name/value2"));
  421 + assertThat([settings1 htmlReferenceForObject:method1 fromSource:protocol], is(@"../Classes/Class.html#//api/name/value1"));
  422 + assertThat([settings1 htmlReferenceForObject:method2 fromSource:class], is(@"../Protocols/Protocol.html#//api/name/value2"));
  423 + assertThat([settings2 htmlReferenceForObject:method1 fromSource:protocol], is(@"../Classes/Class.html#//apple_ref/occ/instp/Class/value1"));
  424 + assertThat([settings2 htmlReferenceForObject:method2 fromSource:class], is(@"../Protocols/Protocol.html#//apple_ref/occ/intfp/Protocol/value2"));
387 425 }
388 426
389 427 #pragma mark Template files handling
11 Testing/GBApplicationTesting.m
@@ -212,6 +212,17 @@ - (void)testPublishDocSet_shouldAssignValueToSettings {
212 212 assertThatBool(settings2.publishDocSet, equalToBool(NO));
213 213 }
214 214
  215 +- (void)testUseAppleAnchors_shouldAssignValueToSettings {
  216 + // setup & execute
  217 + GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--html-anchors", @"appledoc", nil];
  218 + GBApplicationSettingsProvider *settings2 = [self settingsByRunningWithArgs:@"--html-anchors", @"apple", nil];
  219 + GBApplicationSettingsProvider *settings3 = [self settingsByRunningWithArgs:nil];
  220 + // verify
  221 + assertThatBool(settings1.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatAppleDoc));
  222 + assertThatBool(settings2.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatApple));
  223 + assertThatBool(settings3.htmlAnchorFormat, equalToInt(GBHTMLAnchorFormatAppleDoc));
  224 +}
  225 +
215 226 - (void)testKeepIntermediateFiles_shouldAssignValueToSettings {
216 227 // setup & execute
217 228 GBApplicationSettingsProvider *settings1 = [self settingsByRunningWithArgs:@"--keep-intermediate-files", nil];

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.