Permalink
Browse files

Implemented the option for custom date/time formatting for last updat…

…ed message.

The users can simply add arbitrary static text to the last updated line at the bottom of generated documentation XHTML. Note that at the moment this is only supported for XHTML output. Perhaps a better approach would be to append the information to the XML itself so it would be easily accessible to any dependent output generator or even external utilities that use appledoc clean XML for their source.
  • Loading branch information...
1 parent 9408d37 commit 3d911bac28571543563eeafbe5cb0c374ad70e1f @tomaz committed Jun 13, 2009
Showing with 35 additions and 7 deletions.
  1. +3 −0 CommandLineParser.h
  2. +13 −0 CommandLineParser.m
  3. +14 −2 Readme.markdown
  4. +4 −4 XHTMLOutputGenerator.m
  5. +1 −1 XMLBasedOutputGenerator.m
View
@@ -130,6 +130,9 @@ This is used to generate the actual reference name and is visible on the final o
This is used to generate the actual reference name and is visible on the final output. */
@property(readonly) NSString* memberReferenceTemplate;
+/** The template for formatting date/time strings. */
+@property(readonly) NSString* dateTimeTemplate;
+
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Properties - clean output creation
//////////////////////////////////////////////////////////////////////////////////////////
View
@@ -43,6 +43,7 @@
#define kTKCmdObjectRefTemplate @"ObjectReferenceTemplate" // NSString
#define kTKCmdMemberRefTemplate @"MemberReferenceTemplate" // NSString
+#define kTKCmdDateTimeTemplate @"DateTimeTemplate" // NSString
#define kTKCmdCleanTempFilesKey @"CleanTemporaryFilesAfterBuild"// NSNumber / BOOL
#define kTKCmdCleanBeforeBuildKey @"CleanOutputFilesBeforeBuild" // NSNumber / BOOL
#define kTKCmdVerboseLevelKey @"VerboseLevel" // NSNumber / int
@@ -235,6 +236,10 @@ - (void) logCmdLineSwitch:(NSString*) shortcut
@end
+//////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark -
+//////////////////////////////////////////////////////////////////////////////////////////
+
@implementation CommandLineParser
//////////////////////////////////////////////////////////////////////////////////////////
@@ -349,6 +354,7 @@ - (void) parseCommandLineArguments:(const char**) argv
[self parseStringWithShortcut:nil andName:@"--object-reference-template" forKey:kTKCmdObjectRefTemplate];
[self parseStringWithShortcut:nil andName:@"--member-reference-template" forKey:kTKCmdMemberRefTemplate];
+ [self parseStringWithShortcut:nil andName:@"--date-time-template" forKey:kTKCmdDateTimeTemplate];
[self parseBooleanWithShortcut:nil andName:@"--fix-class-locations" withValue:YES forKey:kTKCmdFixClassLocationsKey];
[self parseBooleanWithShortcut:nil andName:@"--merge-categories" withValue:YES forKey:kTKCmdMergeCategoriesKey];
@@ -520,6 +526,7 @@ - (void) setupFactoryDefaults
// Setup other properties.
[parameters setObject:@"$PREFIX[$OBJECT $MEMBER]" forKey:kTKCmdObjectRefTemplate];
[parameters setObject:@"$PREFIX $MEMBER" forKey:kTKCmdMemberRefTemplate];
+ [parameters setObject:@"(Last updated: %Y-%m-%d)" forKey:kTKCmdDateTimeTemplate];
[parameters setObject:[NSNumber numberWithBool:YES] forKey:kTKCmdEmitUtilityOutputKey];
}
@@ -836,6 +843,12 @@ - (NSString*) memberReferenceTemplate
return [parameters objectForKey:kTKCmdMemberRefTemplate];
}
+//----------------------------------------------------------------------------------------
+- (NSString*) dateTimeTemplate
+{
+ return [parameters objectForKey:kTKCmdDateTimeTemplate];
+}
+
//////////////////////////////////////////////////////////////////////////////////////////
#pragma mark Properties - clean output creation
//////////////////////////////////////////////////////////////////////////////////////////
View
@@ -241,8 +241,8 @@ Documentation set related options
specify it.
-Miscellaneous options
----------------------
+Formatting options
+------------------
* `--object-reference-template`: Inter-object reference (links) generation style. This
option allows you to change the way the link names are generated. Defaults to
@@ -253,6 +253,17 @@ Miscellaneous options
option allows you to change the way the link names are generated. Defaults to
`$PREFIX $MEMBER`. You can use `$PREFIX` and `$MEMBER` placeholders which will be
replaced by the selector prefix (`-` or `+`) and member name respectively.
+* `--date-time-template`: Date and time template format. This is used for generating
+ last updated. Any number of date and time components can be formatted using format
+ specifiers of `NSCalendarDate`. Defaults to `(Last updated: %Y-%m-%d)`. As you can
+ see this allows you to use any static text, such as your copyright notice, for
+ example: `(c) 2008-%Y YourCompany. All rights reserved. (Last updated: %Y-%m-%d)`
+ would give you similar footer as Apple documentation does.
+
+
+Miscellaneous options
+---------------------
+
* `--clean-temp-files`: Remove all temporary build files. Note that this is
dynamic and will delete generated files based on what is build. If html is created,
all doxygen and clean xml is removed. If doc set is installed, the whole output path
@@ -329,6 +340,7 @@ line counterparts is:
* `KeepMergedSections` (Boolean): `--keep-merged-sections`
* `ObjectReferenceTemplate` (String): `--object-reference-template`
* `MemberReferenceTemplate` (String): `--member-reference-template`
+* `DateTimeTemplate` (String): `--date-time-template`
* `CleanTemporaryFilesAfterBuild` (Boolean): `--clean-temp-files`
* `CleanOutputFilesBeforeBuild` (Boolean): `--clean-before-build`
* `VerboseLevel` (Number): `--verbose`
View
@@ -853,14 +853,14 @@ - (void) appendFileFooterToData:(NSMutableData*) data
if (showLastUpdate && self.lastUpdated && [self.lastUpdated length] > 0)
{
- [self appendString:@"Last updated: " toData:data];
- [self appendString:self.lastUpdated toData:data];
- [self appendLine:@" <br />" toData:data];
+ [self appendString:@" " toData:data];
+ [self appendLine:self.lastUpdated toData:data];
+ if (showBackToIndex) [self appendLine:@" <br />" toData:data];
}
if (showBackToIndex)
{
- [self appendString:@"Back to " toData:data];
+ [self appendString:@" Back to " toData:data];
[self appendString:@"<a href=\"../" toData:data];
[self appendString:[self outputIndexFilename] toData:data];
@@ -630,7 +630,7 @@ - (NSString*) projectName
- (NSString*) lastUpdated
{
NSCalendarDate* now = [NSCalendarDate date];
- return [now descriptionWithCalendarFormat:@"%Y-%B-%d"];
+ return [now descriptionWithCalendarFormat:cmd.dateTimeTemplate];
}
//----------------------------------------------------------------------------------------

0 comments on commit 3d911ba

Please sign in to comment.