Permalink
Browse files

Fixed output generator directory dependencies handling.

Some of the dependent objects still used hard coded directory and file paths from CommandLineParser. These are now properly handled through OutputInfoProvider protocol properties, similar to the was documentation set was linked with it's parent documents output generator. To even more encapsulate different output generators implementations, all paths handling is now moved from the CommandLineParser to concrete generator subclasses. This makes the code more decoupled and OOP.
  • Loading branch information...
1 parent 04e7189 commit fd65a45ca879b27fd1755774e4f0b21cda2087b0 @tomaz committed Jun 12, 2009
View
@@ -222,37 +222,4 @@ This is used by the log macros, so in most cases, you'll not use it directly in
and @c docsetutil. */
@property(readonly) BOOL emitUtilityOutput;
-//////////////////////////////////////////////////////////////////////////////////////////
-/// @name Properties - internal
-//////////////////////////////////////////////////////////////////////////////////////////
-
-/** The full path to the doxygen output files.
-
-Note that this property is handled differently from others - by default it is set to
-@c outputPath(), however doxygen handler should read the actual value from the doxygen
-configuration file and set it here so that the rest of the application can use it.
-
-Since doxygen generation is the first this that gets generated, the path is properly
-setup for all dependent generators automatically.
-*/
-@property(copy) NSString* outputDoxygenXMLPath;
-
-/** The full path to the output clean XML files. */
-@property(readonly) NSString* outputCleanXMLPath;
-
-/** The full path to the output clean XHTML files. */
-@property(readonly) NSString* outputCleanXHTMLPath;
-
-/** The full path to the temporary output documentation set files. */
-@property(readonly) NSString* outputDocSetPath;
-
-/** The full path to the temporary output documentation set contents files. */
-@property(readonly) NSString* outputDocSetContentsPath;
-
-/** The full path to the temporary output documentation set resources files. */
-@property(readonly) NSString* outputDocSetResourcesPath;
-
-/** The full path to the temporary output documentation set documents files. */
-@property(readonly) NSString* outputDocSetDocumentsPath;
-
@end
View
@@ -10,7 +10,7 @@
#import "LoggingProvider.h"
#import "Systemator.h"
-#define kTKCommandLineException @"TKCommandLineException"
+#define kTKCommandLineException @"TKCommandLineException"
#define kTKCmdGlobalTemplatesPathKey @"GlobalTemplatesPath" // NSString
#define kTKCmdTemplatesPathKey @"TemplatesPath" // NSString
@@ -19,12 +19,6 @@
#define kTKCmdInputPathKey @"InputPath" // NSString
#define kTKCmdOutputPathKey @"OutputPath" // NSString
-#define kTKCmdOutputCleanXMLPathKey @"OutputCleanXMLPath" // NSString
-#define kTKCmdOutputCleanXHTMLPathKey @"OutputCleanXHTMLPath" // NSString
-#define kTKCmdOutputDocSetPathKey @"OutputDocSetPath" // NSString
-#define kTKCmdOutputDocSetContentsPathKey @"OutputDocSetContentsPath" // NSString
-#define kTKCmdOutputDocSetResourcesPathKey @"OutputDocSetResourcesPath" // NSString
-#define kTKCmdOutputDocSetDocumentsPathKey @"OutputDocSetDocumentsPath" // NSString
#define kTKCmdDoxygenCommandLineKey @"DoxygenCommandLine" // NSString
#define kTKCmdDoxygenConfigFileKey @"DoxygenConfigFile" // NSString
@@ -402,17 +396,6 @@ - (void) postProcessCommandLineArguments
[self replaceTemplatePlaceholdersForKey:kTKCmdDocSetBundleFeedKey];
[self replaceTemplatePlaceholdersForKey:kTKCmdDocSetSourcePlistKey];
- // Replace template placeholders for all dependent parameters.
- [self replaceTemplatePlaceholdersForKey:kTKCmdOutputCleanXMLPathKey];
- [self replaceTemplatePlaceholdersForKey:kTKCmdOutputCleanXHTMLPathKey];
- [self replaceTemplatePlaceholdersForKey:kTKCmdOutputDocSetPathKey];
- [self replaceTemplatePlaceholdersForKey:kTKCmdOutputDocSetContentsPathKey];
- [self replaceTemplatePlaceholdersForKey:kTKCmdOutputDocSetResourcesPathKey];
- [self replaceTemplatePlaceholdersForKey:kTKCmdOutputDocSetDocumentsPathKey];
-
- // Setup the default doxygen output XML path.
- self.outputDoxygenXMLPath = self.outputPath;
-
// Make sure the documentation set bundle ID ends with .docset.
if (![self.docsetBundleID hasSuffix:@".docset"])
{
@@ -519,15 +502,7 @@ - (void) setupFactoryDefaults
[parameters setObject:@"$INPUT/DocSet-Info.plist" forKey:kTKCmdDocSetSourcePlistKey];
[parameters setObject:@"/Developer/usr/bin/docsetutil" forKey:kTKCmdDocSetUtilCommandLinKey];
[parameters setObject:[NSNumber numberWithBool:YES] forKey:kTKCmdCreateDocSetKey];
-
- // Setup dependencies, note that we use template placeholders...
- [parameters setObject:@"$OUTPUT/cxml" forKey:kTKCmdOutputCleanXMLPathKey];
- [parameters setObject:@"$OUTPUT/cxhtml" forKey:kTKCmdOutputCleanXHTMLPathKey];
- [parameters setObject:@"$OUTPUT/docset" forKey:kTKCmdOutputDocSetPathKey];
- [parameters setObject:@"$OUTPUT/docset/Contents" forKey:kTKCmdOutputDocSetContentsPathKey];
- [parameters setObject:@"$OUTPUT/docset/Contents/Resources" forKey:kTKCmdOutputDocSetResourcesPathKey];
- [parameters setObject:@"$OUTPUT/docset/Contents/Resources/Documents" forKey:kTKCmdOutputDocSetDocumentsPathKey];
-
+
// Setup the default verbose level and switches. Note that we would only need to
// initialize those which default value is YES since NO is returned by default if
// a boolValue is sent to nil object, but to make future changes more meaningful,
@@ -979,50 +954,4 @@ - (BOOL) emitUtilityOutput
return [[parameters objectForKey:kTKCmdEmitUtilityOutputKey] boolValue];
}
-//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Properties - internal
-//////////////////////////////////////////////////////////////////////////////////////////
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputCleanXMLPath
-{
- return [parameters objectForKey:kTKCmdOutputCleanXMLPathKey];
-}
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputCleanXHTMLPath
-{
- return [parameters objectForKey:kTKCmdOutputCleanXHTMLPathKey];
-}
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputDocSetPath
-{
- return [parameters objectForKey:kTKCmdOutputDocSetPathKey];
-}
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputDocSetContentsPath
-{
- return [parameters objectForKey:kTKCmdOutputDocSetContentsPathKey];
-}
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputDocSetResourcesPath
-{
- return [parameters objectForKey:kTKCmdOutputDocSetResourcesPathKey];
-}
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputDocSetDocumentsPath
-{
- return [parameters objectForKey:kTKCmdOutputDocSetDocumentsPathKey];
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Synthetized properties
-//////////////////////////////////////////////////////////////////////////////////////////
-
-@synthesize outputDoxygenXMLPath;
-
@end
View
@@ -123,4 +123,25 @@ source files.
*/
@property(retain) id<OutputInfoProvider> documentationFilesInfoProvider;
+/** Returns the temporary documentation set contents path.
+
+@see outputResourcesPath
+@see outputDocumentsPath
+*/
+@property(readonly) NSString* outputContentsPath;
+
+/** Returns the temporary documentation set resources path.
+
+@see outputContentsPath
+@see outputDocumentsPath
+*/
+@property(readonly) NSString* outputResourcesPath;
+
+/** Returns the temporary documentation set documents path.
+
+@see outputContentsPath
+@see outputResourcesPath
+*/
+@property(readonly) NSString* outputDocumentsPath;
+
@end
View
@@ -14,6 +14,40 @@
@implementation DocSetOutputGenerator
//////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark OutputInfoProvider protocol implementation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputFilesExtension
+{
+ return @".html";
+}
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputBasePath
+{
+ return [cmd.outputPath stringByAppendingPathComponent:@"docset"];
+}
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputContentsPath
+{
+ return [self.outputBasePath stringByAppendingPathComponent:@"Contents"];
+}
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputResourcesPath
+{
+ return [self.outputContentsPath stringByAppendingPathComponent:@"Resources"];
+}
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputDocumentsPath
+{
+ return [self.outputResourcesPath stringByAppendingPathComponent:@"Documents"];
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
#pragma mark Specific output generation entry points
//////////////////////////////////////////////////////////////////////////////////////////
@@ -42,17 +76,18 @@ - (void) createOutputDirectories
// Note that we only manually create temporary documentation set directory here,
// if the documentation set is installed, it will be copied as a bundle to the
// appropriate path.
- [Systemator createDirectory:cmd.outputDocSetPath];
- [Systemator createDirectory:cmd.outputDocSetContentsPath];
- [Systemator createDirectory:cmd.outputDocSetResourcesPath];
+ [Systemator createDirectory:[self outputBasePath]];
+ [Systemator createDirectory:[self outputContentsPath]];
+ [Systemator createDirectory:[self outputResourcesPath]];
+ [Systemator createDirectory:[self outputDocumentsPath]];
}
//----------------------------------------------------------------------------------------
- (void) removeOutputDirectories
{
// Note that we only remove temporary documentation set directory here, the installed
// copy is always left in it's installation directory.
- [Systemator removeItemAtPath:cmd.outputDocSetPath];
+ [Systemator removeItemAtPath:[self outputBasePath]];
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -214,7 +249,7 @@ - (void) createDocSetNodesFile
// Save the document.
NSError* error = nil;
- NSString* filename = [cmd.outputDocSetResourcesPath stringByAppendingPathComponent:@"Nodes.xml"];
+ NSString* filename = [self.outputResourcesPath stringByAppendingPathComponent:@"Nodes.xml"];
NSData* documentData = [document XMLDataWithOptions:NSXMLNodePrettyPrint];
if (![documentData writeToFile:filename options:0 error:&error])
{
@@ -337,7 +372,7 @@ - (void) createDocSetTokesFile
// Save the document.
NSError* error = nil;
- NSString* filename = [cmd.outputDocSetResourcesPath stringByAppendingPathComponent:@"Tokens.xml"];
+ NSString* filename = [self.outputResourcesPath stringByAppendingPathComponent:@"Tokens.xml"];
NSData* documentData = [document XMLDataWithOptions:NSXMLNodePrettyPrint];
if (![documentData writeToFile:filename options:0 error:&error])
{
@@ -356,23 +391,24 @@ - (void) createDocSetBundle
logNormal(@"Creating DocSet bundle...");
// First copy the info plist file into the contents output.
- NSString* plistDestPath = [cmd.outputDocSetContentsPath stringByAppendingPathComponent:@"Info.plist"];
+ NSString* plistDestPath = [self.outputContentsPath stringByAppendingPathComponent:@"Info.plist"];
logVerbose(@"- Copying info plist file to '%@'...", plistDestPath);
[Systemator copyItemAtPath:cmd.docsetSourcePlistPath toPath:plistDestPath];
// Copy all html files to the bundle structure.
- logVerbose(@"- Copying documentation to '%@'...", cmd.outputDocSetDocumentsPath);
- [Systemator copyItemAtPath:cmd.outputCleanXHTMLPath toPath:cmd.outputDocSetDocumentsPath];
+ logVerbose(@"- Copying documentation to '%@'...", self.outputDocumentsPath);
+ [Systemator copyItemAtPath:[documentationFilesInfoProvider outputBasePath]
+ toPath:self.outputDocumentsPath];
// Index the documentation set.
logVerbose(@"- Indexing DocSet...");
- [Systemator runTask:cmd.docsetutilCommandLine, @"index", cmd.outputDocSetPath, nil];
+ [Systemator runTask:cmd.docsetutilCommandLine, @"index", [self outputBasePath], nil];
// Copy the documentation set to the proper directory. First we need to remove
// previous files otherwise copying will fail.
NSString* docsetInstallPath = [cmd.docsetInstallPath stringByAppendingPathComponent:cmd.docsetBundleID];
logVerbose(@"- Copying DocSet bundle to '%@'...", docsetInstallPath);
- [Systemator copyItemAtPath:cmd.outputDocSetPath toPath:docsetInstallPath];
+ [Systemator copyItemAtPath:[self outputBasePath] toPath:docsetInstallPath];
// Install the script to the Xcode.
logVerbose(@"- Installing DocSet to Xcode...");
@@ -393,30 +429,6 @@ - (void) createDocSetBundle
}
[installScript release];
- // If cleantemp is used, remove clean html and docset temporary files.
- if (cmd.cleanTempFilesAfterBuild && [manager fileExistsAtPath:cmd.outputCleanXHTMLPath])
- {
- logInfo(@"Removing temporary clean XHTML files at '%@'...", cmd.outputCleanXHTMLPath);
- NSError* error = nil;
- if (![manager removeItemAtPath:cmd.outputCleanXHTMLPath error:&error])
- {
- logError(@"Failed removing temporary XHTML files at '%@'!", cmd.outputCleanXHTMLPath);
- [Systemator throwExceptionWithName:kTKConverterException basedOnError:error];
- }
- }
-
- // If cleantemp is used, remove docset temporary files.
- if (cmd.cleanTempFilesAfterBuild && [manager fileExistsAtPath:cmd.outputDocSetPath])
- {
- logInfo(@"Removing temporary clean XHTML files at '%@'...", cmd.outputDocSetPath);
- NSError* error = nil;
- if (![manager removeItemAtPath:cmd.outputDocSetPath error:&error])
- {
- logError(@"Failed removing temporary DocSet files at '%@'!", cmd.outputDocSetPath);
- [Systemator throwExceptionWithName:kTKConverterException basedOnError:error];
- }
- }
-
logInfo(@"Finished creating DocSet bundle.");
}
View
@@ -42,6 +42,7 @@ - (id)init
[doxygenGenerator registerDependentGenerator:xmlGenerator];
[xmlGenerator registerDependentGenerator:xhtmlGenerator];
[xhtmlGenerator registerDependentGenerator:docSetGenerator];
+ xmlGenerator.doxygenInfoProvider = doxygenGenerator;
docSetGenerator.documentationFilesInfoProvider = xhtmlGenerator;
// Setup top level generators.
View
@@ -20,6 +20,10 @@ the user after initial creation. When doxygen configuration file is processed, t
generator invokes doxygen so that it actually generates the output for us.
*/
@interface DoxygenOutputGenerator : OutputGenerator
+{
+ NSString* outputDirectory;
+ NSString* outputRelativePath;
+}
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Doxygen handling
Oops, something went wrong.

0 comments on commit fd65a45

Please sign in to comment.