Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding support for generating Dash's xml format #307

This is some initial support for adding Dash xml feed generation. Note that support for specifying formats is a little crude and I've added a template for xml files which I think is a reasonable approach.
  • Loading branch information...
commit 75a390768c9b344e5ce4304fa415b7cf75fccde2 1 parent 140fbb3
Brandon Titus authored
14 Application/GBAppledocApplication.m
@@ -73,6 +73,7 @@
73 73 static NSString *kGBArgDocSetCopyrightMessage = @"docset-copyright";
74 74 static NSString *kGBArgDocSetFeedName = @"docset-feed-name";
75 75 static NSString *kGBArgDocSetFeedURL = @"docset-feed-url";
  76 +static NSString *kGBArgDocSetFeedFormats = @"docset-feed-formats";
76 77 static NSString *kGBArgDocSetPackageURL = @"docset-package-url";
77 78 static NSString *kGBArgDocSetFallbackURL = @"docset-fallback-url";
78 79 static NSString *kGBArgDocSetPublisherIdentifier = @"docset-publisher-id";
@@ -85,6 +86,7 @@
85 86
86 87 static NSString *kGBArgDocSetBundleFilename = @"docset-bundle-filename";
87 88 static NSString *kGBArgDocSetAtomFilename = @"docset-atom-filename";
  89 +static NSString *kGBArgDocSetXMLFilename = @"docset-xml-filename";
88 90 static NSString *kGBArgDocSetPackageFilename = @"docset-package-filename";
89 91
90 92 static NSString *kGBArgLogFormat = @"logformat";
@@ -250,6 +252,7 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
250 252 { kGBArgDocSetFallbackURL, 0, DDGetoptRequiredArgument },
251 253 { kGBArgDocSetFeedName, 0, DDGetoptRequiredArgument },
252 254 { kGBArgDocSetFeedURL, 0, DDGetoptRequiredArgument },
  255 + { kGBArgDocSetFeedFormats, 0, DDGetoptRequiredArgument },
253 256 { kGBArgDocSetPackageURL, 0, DDGetoptRequiredArgument },
254 257 { kGBArgDocSetMinimumXcodeVersion, 0, DDGetoptRequiredArgument },
255 258 { kGBArgDocSetPlatformFamily, 0, DDGetoptRequiredArgument },
@@ -260,6 +263,7 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
260 263
261 264 { kGBArgDocSetBundleFilename, 0, DDGetoptRequiredArgument },
262 265 { kGBArgDocSetAtomFilename, 0, DDGetoptRequiredArgument },
  266 + { kGBArgDocSetXMLFilename, 0, DDGetoptRequiredArgument },
263 267 { kGBArgDocSetPackageFilename, 0, DDGetoptRequiredArgument },
264 268
265 269 { kGBArgCleanOutput, 0, DDGetoptNoArgument },
@@ -831,6 +835,9 @@ - (void)setDocsetDesc:(NSString *)value { self.settings.docsetDescription = valu
831 835 - (void)setDocsetCopyright:(NSString *)value { self.settings.docsetCopyrightMessage = value; }
832 836 - (void)setDocsetFeedName:(NSString *)value { self.settings.docsetFeedName = value; }
833 837 - (void)setDocsetFeedUrl:(NSString *)value { self.settings.docsetFeedURL = value; }
  838 +- (void)setDocsetFeedFormats:(NSString *)value {
  839 + self.settings.docsetFeedFormats = GBPublishedFeedFormatsFromNSString(value);
  840 +}
834 841 - (void)setDocsetPackageUrl:(NSString *)value { self.settings.docsetPackageURL = value; }
835 842 - (void)setDocsetFallbackUrl:(NSString *)value { self.settings.docsetFallbackURL = value; }
836 843 - (void)setDocsetPublisherId:(NSString *)value { self.settings.docsetPublisherIdentifier = value; }
@@ -843,6 +850,7 @@ - (void)setDashPlatformFamily:(NSString *)value { self.settings.dashDocsetPlatfo
843 850
844 851 - (void)setDocsetBundleFilename:(NSString *)value { self.settings.docsetBundleFilename = value; }
845 852 - (void)setDocsetAtomFilename:(NSString *)value { self.settings.docsetAtomFilename = value; }
  853 +- (void)setDocsetXMLFilename:(NSString *)value { self.settings.docsetXMLFilename = value; }
846 854 - (void)setDocsetPackageFilename:(NSString *)value { self.settings.docsetPackageFilename = value; }
847 855
848 856 @synthesize additionalInputPaths;
@@ -894,6 +902,7 @@ - (void)printSettingsAndArguments:(NSArray *)arguments {
894 902 ddprintf(@"--%@ = %@\n", kGBArgDocSetCopyrightMessage, self.settings.docsetCopyrightMessage);
895 903 ddprintf(@"--%@ = %@\n", kGBArgDocSetFeedName, self.settings.docsetFeedName);
896 904 ddprintf(@"--%@ = %@\n", kGBArgDocSetFeedURL, self.settings.docsetFeedURL);
  905 + ddprintf(@"--%@ = %@\n", kGBArgDocSetFeedFormats, NSStringFromGBPublishedFeedFormats(self.settings.docsetFeedFormats));
897 906 ddprintf(@"--%@ = %@\n", kGBArgDocSetPackageURL, self.settings.docsetPackageURL);
898 907 ddprintf(@"--%@ = %@\n", kGBArgDocSetFallbackURL, self.settings.docsetFallbackURL);
899 908 ddprintf(@"--%@ = %@\n", kGBArgDocSetPublisherIdentifier, self.settings.docsetPublisherIdentifier);
@@ -904,6 +913,7 @@ - (void)printSettingsAndArguments:(NSArray *)arguments {
904 913 ddprintf(@"--%@ = %@\n", kGBArgDocSetCertificateSigner, self.settings.docsetCertificateSigner);
905 914 ddprintf(@"--%@ = %@\n", kGBArgDocSetBundleFilename, self.settings.docsetBundleFilename);
906 915 ddprintf(@"--%@ = %@\n", kGBArgDocSetAtomFilename, self.settings.docsetAtomFilename);
  916 + ddprintf(@"--%@ = %@\n", kGBArgDocSetXMLFilename, self.settings.docsetXMLFilename);
907 917 ddprintf(@"--%@ = %@\n", kGBArgDocSetPackageFilename, self.settings.docsetPackageFilename);
908 918 ddprintf(@"\n");
909 919
@@ -1014,6 +1024,7 @@ - (void)printHelp {
1014 1024 PRINT_USAGE(@" ", kGBArgDocSetCopyrightMessage, @"<string>", @"[*] DocSet copyright message");
1015 1025 PRINT_USAGE(@" ", kGBArgDocSetFeedName, @"<string>", @"[*] DocSet feed name");
1016 1026 PRINT_USAGE(@" ", kGBArgDocSetFeedURL, @"<string>", @"[*] DocSet feed URL");
  1027 + PRINT_USAGE(@" ", kGBArgDocSetFeedFormats, @"<values>", @"[*] DocSet feed formats. Separated by a comma [atom,xml]");
1017 1028 PRINT_USAGE(@" ", kGBArgDocSetPackageURL, @"<string>", @"[*] DocSet package (.xar) URL");
1018 1029 PRINT_USAGE(@" ", kGBArgDocSetFallbackURL, @"<string>", @"[*] DocSet fallback URL");
1019 1030 PRINT_USAGE(@" ", kGBArgDocSetPublisherIdentifier, @"<string>", @"[*] DocSet publisher identifier");
@@ -1024,7 +1035,8 @@ - (void)printHelp {
1024 1035 PRINT_USAGE(@" ", kGBArgDocSetCertificateSigner, @"<string>", @"[*] DocSet certificate signer");
1025 1036 PRINT_USAGE(@" ", kGBArgDocSetBundleFilename, @"<string>", @"[*] DocSet bundle filename");
1026 1037 PRINT_USAGE(@" ", kGBArgDocSetAtomFilename, @"<string>", @"[*] DocSet atom feed filename");
1027   - PRINT_USAGE(@" ", kGBArgDocSetPackageFilename, @"<string>", @"[*] DocSet package (.xar) filename");
  1038 + PRINT_USAGE(@" ", kGBArgDocSetXMLFilename, @"<string>", @"[*] DocSet xml feed filename");
  1039 + PRINT_USAGE(@" ", kGBArgDocSetPackageFilename, @"<string>", @"[*] DocSet package (.xar,.tgz) filename. Leave off the extension. This will be added depending on the generated package.");
1028 1040 ddprintf(@"\n");
1029 1041 ddprintf(@"MISCELLANEOUS\n");
1030 1042 PRINT_USAGE(@" ", kGBArgLogFormat, @"<number>", @"Log format [0-3]");
26 Application/GBApplicationSettingsProvider.h
@@ -22,6 +22,15 @@ typedef enum
22 22 GBHTMLAnchorFormat GBHTMLAnchorFormatFromNSString(NSString *formatString);
23 23 NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
24 24
  25 +typedef enum
  26 +{
  27 + GBPublishedFeedFormatAtom = 1,
  28 + GBPublishedFeedFormatXML = 2
  29 +} GBPublishedFeedFormats;
  30 +
  31 +GBPublishedFeedFormats GBPublishedFeedFormatsFromNSString(NSString *formatString);
  32 +NSString *NSStringFromGBPublishedFeedFormats(GBPublishedFeedFormats format);
  33 +
25 34 #pragma mark -
26 35
27 36 /** Main application settings provider.
@@ -104,6 +113,18 @@ NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
104 113 /** Documentation set feed URL. */
105 114 @property (copy) NSString *docsetFeedURL;
106 115
  116 +/** Specifies the format docsets should be published in.
  117 +
  118 + If `atom`, docset will be published using the standard Xcode atom feed format
  119 +
  120 + If `xml`, docset will be published using the xml format specified by the xml-template.xml found in Templates/publish
  121 +
  122 + Multiple values can be included in this parameter separated by a comma
  123 +
  124 + @see publishDocSet
  125 + */
  126 +@property (assign) GBPublishedFeedFormats docsetFeedFormats;
  127 +
107 128 /** Documentation set package URL. */
108 129 @property (copy) NSString *docsetPackageURL;
109 130
@@ -131,6 +152,9 @@ NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
131 152 /** The name of the documentation set atom file when generating publishing files. The file is generated in `outputPath`. */
132 153 @property (copy) NSString *docsetAtomFilename;
133 154
  155 +/** The name of the documentation set xml file when generating publishing files. The file is generated in `outputPath`. */
  156 +@property (copy) NSString *docsetXMLFilename;
  157 +
134 158 /** The name of the documentation set compressed package file when generating publishing files. The file is generated in `outputPath`. */
135 159 @property (copy) NSString *docsetPackageFilename;
136 160
@@ -637,6 +661,7 @@ NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
637 661 - `%VERSIONID`: Replaced by `versionIdentifier` value.
638 662 - `%DOCSETBUNDLEFILENAME`: Replaced by `docsetBundleFilename` value.
639 663 - `%DOCSETATOMFILENAME`: Replaced by `docsetAtomFilename` value.
  664 + - `%DOCSETXMLFILENAME`: Replaced by `docsetXMLFilename` value.
640 665 - `%DOCSETPACKAGEFILENAME`: Replaced by `docsetPackageFilename` value.
641 666 - `%YEAR`: Replaced by current year as four digit string.
642 667 - `%UPDATEDATE`: Replaced by current date in the form of year, month and day with format `YYYY-MM-DD`. For example `2010-11-30`.
@@ -669,6 +694,7 @@ extern NSString *kGBTemplatePlaceholderCompany;
669 694 extern NSString *kGBTemplatePlaceholderVersion;
670 695 extern NSString *kGBTemplatePlaceholderDocSetBundleFilename;
671 696 extern NSString *kGBTemplatePlaceholderDocSetAtomFilename;
  697 +extern NSString *kGBTemplatePlaceholderDocSetXMLFilename;
672 698 extern NSString *kGBTemplatePlaceholderDocSetPackageFilename;
673 699 extern NSString *kGBTemplatePlaceholderYear;
674 700 extern NSString *kGBTemplatePlaceholderUpdateDate;
35 Application/GBApplicationSettingsProvider.m
@@ -22,6 +22,7 @@
22 22 NSString *kGBTemplatePlaceholderVersion = @"%VERSION";
23 23 NSString *kGBTemplatePlaceholderDocSetBundleFilename = @"%DOCSETBUNDLEFILENAME";
24 24 NSString *kGBTemplatePlaceholderDocSetAtomFilename = @"%DOCSETATOMFILENAME";
  25 +NSString *kGBTemplatePlaceholderDocSetXMLFilename = @"%DOCSETXMLFILENAME";
25 26 NSString *kGBTemplatePlaceholderDocSetPackageFilename = @"%DOCSETPACKAGEFILENAME";
26 27 NSString *kGBTemplatePlaceholderYear = @"%YEAR";
27 28 NSString *kGBTemplatePlaceholderUpdateDate = @"%UPDATEDATE";
@@ -46,6 +47,32 @@ GBHTMLAnchorFormat GBHTMLAnchorFormatFromNSString(NSString *formatString) {
46 47 }
47 48 }
48 49
  50 +GBPublishedFeedFormats GBPublishedFeedFormatsFromNSString(NSString *formatString) {
  51 + // These items are comma delimited
  52 + NSArray *formatItems = [[formatString lowercaseString] componentsSeparatedByString:@","];
  53 + GBPublishedFeedFormats formats;
  54 + if ([formatItems containsObject:@"xml"]) {
  55 + formats = formats | GBPublishedFeedFormatXML;
  56 + }
  57 + if ([formatItems containsObject:@"atom"]) {
  58 + formats = formats | GBPublishedFeedFormatAtom;
  59 + }
  60 + return formats;
  61 +}
  62 +
  63 +NSString *NSStringFromGBPublishedFeedFormats(GBPublishedFeedFormats formats) {
  64 + NSMutableArray *formatItems = [NSMutableArray array];
  65 + if(formats & GBPublishedFeedFormatAtom)
  66 + {
  67 + [formatItems addObject:@"atom"];
  68 + }
  69 + if(formats & GBPublishedFeedFormatXML)
  70 + {
  71 + [formatItems addObject:@"xml"];
  72 + }
  73 + return [formatItems componentsJoinedByString:@","];
  74 +}
  75 +
49 76 #pragma mark -
50 77
51 78 @interface GBApplicationSettingsProvider ()
@@ -140,6 +167,7 @@ - (id)init {
140 167 self.docsetFallbackURL = @"";
141 168 self.docsetFeedName = self.docsetBundleName;
142 169 self.docsetFeedURL = @"";
  170 + self.docsetFeedFormats = GBPublishedFeedFormatAtom;
143 171 self.docsetPackageURL = @"";
144 172 self.docsetMinimumXcodeVersion = @"3.0";
145 173 self.dashDocsetPlatformFamily = @"appledoc"; // this makes docset TOC usable from within Dash - http://kapeli.com/dash/
@@ -150,7 +178,8 @@ - (id)init {
150 178
151 179 self.docsetBundleFilename = [NSString stringWithFormat:@"%@.%@.docset", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
152 180 self.docsetAtomFilename = [NSString stringWithFormat:@"%@.%@.atom", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
153   - self.docsetPackageFilename = [NSString stringWithFormat:@"%@.%@-%@.xar", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID, kGBTemplatePlaceholderVersionID];
  181 + self.docsetXMLFilename = [NSString stringWithFormat:@"%@.%@.xml", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
  182 + self.docsetPackageFilename = [NSString stringWithFormat:@"%@.%@-%@", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID, kGBTemplatePlaceholderVersionID];
154 183
155 184 self.commentComponents = [GBCommentComponentsProvider provider];
156 185 self.stringTemplates = [GBApplicationStringsProvider provider];
@@ -167,6 +196,7 @@ - (void)replaceAllOccurencesOfPlaceholderStringsInSettingsValues {
167 196 // These need to be replaced first as they can be used in other settings!
168 197 self.docsetBundleFilename = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetBundleFilename];
169 198 self.docsetAtomFilename = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetAtomFilename];
  199 + self.docsetXMLFilename = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetXMLFilename];
170 200 self.docsetPackageFilename = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetPackageFilename];
171 201 // Handle the rest now.
172 202 self.docsetBundleIdentifier = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetBundleIdentifier];
@@ -548,6 +578,7 @@ - (NSString *)stringByReplacingOccurencesOfPlaceholdersInString:(NSString *)stri
548 578 string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderVersion withString:self.projectVersion];
549 579 string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetBundleFilename withString:self.docsetBundleFilename];
550 580 string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetAtomFilename withString:self.docsetAtomFilename];
  581 + string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetXMLFilename withString:self.docsetXMLFilename];
551 582 string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetPackageFilename withString:self.docsetPackageFilename];
552 583 string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderYear withString:[self yearStringFromDate:[NSDate date]]];
553 584 string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderUpdateDate withString:[self yearToDayStringFromDate:[NSDate date]]];
@@ -614,6 +645,7 @@ - (NSString *)versionIdentifier {
614 645 @synthesize docsetFallbackURL;
615 646 @synthesize docsetFeedName;
616 647 @synthesize docsetFeedURL;
  648 +@synthesize docsetFeedFormats;
617 649 @synthesize docsetPackageURL;
618 650 @synthesize docsetMinimumXcodeVersion;
619 651 @synthesize dashDocsetPlatformFamily;
@@ -624,6 +656,7 @@ - (NSString *)versionIdentifier {
624 656
625 657 @synthesize docsetBundleFilename;
626 658 @synthesize docsetAtomFilename;
  659 +@synthesize docsetXMLFilename;
627 660 @synthesize docsetPackageFilename;
628 661
629 662 @synthesize repeatFirstParagraphForMemberDescription;
1  Generating/GBDocSetOutputGenerator.m
@@ -104,6 +104,7 @@ - (BOOL)processInfoPlist:(NSError **)error {
104 104 addVarUnlessEmpty(self.settings.docsetFallbackURL, @"fallbackURL");
105 105 addVarUnlessEmpty(self.settings.docsetFeedName, @"feedName");
106 106 addVarUnlessEmpty(self.settings.docsetFeedURL, @"feedURL");
  107 + addVarUnlessEmpty(NSStringFromGBPublishedFeedFormats(self.settings.docsetFeedFormats), @"feedFormats");
107 108 addVarUnlessEmpty(self.settings.docsetMinimumXcodeVersion, @"minimumXcodeVersion");
108 109 addVarUnlessEmpty(self.settings.docsetPlatformFamily, @"platformFamily");
109 110 addVarUnlessEmpty(self.settings.docsetPublisherIdentifier, @"publisherIdentifier");
115 Generating/GBDocSetPublishGenerator.m
@@ -28,8 +28,9 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error {
28 28
29 29 // Get the path to the installed documentation set and extract the name. Then replace the name's extension with .xar.
30 30 NSString *inputDocSetPath = self.inputUserPath;
31   - NSString *packageName = self.settings.docsetPackageFilename;
  31 + NSString *packageName = [self.settings.docsetPackageFilename stringByDeletingPathExtension];
32 32 NSString *atomName = self.settings.docsetAtomFilename;
  33 + NSString *xmlName = self.settings.docsetXMLFilename;
33 34 NSString *installedDocSetPath = inputDocSetPath;
34 35
35 36 // If installation was skipped, move the docset folder to a .docset bundle.
@@ -47,9 +48,22 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error {
47 48 NSString *outputDir = self.outputUserPath;
48 49 NSString *outputDocSetPath = [outputDir stringByAppendingPathComponent:packageName];
49 50 NSString *outputAtomPath = [outputDir stringByAppendingPathComponent:atomName];
  51 + NSString *outputXMLPath = [outputDir stringByAppendingPathComponent:xmlName];
50 52 NSString *signer = self.settings.docsetCertificateSigner;
51 53 NSString *url = self.settings.docsetPackageURL;
52   - if ([url length] == 0) GBLogWarn(@"--docset-package-url is required for publishing DocSet; placeholder will be used in '%@'!", outputAtomPath);
  54 + //TODO: Check for export formats and show this one in this message
  55 +
  56 + NSString *outputPaths = @"";
  57 + if(self.settings.docsetFeedFormats & GBPublishedFeedFormatAtom)
  58 + {
  59 + outputPaths = [outputPaths stringByAppendingString:outputAtomPath];
  60 + }
  61 + if(self.settings.docsetFeedFormats & GBPublishedFeedFormatXML)
  62 + {
  63 + outputPaths = [outputPaths stringByAppendingString:outputXMLPath];
  64 + }
  65 +
  66 + if ([url length] == 0) GBLogWarn(@"--docset-package-url is required for publishing DocSet; placeholder will be used in '%@'!", outputPaths);
53 67
54 68 // Create destination directory.
55 69 if (![self initializeDirectoryAtPath:outputDir preserve:[NSArray arrayWithObject:atomName] error:error]) {
@@ -57,33 +71,76 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error {
57 71 return NO;
58 72 }
59 73
60   - // Create command line arguments array.
61   - NSMutableArray *args = [NSMutableArray array];
62   - [args addObject:@"docsetutil"];
63   - [args addObject:@"package"];
64   - [args addObject:@"-output"];
65   - [args addObject:[outputDocSetPath stringByStandardizingPath]];
66   - [args addObject:@"-atom"];
67   - [args addObject:[outputAtomPath stringByStandardizingPath]];
68   - if ([signer length] > 0) {
69   - [args addObject:@"-signid"];
70   - [args addObject:signer];
71   - }
72   - if ([url length] > 0) {
73   - [args addObject:@"-download-url"];
74   - [args addObject:url];
75   - }
76   - [args addObject:installedDocSetPath];
77   -
78   - // Run the task.
79   - BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) {
80   - if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]);
81   - if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]);
82   - }];
83   - if (!result) {
84   - if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"docsetutil failed to package the documentation set!" reason:task.lastStandardError];
85   - return NO;
86   - }
  74 + if(self.settings.docsetFeedFormats & GBPublishedFeedFormatAtom)
  75 + {
  76 + // Create command line arguments array.
  77 + NSMutableArray *args = [NSMutableArray array];
  78 + [args addObject:@"docsetutil"];
  79 + [args addObject:@"package"];
  80 + [args addObject:@"-output"];
  81 + [args addObject:[[outputDocSetPath stringByStandardizingPath] stringByAppendingString:@".xar"]];
  82 + [args addObject:@"-atom"];
  83 + [args addObject:[outputAtomPath stringByStandardizingPath]];
  84 + if ([signer length] > 0) {
  85 + [args addObject:@"-signid"];
  86 + [args addObject:signer];
  87 + }
  88 + if ([url length] > 0) {
  89 + [args addObject:@"-download-url"];
  90 + [args addObject:url];
  91 + }
  92 + [args addObject:installedDocSetPath];
  93 +
  94 + // Run the task.
  95 + BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) {
  96 + if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]);
  97 + if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]);
  98 + }];
  99 + if (!result) {
  100 + if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"docsetutil failed to package the documentation set!" reason:task.lastStandardError];
  101 + return NO;
  102 + }
  103 + }
  104 +
  105 + if(self.settings.docsetFeedFormats & GBPublishedFeedFormatXML)
  106 + {
  107 + NSMutableArray *args = [NSMutableArray array];
  108 + [args addObject:@"tar"];
  109 + [args addObject:@"--exclude"];
  110 + [args addObject:@".DS_Store"];
  111 + [args addObject:@"-czPf"];
  112 + [args addObject:[[outputDocSetPath stringByStandardizingPath] stringByAppendingString:@".tgz"]];
  113 + [args addObject:installedDocSetPath];
  114 +
  115 + // Run the task.
  116 + BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) {
  117 + if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]);
  118 + if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]);
  119 + }];
  120 + if (!result) {
  121 + if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"tar failed to package the documentation set!" reason:task.lastStandardError];
  122 + return NO;
  123 + }
  124 +
  125 + NSString *xmlTemplatePath = [[NSString stringWithFormat:@"%@/%@", [self templateUserPath], [self templatePathForTemplateEndingWith:@"xml-template.xml"]] stringByExpandingTildeInPath];
  126 +
  127 + NSString *xmlString = [NSString stringWithContentsOfFile:xmlTemplatePath encoding:NSUTF8StringEncoding error:error];
  128 +
  129 + if(!xmlString)
  130 + {
  131 + if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:[NSString stringWithFormat:@"failed to read the xml template document in %@!", xmlTemplatePath] reason:task.lastStandardError];
  132 + return NO;
  133 + }
  134 + xmlString = [xmlString stringByReplacingOccurrencesOfString:@"${DOCSET_FEED_URL}" withString:self.settings.docsetFeedURL];
  135 + xmlString = [xmlString stringByReplacingOccurrencesOfString:@"${DOCSET_FEED_VERSION}" withString:self.settings.projectVersion];
  136 + result = [self writeString:xmlString toFile:[outputXMLPath stringByStandardizingPath] error:error];
  137 + if(!result)
  138 + {
  139 + if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"failed to write the xml feed!" reason:task.lastStandardError];
  140 + return NO;
  141 + }
  142 + }
  143 +
87 144 return YES;
88 145 }
89 146
4 Templates/publish/xml-template.xml
... ... @@ -0,0 +1,4 @@
  1 +<entry>
  2 + <version>${DOCSET_FEED_VERSION}</version>
  3 + <url>${DOCSET_FEED_URL}</url>
  4 +</entry>
9 Testing/GBApplicationSettingsProviderTesting.m
@@ -36,6 +36,7 @@ - (void)testPlaceholderReplacements_shouldReplacePlaceholderStringsInAllSupporte
36 36 settings.docsetFallbackURL = template;
37 37 settings.docsetFeedName = template;
38 38 settings.docsetFeedURL = template;
  39 + settings.docsetFeedFormats = template;
39 40 settings.docsetPackageURL = template;
40 41 settings.docsetMinimumXcodeVersion = template;
41 42 settings.docsetPlatformFamily = template;
@@ -44,6 +45,7 @@ - (void)testPlaceholderReplacements_shouldReplacePlaceholderStringsInAllSupporte
44 45 settings.docsetCopyrightMessage = template;
45 46 settings.docsetBundleFilename = template;
46 47 settings.docsetAtomFilename = template;
  48 + settings.docsetXMLFilename = template;
47 49 settings.docsetPackageFilename = template;
48 50 // setup expected values; this might break sometimes as it's based on time...
49 51 NSDate *date = [NSDate date];
@@ -61,6 +63,7 @@ - (void)testPlaceholderReplacements_shouldReplacePlaceholderStringsInAllSupporte
61 63 assertThat(settings.docsetFallbackURL, is(expected));
62 64 assertThat(settings.docsetFeedName, is(expected));
63 65 assertThat(settings.docsetFeedURL, is(expected));
  66 + assertThat(settings.docsetFeedFormats, is(expected));
64 67 assertThat(settings.docsetPackageURL, is(expected));
65 68 assertThat(settings.docsetMinimumXcodeVersion, is(expected));
66 69 assertThat(settings.docsetPlatformFamily, is(expected));
@@ -69,6 +72,7 @@ - (void)testPlaceholderReplacements_shouldReplacePlaceholderStringsInAllSupporte
69 72 assertThat(settings.docsetCopyrightMessage, is(expected));
70 73 assertThat(settings.docsetBundleFilename, is(expected));
71 74 assertThat(settings.docsetAtomFilename, is(expected));
  75 + assertThat(settings.docsetXMLFilename, is(expected));
72 76 assertThat(settings.docsetPackageFilename, is(expected));
73 77 }
74 78
@@ -81,8 +85,9 @@ - (void)testPlaceholderReplacements_shouldReplaceDocSetFilenames {
81 85 settings.companyIdentifier = @"<CI>";
82 86 settings.docsetBundleFilename = @"<DSB>";
83 87 settings.docsetAtomFilename = @"<DSA>";
  88 + settings.docsetXMLFilename = @"<DSA>";
84 89 settings.docsetPackageFilename = @"<DSP>";
85   - NSString *template = @"%DOCSETBUNDLEFILENAME/%DOCSETATOMFILENAME/%DOCSETPACKAGEFILENAME";
  90 + NSString *template = @"%DOCSETBUNDLEFILENAME/%DOCSETATOMFILENAME/%DOCSETXMLFILENAME/%DOCSETPACKAGEFILENAME";
86 91 settings.docsetBundleIdentifier = template;
87 92 settings.docsetBundleName = template;
88 93 settings.docsetCertificateIssuer = template;
@@ -91,6 +96,7 @@ - (void)testPlaceholderReplacements_shouldReplaceDocSetFilenames {
91 96 settings.docsetFallbackURL = template;
92 97 settings.docsetFeedName = template;
93 98 settings.docsetFeedURL = template;
  99 + settings.docsetFeedFormats = template;
94 100 settings.docsetPackageURL = template;
95 101 settings.docsetMinimumXcodeVersion = template;
96 102 settings.docsetPlatformFamily = template;
@@ -109,6 +115,7 @@ - (void)testPlaceholderReplacements_shouldReplaceDocSetFilenames {
109 115 assertThat(settings.docsetFallbackURL, is(expected));
110 116 assertThat(settings.docsetFeedName, is(expected));
111 117 assertThat(settings.docsetFeedURL, is(expected));
  118 + assertThat(settings.docsetFeedFormats, is(expected));
112 119 assertThat(settings.docsetPackageURL, is(expected));
113 120 assertThat(settings.docsetMinimumXcodeVersion, is(expected));
114 121 assertThat(settings.docsetPlatformFamily, is(expected));
15 Testing/GBApplicationTesting.m
@@ -463,6 +463,14 @@ - (void)testDocSetFeedURL_shouldAssignValueToSettings {
463 463 assertThat(settings.docsetFeedURL, is(@"value"));
464 464 }
465 465
  466 +- (void)testDocSetFeedFormat_shouldAssignValueToSettings {
  467 +
  468 + // setup & execute
  469 + GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docset-feed-formats", @"value", nil];
  470 + // verify
  471 + assertThat(settings.docsetFeedFormats, is(@"value"));
  472 +}
  473 +
466 474 - (void)testDocSetPackageURL_shouldAssignValueToSettings {
467 475 // setup & execute
468 476 GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docset-package-url", @"value", nil];
@@ -533,6 +541,13 @@ - (void)testDocSetAtomFilename_shouldAssignValueToSettings {
533 541 assertThat(settings.docsetAtomFilename, is(@"value"));
534 542 }
535 543
  544 +- (void)testDocSetXMLFilename_shouldAssignValueToSettings {
  545 + // setup & execute
  546 + GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docset-xml-filename", @"value", nil];
  547 + // verify
  548 + assertThat(settings.docsetXMLFilename, is(@"value"));
  549 +}
  550 +
536 551 - (void)testDocSetPackageFilename_shouldAssignValueToSettings {
537 552 // setup & execute
538 553 GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docset-package-filename", @"value", nil];
2  appledoc.xcodeproj/project.pbxproj
@@ -549,6 +549,7 @@
549 549 B4D1FFD415FF5F05009736E2 /* DDXcodeProjectFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDXcodeProjectFile.m; sourceTree = "<group>"; };
550 550 B4D1FFF215FF633F009736E2 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
551 551 B4D1FFF615FF643D009736E2 /* install-appledoc.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "install-appledoc.sh"; sourceTree = "<group>"; };
  552 + F59056EC16C1C6DC00391620 /* publish */ = {isa = PBXFileReference; lastKnownFileType = folder; path = publish; sourceTree = "<group>"; };
552 553 /* End PBXFileReference section */
553 554
554 555 /* Begin PBXFrameworksBuildPhase section */
@@ -736,6 +737,7 @@
736 737 739AD36F1254449D00B642C3 /* Templates */ = {
737 738 isa = PBXGroup;
738 739 children = (
  740 + F59056EC16C1C6DC00391620 /* publish */,
739 741 7367298112A3BD9D00879D1B /* docset */,
740 742 73D2524312A2EA340024F9F9 /* html */,
741 743 );

0 comments on commit 75a3907

Please sign in to comment.
Something went wrong with that request. Please try again.