Skip to content

Commit

Permalink
Tweak warning/verbose output and auto generate author/date when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Oct 31, 2023
1 parent 7fc6637 commit 4e3e169
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 31 deletions.
5 changes: 4 additions & 1 deletion Tools/AGSHtml.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
82 changes: 58 additions & 24 deletions Tools/AGSHtml.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -108,6 +104,7 @@ - (void) dealloc
RELEASE(localRefs);
RELEASE(projectRefs);
RELEASE(indent);
RELEASE(fileName);
DEALLOC
}

Expand All @@ -128,9 +125,15 @@ - (void) incIndent

- (id) init
{
indent = [[NSMutableString alloc] initWithCapacity: 64];
project = RETAIN([[NSUserDefaults standardUserDefaults]
stringForKey: @"Project"]);
if (nil != (self = [super init]))
{
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];

indent = [[NSMutableString alloc] initWithCapacity: 64];
project = RETAIN([defs stringForKey: @"Project"]);
verbose = [defs boolForKey: @"Verbose"];
warn = [defs boolForKey: @"Warn"];
}
return self;
}

Expand Down Expand Up @@ -281,10 +284,11 @@ - (NSString*) makeLink: (NSString*)r
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];
Expand All @@ -305,6 +309,7 @@ - (NSString*) outputDocument: (GSXMLNode*)node
[self decIndent];
[buf appendString: @"</html>\n"];

DESTROY(fileName);
return buf;
}

Expand Down Expand Up @@ -1193,6 +1198,15 @@ - (void) outputNode: (GSXMLNode*)node to: (NSMutableString*)buf
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];

Expand All @@ -1216,17 +1230,15 @@ - (void) outputNode: (GSXMLNode*)node to: (NSMutableString*)buf
if (url == nil)
{
[buf appendString: @"<dt>"];
[buf appendString: [[[author attributes]
objectForKey: @"name"] stringByEscapingXML]];
[buf appendString: [name stringByEscapingXML]];
}
else
{
[buf appendString: @"<dt><a href=\""];
[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)
Expand Down Expand Up @@ -1267,9 +1279,24 @@ - (void) outputNode: (GSXMLNode*)node to: (NSMutableString*)buf
}
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];
}
Expand Down Expand Up @@ -1719,17 +1746,24 @@ - (void) outputNode: (GSXMLNode*)node to: (NSMutableString*)buf
}
if (s == nil)
{
if (c == nil)
{
NSLog(@"Location of %@ '%@' not found or not unique"
@" (referenced from %@:\n%@).",
type, r, base, [[node parent] parent]);
}
else
if (warn)
{
NSLog(@"Location of the %@ version of %@ '%@' not found"
@"(referenced from %@:\n%@).",
c, type, r, base, [[node parent] parent]);
NSString *ref;

ref = [NSString stringWithFormat:
@" (referenced from %@ in %@).",
base, fileName];
if (c == nil)
{
NSLog(@"Warning - location of %@ '%@'"
@" not found or not unique %@.",
type, r, ref);
}
else
{
NSLog(@"Warning - location of the %@ version of %@ '%@'"
@" not found %@.", c, type, r, ref);
}
}
if (tmp == nil)
{
Expand Down
6 changes: 3 additions & 3 deletions Tools/AGSOutput.m
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ - (void) outputDecl: (NSMutableDictionary*)d

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];
Expand Down Expand Up @@ -790,7 +790,7 @@ - (void) outputFunction: (NSMutableDictionary*)d to: (NSMutableString*)str

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);
}

/**
Expand Down Expand Up @@ -1172,7 +1172,7 @@ - (void) outputUnit: (NSMutableDictionary*)d to: (NSMutableString*)str
}
else if (warn == YES)
{
NSLog(@"Warning ... unit %@ is not implemented where expected", name);
NSLog(@"Warning - unit %@ is not implemented where expected", name);
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion Tools/autogsdoc.m
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ standard PropertyList format (not the XML format of OS X), using
[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)
{
Expand Down
10 changes: 8 additions & 2 deletions Tools/gsdoc-1_0_4.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e3e169

Please sign in to comment.