Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reorganized output paths generation by moving common code to the Outp…

…utGenerator.

This relieves most of the output generators from the burder of repeating creation and removal of the same sets of common output directories. Only subclasses that need to create additional subdirectories, should handle their specifics.
  • Loading branch information...
commit 6149a66444b0f30619b4cde31d559049a7a4d608 1 parent fd65a45
@tomaz authored
View
1  Constants.h
@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
extern NSString* kTKConverterException;
+
extern NSString* kTKPlaceholderExtension;
extern NSString* kTKDirClasses;
View
5 DocSetOutputGenerator.h
@@ -116,7 +116,10 @@ will recursively add all subnodes as well.
//////////////////////////////////////////////////////////////////////////////////////////
/** Sets or returns the @c OutputInfoProvider conformer that provides information about
-source files.
+documentation files which should be included in the documentation set.
+
+This value is used to determine the path to the documentation HTML files so that they
+can be copied to the documentation set.
@warning Clients need to set this before starting output generation. If they fail to
provide a valid object, generation immediately fails with an exception.
View
8 DocSetOutputGenerator.m
@@ -82,14 +82,6 @@ - (void) createOutputDirectories
[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:[self outputBasePath]];
-}
-
//////////////////////////////////////////////////////////////////////////////////////////
#pragma mark Documentation set handling
//////////////////////////////////////////////////////////////////////////////////////////
View
72 DoxygenOutputGenerator.m
@@ -26,6 +26,44 @@ - (void) dealloc
}
//////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark OutputInfoProvider protocol implementation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputFilesExtension
+{
+ return @"xml";
+}
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputBasePath
+{
+ return [outputDirectory stringByAppendingPathComponent:outputRelativePath];
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark Output generation entry points
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//----------------------------------------------------------------------------------------
+- (void) generateSpecificOutput
+{
+ [self createDoxygenConfigFile];
+ [self updateDoxygenConfigFile];
+ [self createDoxygenDocumentation];
+}
+
+//----------------------------------------------------------------------------------------
+- (void) createOutputDirectories
+{
+ // We must not allow creation of default paths since at the point this message is
+ // sent, the outputBasePath components were not prepared yet. In fact we don't have
+ // to do anything, since doxygen will take care of creating the path. We only need
+ // to determine the exact path from configuration file so that any dependent objects
+ // can use it.
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
#pragma mark Doxygen handling
//////////////////////////////////////////////////////////////////////////////////////////
@@ -233,38 +271,4 @@ - (void) createDoxygenDocumentation
logInfo(@"Finished creating doxygen documentation.");
}
-//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Output generation entry points
-//////////////////////////////////////////////////////////////////////////////////////////
-
-//----------------------------------------------------------------------------------------
-- (void) generateSpecificOutput
-{
- [self createDoxygenConfigFile];
- [self updateDoxygenConfigFile];
- [self createDoxygenDocumentation];
-}
-
-//----------------------------------------------------------------------------------------
-- (void) removeOutputDirectories
-{
- [Systemator removeItemAtPath:[self outputBasePath]];
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark OutputInfoProvider protocol implementation
-//////////////////////////////////////////////////////////////////////////////////////////
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputFilesExtension
-{
- return @"xml";
-}
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputBasePath
-{
- return [outputDirectory stringByAppendingPathComponent:outputRelativePath];
-}
-
@end
View
9 OutputGenerator.h
@@ -159,6 +159,11 @@ If any of the required directories already exists, the subclass should decide on
it should delete it or skip it. In most cases, the directory is left as is. If the directory
contains files, the subclass should again decide whether it should remove these or
leave them. Again, in most cases the files can be left as they are.
+
+Default implementation creates the path returned from @c outputBasePath() and all
+default subdirectories: @c Classes, @c Categories and @c Protocols. Subclasses that need
+to create additional directories or don't want to use default ones, should override
+and create all required directories themselves.
@exception NSException Thrown if directories creation fails.
@see removeOutputDirectories
@@ -171,6 +176,10 @@ This message is sent after all concrete output generators finish their jobs if t
files should be removed or before generation starts if clean run is desired. Subclasses
should remove all generated directories and files. Note that this message is only sent
if @c createOutputDirectories() was sent at the start of the generation.
+
+Default implementation removes the directory at the path returned from @c outputBasePath().
+Subclasses that need to remove additional directories should override and remove all
+directories created in @c createOutputDirectories(). This should be vary rare though.
@exception NSException Thrown if removing directories or files fails.
@see createOutputDirectories
View
73 OutputGenerator.m
@@ -8,6 +8,7 @@
#import "OutputGenerator.h"
#import "CommandLineParser.h"
+#import "Systemator.h"
@implementation OutputGenerator
@@ -40,23 +41,38 @@ - (void) dealloc
}
//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Dependencies handling
+#pragma mark OutputInfoProvider protocol implementation
//////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------
-- (void) registerDependentGenerator:(id<OutputProcessing>) generator
+- (NSString*) outputObjectFilenameForObject:(NSDictionary*) objectData
{
- NSParameterAssert(generator != nil);
- [dependentGenerators addObject:generator];
+ NSString* path = [objectData objectForKey:kTKDataObjectRelPathKey];
+ return [self pathByReplacingTemplatePlaceholdersInPath:path];
}
-//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Subclass handling
-//////////////////////////////////////////////////////////////////////////////////////////
+//----------------------------------------------------------------------------------------
+- (NSString*) outputIndexFilename
+{
+ return [NSString stringWithFormat:@"index%@", [self outputFilesExtension]];
+}
//----------------------------------------------------------------------------------------
-- (void) generateSpecificOutput
+- (NSString*) outputHierarchyFilename
{
+ return [NSString stringWithFormat:@"hierarchy%@", [self outputFilesExtension]];
+}
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputFilesExtension
+{
+ return @"";
+}
+
+//----------------------------------------------------------------------------------------
+- (NSString*) outputBasePath
+{
+ return @"";
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -120,52 +136,39 @@ - (BOOL) isOutputGenerationEnabled
//----------------------------------------------------------------------------------------
- (void) createOutputDirectories
{
+ NSString* basePath = self.outputBasePath;
+ [Systemator createDirectory:basePath];
+ [Systemator createDirectory:[basePath stringByAppendingPathComponent:kTKDirClasses]];
+ [Systemator createDirectory:[basePath stringByAppendingPathComponent:kTKDirCategories]];
+ [Systemator createDirectory:[basePath stringByAppendingPathComponent:kTKDirProtocols]];
}
//----------------------------------------------------------------------------------------
- (void) removeOutputDirectories
{
+ [Systemator removeItemAtPath:self.outputBasePath];
}
//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark OutputInfoProvider protocol implementation
+#pragma mark Subclass handling
//////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------
-- (NSString*) outputObjectFilenameForObject:(NSDictionary*) objectData
-{
- NSString* path = [objectData objectForKey:kTKDataObjectRelPathKey];
- return [self pathByReplacingTemplatePlaceholdersInPath:path];
-}
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputIndexFilename
-{
- return [NSString stringWithFormat:@"index%@", [self outputFilesExtension]];
-}
-
-//----------------------------------------------------------------------------------------
-- (NSString*) outputHierarchyFilename
+- (void) generateSpecificOutput
{
- return [NSString stringWithFormat:@"hierarchy%@", [self outputFilesExtension]];
}
-//----------------------------------------------------------------------------------------
-- (NSString*) outputFilesExtension
-{
- return @"";
-}
+//////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark Helper methods
+//////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------
-- (NSString*) outputBasePath
+- (void) registerDependentGenerator:(id<OutputProcessing>) generator
{
- return @"";
+ NSParameterAssert(generator != nil);
+ [dependentGenerators addObject:generator];
}
-//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Helper methods
-//////////////////////////////////////////////////////////////////////////////////////////
-
//----------------------------------------------------------------------------------------
- (NSString*) pathByReplacingTemplatePlaceholdersInPath:(NSString*) path
{
View
2  OutputInfoProvider.h
@@ -71,6 +71,8 @@ can get all required information it needs.
- (NSString*) outputFilesExtension;
/** Returns the base path where output files are generated.
+
+This is full path to the base directory under which all files are generated.
@return Returns the base path where output files are generated.
@see outputObjectFilenameForObject:
View
11 XHTMLOutputGenerator.m
@@ -85,19 +85,10 @@ - (void) outputGenerationFinished
//----------------------------------------------------------------------------------------
- (void) createOutputDirectories
{
- [Systemator createDirectory:[self outputBasePath]];
- [Systemator createDirectory:[[self outputBasePath] stringByAppendingPathComponent:kTKDirClasses]];
- [Systemator createDirectory:[[self outputBasePath] stringByAppendingPathComponent:kTKDirCategories]];
- [Systemator createDirectory:[[self outputBasePath] stringByAppendingPathComponent:kTKDirProtocols]];
+ [super createOutputDirectories];
[Systemator createDirectory:[[self outputBasePath] stringByAppendingPathComponent:kTKDirCSS]];
}
-//----------------------------------------------------------------------------------------
-- (void) removeOutputDirectories
-{
- [Systemator removeItemAtPath:[self outputBasePath]];
-}
-
//////////////////////////////////////////////////////////////////////////////////////////
#pragma mark Object file header and footer handling
//////////////////////////////////////////////////////////////////////////////////////////
View
4 XMLOutputGenerator.h
@@ -393,6 +393,10 @@ or web robots.
/** Sets or returns the @c OutputInfoProvider conformer that provides information about
doxygen files.
+
+This value is used to determine the path to the doxygen XML files. It is used to enumerate
+the list of all objects and convert the doxygen XML to clean XML which is later as a
+foundation for generating usable output by the rest of the output generators.
@warning Clients need to set this before starting output generation. If they fail to
provide a valid object, generation immediately fails with an exception.
View
26 XMLOutputGenerator.m
@@ -50,26 +50,6 @@ - (void) generateSpecificOutput
}
//////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Specific output directories handling
-//////////////////////////////////////////////////////////////////////////////////////////
-
-//----------------------------------------------------------------------------------------
-- (void) createOutputDirectories
-{
- NSString* basePath = [self outputBasePath];
- [Systemator createDirectory:basePath];
- [Systemator createDirectory:[basePath stringByAppendingPathComponent:kTKDirClasses]];
- [Systemator createDirectory:[basePath stringByAppendingPathComponent:kTKDirCategories]];
- [Systemator createDirectory:[basePath stringByAppendingPathComponent:kTKDirProtocols]];
-}
-
-//----------------------------------------------------------------------------------------
-- (void) removeOutputDirectories
-{
- [Systemator removeItemAtPath:[self outputBasePath]];
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
#pragma mark Clean XML handling
//////////////////////////////////////////////////////////////////////////////////////////
@@ -1419,7 +1399,11 @@ - (NSString*) objectReferenceFromObject:(NSString*) source
// If the two subdirectories are not the same, we should prepend the relative path.
if (![sourceSubdir isEqualToString:destinationSubdir])
{
- return [NSString stringWithFormat:@"../%@/%@%@", destinationSubdir, destination, kTKPlaceholderExtension];
+ return [NSString stringWithFormat:
+ @"../%@/%@%@",
+ destinationSubdir,
+ destination,
+ kTKPlaceholderExtension];
}
return [NSString stringWithFormat:@"%@%@", destination, kTKPlaceholderExtension];
Please sign in to comment.
Something went wrong with that request. Please try again.