Tweak warning/verbose output and auto generate author/date when needed

This commit is contained in:
rfm 2023-10-31 12:30:00 +00:00
parent 7fc6637390
commit 4e3e169bed
5 changed files with 74 additions and 31 deletions

View file

@ -43,12 +43,15 @@
NSString *nextFile; // Not retained
NSString *prevFile; // Not retained
NSString *upFile; // Not retained
NSString *fileName;
unsigned chap;
unsigned sect;
unsigned ssect;
unsigned sssect;
BOOL isContentsDoc;
BOOL ivarsAtEnd;
BOOL verbose;
BOOL warn;
}
- (void) decIndent;
- (void) incIndent;
@ -68,7 +71,7 @@
style: (NSString*)style
target: (NSString*)target
to: (NSMutableString*)buf;
- (NSString*) outputDocument: (GSXMLNode*)node;
- (NSString*) outputDocument: (GSXMLNode*)node name: (NSString*)file;
- (void) outputNode: (GSXMLNode*)node to: (NSMutableString*)buf;
- (void) outputNodeList: (GSXMLNode*)node to: (NSMutableString*)buf;
- (GSXMLNode*) outputBlock: (GSXMLNode*)node

View file

@ -22,11 +22,7 @@
#import "common.h"
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSSet.h"
#import "Foundation/NSUserDefaults.h"
#import "Foundation/Foundation.h"
#import "AGSHtml.h"
#import "GNUstepBase/NSString+GNUstepBase.h"
#import "GNUstepBase/NSMutableString+GNUstepBase.h"
@ -108,6 +104,7 @@ static NSString *mainFont = nil;
RELEASE(localRefs);
RELEASE(projectRefs);
RELEASE(indent);
RELEASE(fileName);
DEALLOC
}
@ -128,9 +125,15 @@ static NSString *mainFont = nil;
- (id) init
{
if (nil != (self = [super init]))
{
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
indent = [[NSMutableString alloc] initWithCapacity: 64];
project = RETAIN([[NSUserDefaults standardUserDefaults]
stringForKey: @"Project"]);
project = RETAIN([defs stringForKey: @"Project"]);
verbose = [defs boolForKey: @"Verbose"];
warn = [defs boolForKey: @"Warn"];
}
return self;
}
@ -281,10 +284,11 @@ static NSString *mainFont = nil;
return [s stringByReplacingString: @":" withString: @"$"];
}
- (NSString*) outputDocument: (GSXMLNode*)node
- (NSString*) outputDocument: (GSXMLNode*)node name: (NSString*)file
{
NSMutableString *buf;
ASSIGN(fileName, file);
if (localRefs == nil)
{
localRefs = [AGSIndex new];
@ -305,6 +309,7 @@ static NSString *mainFont = nil;
[self decIndent];
[buf appendString: @"</html>\n"];
DESTROY(fileName);
return buf;
}
@ -1193,6 +1198,15 @@ static NSString *mainFont = nil;
GSXMLNode *email = nil;
GSXMLNode *url = nil;
GSXMLNode *desc = nil;
NSString *name;
name = [[author attributes] objectForKey: @"name"];
name = [name stringByTrimmingSpaces];
if ([name length] == 0)
{
name = [NSString stringWithFormat: @"Generated by %@",
NSFullUserName()];
}
children = [children nextElement];
@ -1216,8 +1230,7 @@ static NSString *mainFont = nil;
if (url == nil)
{
[buf appendString: @"<dt>"];
[buf appendString: [[[author attributes]
objectForKey: @"name"] stringByEscapingXML]];
[buf appendString: [name stringByEscapingXML]];
}
else
{
@ -1225,8 +1238,7 @@ static NSString *mainFont = nil;
[buf appendString: [[url attributes]
objectForKey: @"url"]];
[buf appendString: @"\">"];
[buf appendString: [[[author attributes]
objectForKey: @"name"] stringByEscapingXML]];
[buf appendString: [name stringByEscapingXML]];
[buf appendString: @"</a>"];
}
if (email != nil)
@ -1267,9 +1279,24 @@ static NSString *mainFont = nil;
}
if ([[children name] isEqual: @"date"] == YES)
{
GSXMLNode *tmp = [children firstChild];
NSString *str;
[buf appendString: indent];
[buf appendString: @"<p><b>Date:</b> "];
[self outputText: [children firstChild] to: buf];
if (nil == tmp
|| ([tmp type] == XML_TEXT_NODE
&& [(str = [[tmp escapedContent] stringByTrimmingSpaces])
length] == 0))
{
str = [NSString stringWithFormat: @"Generated at %@",
[NSDate date]];
[buf appendString: str];
}
else
{
[self outputText: tmp to: buf];
}
[buf appendString: @"</p>\n"];
children = [children nextElement];
}
@ -1719,17 +1746,24 @@ static NSString *mainFont = nil;
}
if (s == nil)
{
if (warn)
{
NSString *ref;
ref = [NSString stringWithFormat:
@" (referenced from %@ in %@).",
base, fileName];
if (c == nil)
{
NSLog(@"Location of %@ '%@' not found or not unique"
@" (referenced from %@:\n%@).",
type, r, base, [[node parent] parent]);
NSLog(@"Warning - location of %@ '%@'"
@" not found or not unique %@.",
type, r, ref);
}
else
{
NSLog(@"Location of the %@ version of %@ '%@' not found"
@"(referenced from %@:\n%@).",
c, type, r, base, [[node parent] parent]);
NSLog(@"Warning - location of the %@ version of %@ '%@'"
@" not found %@.", c, type, r, ref);
}
}
if (tmp == nil)
{

View file

@ -746,7 +746,7 @@ static BOOL snuggleStart(NSString *t)
if (warn == YES && [[d objectForKey: @"Implemented"] isEqual: @"YES"] == NO)
{
NSLog(@"Warning ... %@ %@ is not implemented where expected", kind, name);
NSLog(@"Warning - %@ %@ is not implemented where expected", kind, name);
}
[str appendFormat: @" <%@ type=\"", kind];
@ -790,7 +790,7 @@ static BOOL snuggleStart(NSString *t)
if (warn == YES && [[d objectForKey: @"Implemented"] isEqual: @"YES"] == NO)
{
NSLog(@"Warning ... function %@ is not implemented where expected", name);
NSLog(@"Warning - function %@ is not implemented where expected", name);
}
/**
@ -1172,7 +1172,7 @@ static BOOL snuggleStart(NSString *t)
}
else if (warn == YES)
{
NSLog(@"Warning ... unit %@ is not implemented where expected", name);
NSLog(@"Warning - unit %@ is not implemented where expected", name);
}
}
else

View file

@ -2178,7 +2178,7 @@ main(int argc, char **argv, char **env)
[html setProjectRefs: projectRefs];
[html setLocalRefs: localRefs];
[html setInstanceVariablesAtEnd: instanceVarsAtEnd];
generated = [html outputDocument: root];
generated = [html outputDocument: root name: gsdocfile];
d = [generated dataUsingEncoding: NSUTF8StringEncoding];
if ([d writeToFile: htmlfile atomically: YES] == NO)
{

View file

@ -578,10 +578,16 @@
<!-- The version of the document. -->
<!ELEMENT version (%text;)*>
<!-- The date the document was written. -->
<!-- The date the document was written.
If the text content is empty, output produced from the document
should describe the date/time at which that output was generated.
-->
<!ELEMENT date (%text;)*>
<!-- An author. -->
<!-- An author.
If the name attribute is empty, output produced from the document
should describe the user account which generated the output.
-->
<!ELEMENT author (email?, url?, desc?)>
<!ATTLIST author
name CDATA #REQUIRED