Permalink
Browse files

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...
1 parent 140fbb3 commit 75a390768c9b344e5ce4304fa415b7cf75fccde2 @bjtitus bjtitus committed Feb 5, 2013
@@ -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]");
@@ -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;
@@ -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;
@@ -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");
Oops, something went wrong.

0 comments on commit 75a3907

Please sign in to comment.