Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding support for multiple feed formats #309

Merged
merged 2 commits into from

2 participants

@bjtitus

This is some initial support for adding Dash xml feed generation (#307). 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.

Basically, I've added a --docset-feed-formats which currently takes a series separated by commas with current types being atom and xml. and --docset-xml-filename to allow users to specify multiple feed formats and the corresponding filename to go with the xml feed. It might be better to just have a --docset-feed-filename and append the extension according to the format.

The other change is related to the --docset-package-filename which will now ignore the path extension and create the file with the appropriate extension depending on which format is being output. I realize this might cause issues if people are relying on being able to change the extension through this argument but this seemed like the best way to do it without adding filenames for each format.

The xml file template Templates/publish/xml-template.xml allows users to create their own templates in case Dash or anyone else has a different format. I thought this should be made available since it's mostly static anyway.

I'm not totally sold on how it's recognizing the feed formats but I think it's better than nothing.

This will default to Atom so that existing functionality will work.

bjtitus added some commits
@bjtitus bjtitus 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.
75a3907
@bjtitus bjtitus Removing old todo and displaying proper output paths f5c9ef1
@tomaz
Owner

Cool, thanks! Merging it right away...

@tomaz tomaz merged commit 3377667 into tomaz:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 6, 2013
  1. @bjtitus

    Adding support for generating Dash's xml format #307

    bjtitus authored
    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.
  2. @bjtitus
This page is out of date. Refresh to see the latest.
View
14 Application/GBAppledocApplication.m
@@ -73,6 +73,7 @@
static NSString *kGBArgDocSetCopyrightMessage = @"docset-copyright";
static NSString *kGBArgDocSetFeedName = @"docset-feed-name";
static NSString *kGBArgDocSetFeedURL = @"docset-feed-url";
+static NSString *kGBArgDocSetFeedFormats = @"docset-feed-formats";
static NSString *kGBArgDocSetPackageURL = @"docset-package-url";
static NSString *kGBArgDocSetFallbackURL = @"docset-fallback-url";
static NSString *kGBArgDocSetPublisherIdentifier = @"docset-publisher-id";
@@ -85,6 +86,7 @@
static NSString *kGBArgDocSetBundleFilename = @"docset-bundle-filename";
static NSString *kGBArgDocSetAtomFilename = @"docset-atom-filename";
+static NSString *kGBArgDocSetXMLFilename = @"docset-xml-filename";
static NSString *kGBArgDocSetPackageFilename = @"docset-package-filename";
static NSString *kGBArgLogFormat = @"logformat";
@@ -250,6 +252,7 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
{ kGBArgDocSetFallbackURL, 0, DDGetoptRequiredArgument },
{ kGBArgDocSetFeedName, 0, DDGetoptRequiredArgument },
{ kGBArgDocSetFeedURL, 0, DDGetoptRequiredArgument },
+ { kGBArgDocSetFeedFormats, 0, DDGetoptRequiredArgument },
{ kGBArgDocSetPackageURL, 0, DDGetoptRequiredArgument },
{ kGBArgDocSetMinimumXcodeVersion, 0, DDGetoptRequiredArgument },
{ kGBArgDocSetPlatformFamily, 0, DDGetoptRequiredArgument },
@@ -260,6 +263,7 @@ - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser
{ kGBArgDocSetBundleFilename, 0, DDGetoptRequiredArgument },
{ kGBArgDocSetAtomFilename, 0, DDGetoptRequiredArgument },
+ { kGBArgDocSetXMLFilename, 0, DDGetoptRequiredArgument },
{ kGBArgDocSetPackageFilename, 0, DDGetoptRequiredArgument },
{ kGBArgCleanOutput, 0, DDGetoptNoArgument },
@@ -831,6 +835,9 @@ - (void)setDocsetDesc:(NSString *)value { self.settings.docsetDescription = valu
- (void)setDocsetCopyright:(NSString *)value { self.settings.docsetCopyrightMessage = value; }
- (void)setDocsetFeedName:(NSString *)value { self.settings.docsetFeedName = value; }
- (void)setDocsetFeedUrl:(NSString *)value { self.settings.docsetFeedURL = value; }
+- (void)setDocsetFeedFormats:(NSString *)value {
+ self.settings.docsetFeedFormats = GBPublishedFeedFormatsFromNSString(value);
+}
- (void)setDocsetPackageUrl:(NSString *)value { self.settings.docsetPackageURL = value; }
- (void)setDocsetFallbackUrl:(NSString *)value { self.settings.docsetFallbackURL = value; }
- (void)setDocsetPublisherId:(NSString *)value { self.settings.docsetPublisherIdentifier = value; }
@@ -843,6 +850,7 @@ - (void)setDashPlatformFamily:(NSString *)value { self.settings.dashDocsetPlatfo
- (void)setDocsetBundleFilename:(NSString *)value { self.settings.docsetBundleFilename = value; }
- (void)setDocsetAtomFilename:(NSString *)value { self.settings.docsetAtomFilename = value; }
+- (void)setDocsetXMLFilename:(NSString *)value { self.settings.docsetXMLFilename = value; }
- (void)setDocsetPackageFilename:(NSString *)value { self.settings.docsetPackageFilename = value; }
@synthesize additionalInputPaths;
@@ -894,6 +902,7 @@ - (void)printSettingsAndArguments:(NSArray *)arguments {
ddprintf(@"--%@ = %@\n", kGBArgDocSetCopyrightMessage, self.settings.docsetCopyrightMessage);
ddprintf(@"--%@ = %@\n", kGBArgDocSetFeedName, self.settings.docsetFeedName);
ddprintf(@"--%@ = %@\n", kGBArgDocSetFeedURL, self.settings.docsetFeedURL);
+ ddprintf(@"--%@ = %@\n", kGBArgDocSetFeedFormats, NSStringFromGBPublishedFeedFormats(self.settings.docsetFeedFormats));
ddprintf(@"--%@ = %@\n", kGBArgDocSetPackageURL, self.settings.docsetPackageURL);
ddprintf(@"--%@ = %@\n", kGBArgDocSetFallbackURL, self.settings.docsetFallbackURL);
ddprintf(@"--%@ = %@\n", kGBArgDocSetPublisherIdentifier, self.settings.docsetPublisherIdentifier);
@@ -904,6 +913,7 @@ - (void)printSettingsAndArguments:(NSArray *)arguments {
ddprintf(@"--%@ = %@\n", kGBArgDocSetCertificateSigner, self.settings.docsetCertificateSigner);
ddprintf(@"--%@ = %@\n", kGBArgDocSetBundleFilename, self.settings.docsetBundleFilename);
ddprintf(@"--%@ = %@\n", kGBArgDocSetAtomFilename, self.settings.docsetAtomFilename);
+ ddprintf(@"--%@ = %@\n", kGBArgDocSetXMLFilename, self.settings.docsetXMLFilename);
ddprintf(@"--%@ = %@\n", kGBArgDocSetPackageFilename, self.settings.docsetPackageFilename);
ddprintf(@"\n");
@@ -1014,6 +1024,7 @@ - (void)printHelp {
PRINT_USAGE(@" ", kGBArgDocSetCopyrightMessage, @"<string>", @"[*] DocSet copyright message");
PRINT_USAGE(@" ", kGBArgDocSetFeedName, @"<string>", @"[*] DocSet feed name");
PRINT_USAGE(@" ", kGBArgDocSetFeedURL, @"<string>", @"[*] DocSet feed URL");
+ PRINT_USAGE(@" ", kGBArgDocSetFeedFormats, @"<values>", @"[*] DocSet feed formats. Separated by a comma [atom,xml]");
PRINT_USAGE(@" ", kGBArgDocSetPackageURL, @"<string>", @"[*] DocSet package (.xar) URL");
PRINT_USAGE(@" ", kGBArgDocSetFallbackURL, @"<string>", @"[*] DocSet fallback URL");
PRINT_USAGE(@" ", kGBArgDocSetPublisherIdentifier, @"<string>", @"[*] DocSet publisher identifier");
@@ -1024,7 +1035,8 @@ - (void)printHelp {
PRINT_USAGE(@" ", kGBArgDocSetCertificateSigner, @"<string>", @"[*] DocSet certificate signer");
PRINT_USAGE(@" ", kGBArgDocSetBundleFilename, @"<string>", @"[*] DocSet bundle filename");
PRINT_USAGE(@" ", kGBArgDocSetAtomFilename, @"<string>", @"[*] DocSet atom feed filename");
- PRINT_USAGE(@" ", kGBArgDocSetPackageFilename, @"<string>", @"[*] DocSet package (.xar) filename");
+ PRINT_USAGE(@" ", kGBArgDocSetXMLFilename, @"<string>", @"[*] DocSet xml feed filename");
+ PRINT_USAGE(@" ", kGBArgDocSetPackageFilename, @"<string>", @"[*] DocSet package (.xar,.tgz) filename. Leave off the extension. This will be added depending on the generated package.");
ddprintf(@"\n");
ddprintf(@"MISCELLANEOUS\n");
PRINT_USAGE(@" ", kGBArgLogFormat, @"<number>", @"Log format [0-3]");
View
26 Application/GBApplicationSettingsProvider.h
@@ -22,6 +22,15 @@ typedef enum
GBHTMLAnchorFormat GBHTMLAnchorFormatFromNSString(NSString *formatString);
NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
+typedef enum
+{
+ GBPublishedFeedFormatAtom = 1,
+ GBPublishedFeedFormatXML = 2
+} GBPublishedFeedFormats;
+
+GBPublishedFeedFormats GBPublishedFeedFormatsFromNSString(NSString *formatString);
+NSString *NSStringFromGBPublishedFeedFormats(GBPublishedFeedFormats format);
+
#pragma mark -
/** Main application settings provider.
@@ -104,6 +113,18 @@ NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
/** Documentation set feed URL. */
@property (copy) NSString *docsetFeedURL;
+/** Specifies the format docsets should be published in.
+
+ If `atom`, docset will be published using the standard Xcode atom feed format
+
+ If `xml`, docset will be published using the xml format specified by the xml-template.xml found in Templates/publish
+
+ Multiple values can be included in this parameter separated by a comma
+
+ @see publishDocSet
+ */
+@property (assign) GBPublishedFeedFormats docsetFeedFormats;
+
/** Documentation set package URL. */
@property (copy) NSString *docsetPackageURL;
@@ -131,6 +152,9 @@ NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
/** The name of the documentation set atom file when generating publishing files. The file is generated in `outputPath`. */
@property (copy) NSString *docsetAtomFilename;
+/** The name of the documentation set xml file when generating publishing files. The file is generated in `outputPath`. */
+@property (copy) NSString *docsetXMLFilename;
+
/** The name of the documentation set compressed package file when generating publishing files. The file is generated in `outputPath`. */
@property (copy) NSString *docsetPackageFilename;
@@ -637,6 +661,7 @@ NSString *NSStringFromGBHTMLAnchorFormat(GBHTMLAnchorFormat format);
- `%VERSIONID`: Replaced by `versionIdentifier` value.
- `%DOCSETBUNDLEFILENAME`: Replaced by `docsetBundleFilename` value.
- `%DOCSETATOMFILENAME`: Replaced by `docsetAtomFilename` value.
+ - `%DOCSETXMLFILENAME`: Replaced by `docsetXMLFilename` value.
- `%DOCSETPACKAGEFILENAME`: Replaced by `docsetPackageFilename` value.
- `%YEAR`: Replaced by current year as four digit string.
- `%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;
extern NSString *kGBTemplatePlaceholderVersion;
extern NSString *kGBTemplatePlaceholderDocSetBundleFilename;
extern NSString *kGBTemplatePlaceholderDocSetAtomFilename;
+extern NSString *kGBTemplatePlaceholderDocSetXMLFilename;
extern NSString *kGBTemplatePlaceholderDocSetPackageFilename;
extern NSString *kGBTemplatePlaceholderYear;
extern NSString *kGBTemplatePlaceholderUpdateDate;
View
35 Application/GBApplicationSettingsProvider.m
@@ -22,6 +22,7 @@
NSString *kGBTemplatePlaceholderVersion = @"%VERSION";
NSString *kGBTemplatePlaceholderDocSetBundleFilename = @"%DOCSETBUNDLEFILENAME";
NSString *kGBTemplatePlaceholderDocSetAtomFilename = @"%DOCSETATOMFILENAME";
+NSString *kGBTemplatePlaceholderDocSetXMLFilename = @"%DOCSETXMLFILENAME";
NSString *kGBTemplatePlaceholderDocSetPackageFilename = @"%DOCSETPACKAGEFILENAME";
NSString *kGBTemplatePlaceholderYear = @"%YEAR";
NSString *kGBTemplatePlaceholderUpdateDate = @"%UPDATEDATE";
@@ -46,6 +47,32 @@ GBHTMLAnchorFormat GBHTMLAnchorFormatFromNSString(NSString *formatString) {
}
}
+GBPublishedFeedFormats GBPublishedFeedFormatsFromNSString(NSString *formatString) {
+ // These items are comma delimited
+ NSArray *formatItems = [[formatString lowercaseString] componentsSeparatedByString:@","];
+ GBPublishedFeedFormats formats;
+ if ([formatItems containsObject:@"xml"]) {
+ formats = formats | GBPublishedFeedFormatXML;
+ }
+ if ([formatItems containsObject:@"atom"]) {
+ formats = formats | GBPublishedFeedFormatAtom;
+ }
+ return formats;
+}
+
+NSString *NSStringFromGBPublishedFeedFormats(GBPublishedFeedFormats formats) {
+ NSMutableArray *formatItems = [NSMutableArray array];
+ if(formats & GBPublishedFeedFormatAtom)
+ {
+ [formatItems addObject:@"atom"];
+ }
+ if(formats & GBPublishedFeedFormatXML)
+ {
+ [formatItems addObject:@"xml"];
+ }
+ return [formatItems componentsJoinedByString:@","];
+}
+
#pragma mark -
@interface GBApplicationSettingsProvider ()
@@ -140,6 +167,7 @@ - (id)init {
self.docsetFallbackURL = @"";
self.docsetFeedName = self.docsetBundleName;
self.docsetFeedURL = @"";
+ self.docsetFeedFormats = GBPublishedFeedFormatAtom;
self.docsetPackageURL = @"";
self.docsetMinimumXcodeVersion = @"3.0";
self.dashDocsetPlatformFamily = @"appledoc"; // this makes docset TOC usable from within Dash - http://kapeli.com/dash/
@@ -150,7 +178,8 @@ - (id)init {
self.docsetBundleFilename = [NSString stringWithFormat:@"%@.%@.docset", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
self.docsetAtomFilename = [NSString stringWithFormat:@"%@.%@.atom", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
- self.docsetPackageFilename = [NSString stringWithFormat:@"%@.%@-%@.xar", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID, kGBTemplatePlaceholderVersionID];
+ self.docsetXMLFilename = [NSString stringWithFormat:@"%@.%@.xml", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID];
+ self.docsetPackageFilename = [NSString stringWithFormat:@"%@.%@-%@", kGBTemplatePlaceholderCompanyID, kGBTemplatePlaceholderProjectID, kGBTemplatePlaceholderVersionID];
self.commentComponents = [GBCommentComponentsProvider provider];
self.stringTemplates = [GBApplicationStringsProvider provider];
@@ -167,6 +196,7 @@ - (void)replaceAllOccurencesOfPlaceholderStringsInSettingsValues {
// These need to be replaced first as they can be used in other settings!
self.docsetBundleFilename = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetBundleFilename];
self.docsetAtomFilename = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetAtomFilename];
+ self.docsetXMLFilename = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetXMLFilename];
self.docsetPackageFilename = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetPackageFilename];
// Handle the rest now.
self.docsetBundleIdentifier = [self stringByReplacingOccurencesOfPlaceholdersInString:self.docsetBundleIdentifier];
@@ -548,6 +578,7 @@ - (NSString *)stringByReplacingOccurencesOfPlaceholdersInString:(NSString *)stri
string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderVersion withString:self.projectVersion];
string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetBundleFilename withString:self.docsetBundleFilename];
string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetAtomFilename withString:self.docsetAtomFilename];
+ string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetXMLFilename withString:self.docsetXMLFilename];
string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderDocSetPackageFilename withString:self.docsetPackageFilename];
string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderYear withString:[self yearStringFromDate:[NSDate date]]];
string = [string stringByReplacingOccurrencesOfString:kGBTemplatePlaceholderUpdateDate withString:[self yearToDayStringFromDate:[NSDate date]]];
@@ -614,6 +645,7 @@ - (NSString *)versionIdentifier {
@synthesize docsetFallbackURL;
@synthesize docsetFeedName;
@synthesize docsetFeedURL;
+@synthesize docsetFeedFormats;
@synthesize docsetPackageURL;
@synthesize docsetMinimumXcodeVersion;
@synthesize dashDocsetPlatformFamily;
@@ -624,6 +656,7 @@ - (NSString *)versionIdentifier {
@synthesize docsetBundleFilename;
@synthesize docsetAtomFilename;
+@synthesize docsetXMLFilename;
@synthesize docsetPackageFilename;
@synthesize repeatFirstParagraphForMemberDescription;
View
1  Generating/GBDocSetOutputGenerator.m
@@ -104,6 +104,7 @@ - (BOOL)processInfoPlist:(NSError **)error {
addVarUnlessEmpty(self.settings.docsetFallbackURL, @"fallbackURL");
addVarUnlessEmpty(self.settings.docsetFeedName, @"feedName");
addVarUnlessEmpty(self.settings.docsetFeedURL, @"feedURL");
+ addVarUnlessEmpty(NSStringFromGBPublishedFeedFormats(self.settings.docsetFeedFormats), @"feedFormats");
addVarUnlessEmpty(self.settings.docsetMinimumXcodeVersion, @"minimumXcodeVersion");
addVarUnlessEmpty(self.settings.docsetPlatformFamily, @"platformFamily");
addVarUnlessEmpty(self.settings.docsetPublisherIdentifier, @"publisherIdentifier");
View
114 Generating/GBDocSetPublishGenerator.m
@@ -28,8 +28,9 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error {
// Get the path to the installed documentation set and extract the name. Then replace the name's extension with .xar.
NSString *inputDocSetPath = self.inputUserPath;
- NSString *packageName = self.settings.docsetPackageFilename;
+ NSString *packageName = [self.settings.docsetPackageFilename stringByDeletingPathExtension];
NSString *atomName = self.settings.docsetAtomFilename;
+ NSString *xmlName = self.settings.docsetXMLFilename;
NSString *installedDocSetPath = inputDocSetPath;
// If installation was skipped, move the docset folder to a .docset bundle.
@@ -47,9 +48,21 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error {
NSString *outputDir = self.outputUserPath;
NSString *outputDocSetPath = [outputDir stringByAppendingPathComponent:packageName];
NSString *outputAtomPath = [outputDir stringByAppendingPathComponent:atomName];
+ NSString *outputXMLPath = [outputDir stringByAppendingPathComponent:xmlName];
NSString *signer = self.settings.docsetCertificateSigner;
NSString *url = self.settings.docsetPackageURL;
- if ([url length] == 0) GBLogWarn(@"--docset-package-url is required for publishing DocSet; placeholder will be used in '%@'!", outputAtomPath);
+
+ NSMutableArray *outputPaths = [NSMutableArray arrayWithCapacity:2];
+ if(self.settings.docsetFeedFormats & GBPublishedFeedFormatAtom)
+ {
+ [outputPaths addObject:outputAtomPath];
+ }
+ if(self.settings.docsetFeedFormats & GBPublishedFeedFormatXML)
+ {
+ [outputPaths addObject:outputXMLPath];
+ }
+
+ if ([url length] == 0) GBLogWarn(@"--docset-package-url is required for publishing DocSet; placeholder will be used in '%@'!", [outputPaths componentsJoinedByString:@", "]);
// Create destination directory.
if (![self initializeDirectoryAtPath:outputDir preserve:[NSArray arrayWithObject:atomName] error:error]) {
@@ -57,33 +70,76 @@ - (BOOL)generateOutputWithStore:(id)store error:(NSError **)error {
return NO;
}
- // Create command line arguments array.
- NSMutableArray *args = [NSMutableArray array];
- [args addObject:@"docsetutil"];
- [args addObject:@"package"];
- [args addObject:@"-output"];
- [args addObject:[outputDocSetPath stringByStandardizingPath]];
- [args addObject:@"-atom"];
- [args addObject:[outputAtomPath stringByStandardizingPath]];
- if ([signer length] > 0) {
- [args addObject:@"-signid"];
- [args addObject:signer];
- }
- if ([url length] > 0) {
- [args addObject:@"-download-url"];
- [args addObject:url];
- }
- [args addObject:installedDocSetPath];
-
- // Run the task.
- BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) {
- if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]);
- if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]);
- }];
- if (!result) {
- if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"docsetutil failed to package the documentation set!" reason:task.lastStandardError];
- return NO;
- }
+ if(self.settings.docsetFeedFormats & GBPublishedFeedFormatAtom)
+ {
+ // Create command line arguments array.
+ NSMutableArray *args = [NSMutableArray array];
+ [args addObject:@"docsetutil"];
+ [args addObject:@"package"];
+ [args addObject:@"-output"];
+ [args addObject:[[outputDocSetPath stringByStandardizingPath] stringByAppendingString:@".xar"]];
+ [args addObject:@"-atom"];
+ [args addObject:[outputAtomPath stringByStandardizingPath]];
+ if ([signer length] > 0) {
+ [args addObject:@"-signid"];
+ [args addObject:signer];
+ }
+ if ([url length] > 0) {
+ [args addObject:@"-download-url"];
+ [args addObject:url];
+ }
+ [args addObject:installedDocSetPath];
+
+ // Run the task.
+ BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) {
+ if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]);
+ if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]);
+ }];
+ if (!result) {
+ if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"docsetutil failed to package the documentation set!" reason:task.lastStandardError];
+ return NO;
+ }
+ }
+
+ if(self.settings.docsetFeedFormats & GBPublishedFeedFormatXML)
+ {
+ NSMutableArray *args = [NSMutableArray array];
+ [args addObject:@"tar"];
+ [args addObject:@"--exclude"];
+ [args addObject:@".DS_Store"];
+ [args addObject:@"-czPf"];
+ [args addObject:[[outputDocSetPath stringByStandardizingPath] stringByAppendingString:@".tgz"]];
+ [args addObject:installedDocSetPath];
+
+ // Run the task.
+ BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) {
+ if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]);
+ if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]);
+ }];
+ if (!result) {
+ if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"tar failed to package the documentation set!" reason:task.lastStandardError];
+ return NO;
+ }
+
+ NSString *xmlTemplatePath = [[NSString stringWithFormat:@"%@/%@", [self templateUserPath], [self templatePathForTemplateEndingWith:@"xml-template.xml"]] stringByExpandingTildeInPath];
+
+ NSString *xmlString = [NSString stringWithContentsOfFile:xmlTemplatePath encoding:NSUTF8StringEncoding error:error];
+
+ if(!xmlString)
+ {
+ if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:[NSString stringWithFormat:@"failed to read the xml template document in %@!", xmlTemplatePath] reason:task.lastStandardError];
+ return NO;
+ }
+ xmlString = [xmlString stringByReplacingOccurrencesOfString:@"${DOCSET_FEED_URL}" withString:self.settings.docsetFeedURL];
+ xmlString = [xmlString stringByReplacingOccurrencesOfString:@"${DOCSET_FEED_VERSION}" withString:self.settings.projectVersion];
+ result = [self writeString:xmlString toFile:[outputXMLPath stringByStandardizingPath] error:error];
+ if(!result)
+ {
+ if (error) *error = [NSError errorWithCode:GBErrorDocSetUtilIndexingFailed description:@"failed to write the xml feed!" reason:task.lastStandardError];
+ return NO;
+ }
+ }
+
return YES;
}
View
4 Templates/publish/xml-template.xml
@@ -0,0 +1,4 @@
+<entry>
+ <version>${DOCSET_FEED_VERSION}</version>
+ <url>${DOCSET_FEED_URL}</url>
+</entry>
View
9 Testing/GBApplicationSettingsProviderTesting.m
@@ -36,6 +36,7 @@ - (void)testPlaceholderReplacements_shouldReplacePlaceholderStringsInAllSupporte
settings.docsetFallbackURL = template;
settings.docsetFeedName = template;
settings.docsetFeedURL = template;
+ settings.docsetFeedFormats = template;
settings.docsetPackageURL = template;
settings.docsetMinimumXcodeVersion = template;
settings.docsetPlatformFamily = template;
@@ -44,6 +45,7 @@ - (void)testPlaceholderReplacements_shouldReplacePlaceholderStringsInAllSupporte
settings.docsetCopyrightMessage = template;
settings.docsetBundleFilename = template;
settings.docsetAtomFilename = template;
+ settings.docsetXMLFilename = template;
settings.docsetPackageFilename = template;
// setup expected values; this might break sometimes as it's based on time...
NSDate *date = [NSDate date];
@@ -61,6 +63,7 @@ - (void)testPlaceholderReplacements_shouldReplacePlaceholderStringsInAllSupporte
assertThat(settings.docsetFallbackURL, is(expected));
assertThat(settings.docsetFeedName, is(expected));
assertThat(settings.docsetFeedURL, is(expected));
+ assertThat(settings.docsetFeedFormats, is(expected));
assertThat(settings.docsetPackageURL, is(expected));
assertThat(settings.docsetMinimumXcodeVersion, is(expected));
assertThat(settings.docsetPlatformFamily, is(expected));
@@ -69,6 +72,7 @@ - (void)testPlaceholderReplacements_shouldReplacePlaceholderStringsInAllSupporte
assertThat(settings.docsetCopyrightMessage, is(expected));
assertThat(settings.docsetBundleFilename, is(expected));
assertThat(settings.docsetAtomFilename, is(expected));
+ assertThat(settings.docsetXMLFilename, is(expected));
assertThat(settings.docsetPackageFilename, is(expected));
}
@@ -81,8 +85,9 @@ - (void)testPlaceholderReplacements_shouldReplaceDocSetFilenames {
settings.companyIdentifier = @"<CI>";
settings.docsetBundleFilename = @"<DSB>";
settings.docsetAtomFilename = @"<DSA>";
+ settings.docsetXMLFilename = @"<DSA>";
settings.docsetPackageFilename = @"<DSP>";
- NSString *template = @"%DOCSETBUNDLEFILENAME/%DOCSETATOMFILENAME/%DOCSETPACKAGEFILENAME";
+ NSString *template = @"%DOCSETBUNDLEFILENAME/%DOCSETATOMFILENAME/%DOCSETXMLFILENAME/%DOCSETPACKAGEFILENAME";
settings.docsetBundleIdentifier = template;
settings.docsetBundleName = template;
settings.docsetCertificateIssuer = template;
@@ -91,6 +96,7 @@ - (void)testPlaceholderReplacements_shouldReplaceDocSetFilenames {
settings.docsetFallbackURL = template;
settings.docsetFeedName = template;
settings.docsetFeedURL = template;
+ settings.docsetFeedFormats = template;
settings.docsetPackageURL = template;
settings.docsetMinimumXcodeVersion = template;
settings.docsetPlatformFamily = template;
@@ -109,6 +115,7 @@ - (void)testPlaceholderReplacements_shouldReplaceDocSetFilenames {
assertThat(settings.docsetFallbackURL, is(expected));
assertThat(settings.docsetFeedName, is(expected));
assertThat(settings.docsetFeedURL, is(expected));
+ assertThat(settings.docsetFeedFormats, is(expected));
assertThat(settings.docsetPackageURL, is(expected));
assertThat(settings.docsetMinimumXcodeVersion, is(expected));
assertThat(settings.docsetPlatformFamily, is(expected));
View
15 Testing/GBApplicationTesting.m
@@ -463,6 +463,14 @@ - (void)testDocSetFeedURL_shouldAssignValueToSettings {
assertThat(settings.docsetFeedURL, is(@"value"));
}
+- (void)testDocSetFeedFormat_shouldAssignValueToSettings {
+
+ // setup & execute
+ GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docset-feed-formats", @"value", nil];
+ // verify
+ assertThat(settings.docsetFeedFormats, is(@"value"));
+}
+
- (void)testDocSetPackageURL_shouldAssignValueToSettings {
// setup & execute
GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docset-package-url", @"value", nil];
@@ -533,6 +541,13 @@ - (void)testDocSetAtomFilename_shouldAssignValueToSettings {
assertThat(settings.docsetAtomFilename, is(@"value"));
}
+- (void)testDocSetXMLFilename_shouldAssignValueToSettings {
+ // setup & execute
+ GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docset-xml-filename", @"value", nil];
+ // verify
+ assertThat(settings.docsetXMLFilename, is(@"value"));
+}
+
- (void)testDocSetPackageFilename_shouldAssignValueToSettings {
// setup & execute
GBApplicationSettingsProvider *settings = [self settingsByRunningWithArgs:@"--docset-package-filename", @"value", nil];
View
2  appledoc.xcodeproj/project.pbxproj
@@ -549,6 +549,7 @@
B4D1FFD415FF5F05009736E2 /* DDXcodeProjectFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDXcodeProjectFile.m; sourceTree = "<group>"; };
B4D1FFF215FF633F009736E2 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
B4D1FFF615FF643D009736E2 /* install-appledoc.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "install-appledoc.sh"; sourceTree = "<group>"; };
+ F59056EC16C1C6DC00391620 /* publish */ = {isa = PBXFileReference; lastKnownFileType = folder; path = publish; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -736,6 +737,7 @@
739AD36F1254449D00B642C3 /* Templates */ = {
isa = PBXGroup;
children = (
+ F59056EC16C1C6DC00391620 /* publish */,
7367298112A3BD9D00879D1B /* docset */,
73D2524312A2EA340024F9F9 /* html */,
);
Something went wrong with that request. Please try again.