Some restructuring and minor fixes to autogsdoc

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11552 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-11-27 20:55:12 +00:00
parent 000f954c4f
commit 7ce99f4e24
4 changed files with 287 additions and 185 deletions

View file

@ -4,6 +4,9 @@
the delay between polling for incoming packets can grow to ...
improve response on heavily loaded systems.
* Source/GSHTTPURLHandle.m: ditto
* Tools/autogsdoc.m: Tidied structure a little and added file
modification date checks to see whether files should be regenerated
or not.
2001-11-24 Fred Kiefer <FredKiefer@gmx.de>

View file

@ -713,7 +713,7 @@ NSLog(@"Element '%@' not implemented", name); // FIXME
}
if (f == nil)
{
NSLog(@"ref '%@' not found for %@", name, type);
NSLog(@"ref '%@' not found for %@", r, type);
}
else
{

View file

@ -1174,6 +1174,7 @@ static BOOL snuggleStart(NSString *t)
{
unsigned sPos = NSMaxRange(r);
pos = sPos;
r = NSMakeRange(pos, [tmp length] - pos);
r = [tmp rangeOfString: @"]" options: NSLiteralSearch range: r];
if (r.length > 0)

View file

@ -222,6 +222,7 @@ main(int argc, char **argv, char **env)
unsigned i;
NSUserDefaults *defs;
NSFileManager *mgr;
NSDictionary *projects;
NSString *documentationDirectory;
NSString *declared;
NSString *headerDirectory;
@ -234,7 +235,7 @@ main(int argc, char **argv, char **env)
AGSOutput *output;
NSString *up = nil;
NSString *prev = nil;
unsigned pass;
CREATE_AUTORELEASE_POOL(outer);
CREATE_AUTORELEASE_POOL(pool);
#ifdef GS_PASS_ARGUMENTS
@ -250,6 +251,8 @@ main(int argc, char **argv, char **env)
declared = [defs stringForKey: @"Declared"];
projects = [defs dictionaryForKey: @"Projects"];
headerDirectory = [defs stringForKey: @"HeaderDirectory"];
if (headerDirectory == nil)
{
@ -284,17 +287,6 @@ main(int argc, char **argv, char **env)
args = [proc arguments];
/*
* On the initial pass (pass0), we parse all files, produce indexes,
* and write gsdoc output, but not html output.
*
* On the next pass, we have all the indexing info, so we can use it
* to produce html output.
*/
for (pass = 0; pass < 2; pass++)
{
CREATE_AUTORELEASE_POOL(arp);
for (i = 1; i < [args count]; i++)
{
NSString *arg = [args objectAtIndex: i];
@ -308,7 +300,6 @@ main(int argc, char **argv, char **env)
|| [arg hasSuffix: @".gsdoc"]== YES)
{
NSString *gsdocfile;
NSString *htmlfile;
NSString *hfile;
NSString *sfile;
NSString *ddir;
@ -318,7 +309,15 @@ main(int argc, char **argv, char **env)
NSString *generated;
BOOL isSource = [arg hasSuffix: @".m"];
BOOL isDocumentation = [arg hasSuffix: @".gsdoc"];
NSDictionary *attrs;
NSDate *sDate;
NSDate *gDate;
if (pool != nil)
{
RELEASE(pool);
pool = [NSAutoreleasePool new];
}
file = [[arg lastPathComponent] stringByDeletingPathExtension];
hdir = [arg stringByDeletingLastPathComponent];
if ([hdir length] == 0)
@ -343,14 +342,38 @@ main(int argc, char **argv, char **env)
sfile = [sfile stringByAppendingPathExtension: @"m"];
gsdocfile = [ddir stringByAppendingPathComponent: file];
gsdocfile = [gsdocfile stringByAppendingPathExtension: @"gsdoc"];
htmlfile = [ddir stringByAppendingPathComponent: file];
htmlfile = [htmlfile stringByAppendingPathExtension: @"html"];
if (pass == 0)
{
/*
* We perform parsing of source code in pass 0 only.
* When were the files last modified?
*/
attrs = [mgr fileAttributesAtPath: hfile traverseLink: YES];
if (attrs == nil)
{
sDate = [NSDate distantPast];
}
else
{
sDate = [attrs objectForKey: NSFileModificationDate];
}
AUTORELEASE(RETAIN(sDate));
attrs = [mgr fileAttributesAtPath: sfile traverseLink: YES];
if (attrs != nil)
{
NSDate *d;
d = [attrs objectForKey: NSFileModificationDate];
if ([d earlierDate: sDate] == d)
{
sDate = d;
AUTORELEASE(RETAIN(sDate));
}
}
attrs = [mgr fileAttributesAtPath: gsdocfile traverseLink: YES];
gDate = [attrs objectForKey: NSFileModificationDate];
AUTORELEASE(RETAIN(gDate));
if (gDate == nil || [sDate earlierDate: gDate] == gDate)
{
[parser reset];
if (isSource == NO && isDocumentation == NO)
@ -410,7 +433,7 @@ main(int argc, char **argv, char **env)
[[parser info] setObject: file forKey: @"base"];
if (up == nil)
{
up = file;
ASSIGN(up, file);
}
else
{
@ -420,7 +443,7 @@ main(int argc, char **argv, char **env)
{
[[parser info] setObject: prev forKey: @"prev"];
}
prev = file;
ASSIGN(prev, file);
if (i < [args count] - 1)
{
unsigned j = i + 1;
@ -454,11 +477,8 @@ main(int argc, char **argv, char **env)
if ([mgr isReadableFileAtPath: gsdocfile] == YES)
{
CREATE_AUTORELEASE_POOL(pool);
GSXMLParser *parser;
AGSIndex *locRefs;
AGSHtml *html;
NSString *result;
parser = [GSXMLParser parserWithContentsOfFile: gsdocfile];
[parser substituteEntities: YES];
@ -477,30 +497,12 @@ main(int argc, char **argv, char **env)
locRefs = AUTORELEASE([AGSIndex new]);
[locRefs makeRefs: [[parser doc] root]];
if (pass == 1)
{
/*
* We only perform final outpu in pass 1
*/
html = AUTORELEASE([AGSHtml new]);
[html setGlobalRefs: prjRefs];
[html setLocalRefs: locRefs];
result = [html outputDocument: [[parser doc] root]];
if ([result writeToFile: htmlfile atomically: YES] == NO)
{
NSLog(@"Sorry unable to write %@", htmlfile);
}
}
else
{
/*
* We only accumulate index info in pass 0
* accumulate index info
*/
[indexer mergeRefs: [locRefs refs]];
[prjRefs mergeRefs: [locRefs refs]];
}
RELEASE(pool);
}
else if (isDocumentation)
{
NSLog(@"No readable documentation at '%@' ... skipping",
@ -512,21 +514,117 @@ main(int argc, char **argv, char **env)
NSLog(@"Unknown argument '%@' ... ignored", arg);
}
}
RELEASE(arp);
for (i = 1; i < [args count]; i++)
{
NSString *arg = [args objectAtIndex: i];
if ([arg hasPrefix: @"-"])
{
i++; // Skip next value ... it is a default.
}
else if ([arg hasSuffix: @".h"] == YES
|| [arg hasSuffix: @".m"] == YES
|| [arg hasSuffix: @".gsdoc"]== YES)
{
NSString *gsdocfile;
NSString *htmlfile;
NSString *ddir;
NSString *file;
NSString *generated;
NSDictionary *attrs;
NSDate *gDate;
NSDate *hDate;
if (pool != nil)
{
RELEASE(pool);
pool = [NSAutoreleasePool new];
}
file = [[arg lastPathComponent] stringByDeletingPathExtension];
ddir = documentationDirectory;
gsdocfile = [ddir stringByAppendingPathComponent: file];
gsdocfile = [gsdocfile stringByAppendingPathExtension: @"gsdoc"];
htmlfile = [ddir stringByAppendingPathComponent: file];
htmlfile = [htmlfile stringByAppendingPathExtension: @"html"];
/*
* When were the files last modified?
*/
attrs = [mgr fileAttributesAtPath: gsdocfile traverseLink: YES];
gDate = [attrs objectForKey: NSFileModificationDate];
AUTORELEASE(RETAIN(gDate));
attrs = [mgr fileAttributesAtPath: htmlfile traverseLink: YES];
hDate = [attrs objectForKey: NSFileModificationDate];
AUTORELEASE(RETAIN(hDate));
if ([mgr isReadableFileAtPath: gsdocfile] == YES)
{
if (hDate == nil || [gDate earlierDate: hDate] == hDate)
{
GSXMLParser *parser;
AGSIndex *locRefs;
AGSHtml *html;
parser = [GSXMLParser parserWithContentsOfFile: gsdocfile];
[parser substituteEntities: YES];
[parser doValidityChecking: YES];
if ([parser parse] == NO)
{
NSLog(@"WARNING %@ is not a valid document", gsdocfile);
}
if (![[[[parser doc] root] name] isEqualToString: @"gsdoc"])
{
NSLog(@"not a gsdoc document - because name node is %@",
[[[parser doc] root] name]);
return 1;
}
locRefs = AUTORELEASE([AGSIndex new]);
[locRefs makeRefs: [[parser doc] root]];
/*
* We perform final output
*/
html = AUTORELEASE([AGSHtml new]);
[html setGlobalRefs: prjRefs];
[html setLocalRefs: locRefs];
generated = [html outputDocument: [[parser doc] root]];
if ([generated writeToFile: htmlfile atomically: YES] == NO)
{
NSLog(@"Sorry unable to write %@", htmlfile);
}
}
}
else
{
NSLog(@"No readable documentation at '%@' ... skipping",
gsdocfile);
}
}
else
{
NSLog(@"Unknown argument '%@' ... ignored", arg);
}
}
RELEASE(pool);
DESTROY(up);
DESTROY(prev);
/*
* Save references.
*/
refsFile = [documentationDirectory stringByAppendingPathComponent:
projectName];
refsFile = [refsFile stringByAppendingPathExtension: @"gsdocidx"];
refsFile = [refsFile stringByAppendingPathExtension: @"igsdoc"];
if ([[prjRefs refs] writeToFile: refsFile atomically: YES] == NO)
{
NSLog(@"Sorry unable to write %@", refsFile);
}
RELEASE(pool);
RELEASE(outer);
return 0;
}