Skip to content
This repository
Browse code

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...
commit 3d911bac28571543563eeafbe5cb0c374ad70e1f 1 parent 9408d37
tomaz authored June 13, 2009
3  CommandLineParser.h
@@ -130,6 +130,9 @@ This is used to generate the actual reference name and is visible on the final o
130 130
 This is used to generate the actual reference name and is visible on the final output. */
131 131
 @property(readonly) NSString* memberReferenceTemplate;
132 132
 
  133
+/** The template for formatting date/time strings. */
  134
+@property(readonly) NSString* dateTimeTemplate;
  135
+
133 136
 //////////////////////////////////////////////////////////////////////////////////////////
134 137
 /// @name Properties - clean output creation
135 138
 //////////////////////////////////////////////////////////////////////////////////////////
13  CommandLineParser.m
@@ -43,6 +43,7 @@
43 43
 
44 44
 #define kTKCmdObjectRefTemplate					@"ObjectReferenceTemplate"		// NSString
45 45
 #define kTKCmdMemberRefTemplate					@"MemberReferenceTemplate"		// NSString
  46
+#define kTKCmdDateTimeTemplate					@"DateTimeTemplate"				// NSString
46 47
 #define kTKCmdCleanTempFilesKey					@"CleanTemporaryFilesAfterBuild"// NSNumber / BOOL
47 48
 #define kTKCmdCleanBeforeBuildKey				@"CleanOutputFilesBeforeBuild"	// NSNumber / BOOL
48 49
 #define kTKCmdVerboseLevelKey					@"VerboseLevel"					// NSNumber / int
@@ -235,6 +236,10 @@ - (void) logCmdLineSwitch:(NSString*) shortcut
235 236
 
236 237
 @end
237 238
 
  239
+//////////////////////////////////////////////////////////////////////////////////////////
  240
+#pragma mark -
  241
+//////////////////////////////////////////////////////////////////////////////////////////
  242
+
238 243
 @implementation CommandLineParser
239 244
 
240 245
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -349,6 +354,7 @@ - (void) parseCommandLineArguments:(const char**) argv
349 354
 	
350 355
 	[self parseStringWithShortcut:nil andName:@"--object-reference-template" forKey:kTKCmdObjectRefTemplate];
351 356
 	[self parseStringWithShortcut:nil andName:@"--member-reference-template" forKey:kTKCmdMemberRefTemplate];
  357
+	[self parseStringWithShortcut:nil andName:@"--date-time-template" forKey:kTKCmdDateTimeTemplate];
352 358
 
353 359
 	[self parseBooleanWithShortcut:nil andName:@"--fix-class-locations" withValue:YES forKey:kTKCmdFixClassLocationsKey];
354 360
 	[self parseBooleanWithShortcut:nil andName:@"--merge-categories" withValue:YES forKey:kTKCmdMergeCategoriesKey];
@@ -520,6 +526,7 @@ - (void) setupFactoryDefaults
520 526
 	// Setup other properties.
521 527
 	[parameters setObject:@"$PREFIX[$OBJECT $MEMBER]" forKey:kTKCmdObjectRefTemplate];
522 528
 	[parameters setObject:@"$PREFIX $MEMBER" forKey:kTKCmdMemberRefTemplate];
  529
+	[parameters setObject:@"(Last updated: %Y-%m-%d)" forKey:kTKCmdDateTimeTemplate];
523 530
 	[parameters setObject:[NSNumber numberWithBool:YES] forKey:kTKCmdEmitUtilityOutputKey];
524 531
 }
525 532
 
@@ -836,6 +843,12 @@ - (NSString*) memberReferenceTemplate
836 843
 	return [parameters objectForKey:kTKCmdMemberRefTemplate];
837 844
 }
838 845
 
  846
+//----------------------------------------------------------------------------------------
  847
+- (NSString*) dateTimeTemplate
  848
+{
  849
+	return [parameters objectForKey:kTKCmdDateTimeTemplate];
  850
+}
  851
+
839 852
 //////////////////////////////////////////////////////////////////////////////////////////
840 853
 #pragma mark Properties - clean output creation
841 854
 //////////////////////////////////////////////////////////////////////////////////////////
16  Readme.markdown
Source Rendered
@@ -241,8 +241,8 @@ Documentation set related options
241 241
 	specify it.
242 242
 
243 243
 
244  
-Miscellaneous options
245  
----------------------
  244
+Formatting options
  245
+------------------
246 246
 
247 247
 *	`--object-reference-template`: Inter-object reference (links) generation style. This
248 248
 	option allows you to change the way the link names are generated. Defaults to 
@@ -253,6 +253,17 @@ Miscellaneous options
253 253
 	option allows you to change the way the link names are generated. Defaults to
254 254
 	`$PREFIX $MEMBER`. You can use `$PREFIX` and `$MEMBER` placeholders which will be
255 255
 	replaced by the selector prefix (`-` or `+`) and member name respectively.
  256
+*	`--date-time-template`: Date and time template format. This is used for generating
  257
+	last updated. Any number of date and time components can be formatted using format
  258
+	specifiers of `NSCalendarDate`. Defaults to `(Last updated: %Y-%m-%d)`. As you can
  259
+	see this allows you to use any static text, such as your copyright notice, for
  260
+	example: `(c) 2008-%Y YourCompany. All rights reserved. (Last updated: %Y-%m-%d)`
  261
+	would give you similar footer as Apple documentation does.
  262
+
  263
+
  264
+Miscellaneous options
  265
+---------------------
  266
+
256 267
 *	`--clean-temp-files`: Remove all temporary build files. Note that this is 
257 268
 	dynamic and will delete generated files based on what is build. If html is created, 
258 269
 	all doxygen and clean xml is removed. If doc set is installed, the whole output path 
@@ -329,6 +340,7 @@ line counterparts is:
329 340
 *	`KeepMergedSections` (Boolean): `--keep-merged-sections`
330 341
 *	`ObjectReferenceTemplate` (String): `--object-reference-template`
331 342
 *	`MemberReferenceTemplate` (String): `--member-reference-template`
  343
+*	`DateTimeTemplate` (String): `--date-time-template`
332 344
 *	`CleanTemporaryFilesAfterBuild` (Boolean): `--clean-temp-files`
333 345
 *	`CleanOutputFilesBeforeBuild` (Boolean): `--clean-before-build`
334 346
 *	`VerboseLevel` (Number): `--verbose`
8  XHTMLOutputGenerator.m
@@ -853,14 +853,14 @@ - (void) appendFileFooterToData:(NSMutableData*) data
853 853
 	
854 854
 		if (showLastUpdate && self.lastUpdated && [self.lastUpdated length] > 0)
855 855
 		{
856  
-			[self appendString:@"Last updated: " toData:data];
857  
-			[self appendString:self.lastUpdated toData:data];
858  
-			[self appendLine:@"      <br />" toData:data];
  856
+			[self appendString:@"      " toData:data];
  857
+			[self appendLine:self.lastUpdated toData:data];
  858
+			if (showBackToIndex) [self appendLine:@"      <br />" toData:data];
859 859
 		}
860 860
 		
861 861
 		if (showBackToIndex)
862 862
 		{
863  
-			[self appendString:@"Back to " toData:data];
  863
+			[self appendString:@"      Back to " toData:data];
864 864
 			
865 865
 			[self appendString:@"<a href=\"../" toData:data];
866 866
 			[self appendString:[self outputIndexFilename] toData:data];
2  XMLBasedOutputGenerator.m
@@ -630,7 +630,7 @@ - (NSString*) projectName
630 630
 - (NSString*) lastUpdated
631 631
 {
632 632
 	NSCalendarDate* now = [NSCalendarDate date];
633  
-	return [now descriptionWithCalendarFormat:@"%Y-%B-%d"];
  633
+	return [now descriptionWithCalendarFormat:cmd.dateTimeTemplate];
634 634
 }
635 635
 
636 636
 //----------------------------------------------------------------------------------------

0 notes on commit 3d911ba

Please sign in to comment.
Something went wrong with that request. Please try again.