From 43bcaac3ada9588a3c406ecc5161feb41e80939a Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Tue, 16 Feb 2010 19:51:52 +0000 Subject: [PATCH] Attempt to allow documentation to be generated for uninstalled base package. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29655 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 10 +++++ Headers/Additions/GNUstepBase/GSXML.h | 1 + Source/Additions/GSXML.m | 56 ++++++++++++++++++++++----- Source/DocMakefile | 1 + Tools/autogsdoc.m | 6 +++ 5 files changed, 64 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d3b03b60..47b929197 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-02-16 Richard Frith-Macdonald + + * Headers/Additions/GNUstepBase/GSXML.h: + * Source/Additions/GSXML.m: new method to allow an additional DTD + directory to be set for the parser. + * Tools/autogsdoc.m: Add flag to allow command line setting of extra + DTD directory. + * Source/DocMakefile: Set extra DTD directory to the Tools directory + so that gsdoc DTDs can be found even when they haven't been installed. + 2010-02-16 Niels Grewe * Source/Additions/GSXML.m: diff --git a/Headers/Additions/GNUstepBase/GSXML.h b/Headers/Additions/GNUstepBase/GSXML.h index 1fcd62b55..15b67663c 100644 --- a/Headers/Additions/GNUstepBase/GSXML.h +++ b/Headers/Additions/GNUstepBase/GSXML.h @@ -206,6 +206,7 @@ extern "C" { withContentsOfURL: (NSURL*)url; + (GSXMLParser*) parserWithSAXHandler: (GSSAXHandler*)handler withData: (NSData*)data; ++ (void) setDTDs: (NSString*)aPath; + (NSString*) xmlEncodingStringForStringEncoding: (NSStringEncoding)encoding; - (void) abortParsing; diff --git a/Source/Additions/GSXML.m b/Source/Additions/GSXML.m index 7305a1b8a..e2e43907d 100644 --- a/Source/Additions/GSXML.m +++ b/Source/Additions/GSXML.m @@ -1619,6 +1619,10 @@ static NSMapTable *nodeNames = 0; */ @implementation GSXMLParser +/* To override location for DTDs + */ +static NSString *dtdPath = nil; + static NSString *endMarker = @"At end of incremental parse"; + (void) initialize @@ -1777,6 +1781,15 @@ static NSString *endMarker = @"At end of incremental parse"; withData: data]); } +/** Sets a directory in which to look for DTDs when resolving external + * references. Can be used whjen DTDs have not been installed in the + * normal locatioons. + */ ++ (void) setDTDs: (NSString*)aPath +{ + ASSIGNCOPY(dtdPath, aPath); +} + /** * Return the name of the string encoding (for XML) to use for the * specified OpenStep encoding. @@ -2541,16 +2554,28 @@ loadEntityFunction(void *ctx, range: r]; } + if (dtdPath != nil) + { + found = [dtdPath stringByAppendingPathComponent: name]; + found = [found stringByAppendingPathExtension: @"dtd"]; + if (![[NSFileManager defaultManager] fileExistsAtPath: found]) + { + found = nil; + } + } + if (found == nil) + { #ifdef GNUSTEP - found = [NSBundle pathForLibraryResource: name - ofType: @"dtd" - inDirectory: @"DTDs"]; + found = [NSBundle pathForLibraryResource: name + ofType: @"dtd" + inDirectory: @"DTDs"]; #else - found = [[NSBundle bundleForClass: NSClassFromString(@"GSXMLNode")] - pathForResource: name - ofType: @"dtd" - inDirectory: @"DTDs"]; + found = [[NSBundle bundleForClass: [GSXMLNode class] + pathForResource: name + ofType: @"dtd" + inDirectory: @"DTDs"]; #endif + } if (found == nil) { NSLog(@"unable to find GNUstep DTD - '%@' for '%s'", name, eid); @@ -2566,9 +2591,20 @@ loadEntityFunction(void *ctx, */ if (file == nil) { - file = [[NSBundle mainBundle] pathForResource: local - ofType: @"" - inDirectory: @"DTDs"]; + if (dtdPath != nil) + { + file = [dtdPath stringByAppendingPathComponent: local]; + if (![[NSFileManager defaultManager] fileExistsAtPath: local]) + { + file = nil; + } + } + if (file == nil) + { + file = [[NSBundle mainBundle] pathForResource: local + ofType: @"" + inDirectory: @"DTDs"]; + } if (file == nil) { file = [NSBundle pathForLibraryResource: local diff --git a/Source/DocMakefile b/Source/DocMakefile index 411f613fc..e22d617ce 100644 --- a/Source/DocMakefile +++ b/Source/DocMakefile @@ -202,6 +202,7 @@ BaseAdditions_AGSDOC_FLAGS = \ -HeaderDirectory ../Headers/Additions/GNUstepBase \ -Declared GNUstepBase \ -Standards YES \ + -DTDs ../Tools \ -ConstantsTemplate TypesAndConstants \ -FunctionsTemplate Functions \ -MacrosTemplate Functions \ diff --git a/Tools/autogsdoc.m b/Tools/autogsdoc.m index 2530c2b9f..864c5327a 100644 --- a/Tools/autogsdoc.m +++ b/Tools/autogsdoc.m @@ -809,6 +809,8 @@ main(int argc, char **argv, char **env) @"\t\tBOOL\t(NO)\n\tif YES, create documentation pages " @"for display in HTML frames", @"MakeFrames", + @"\t\tString\t(nil)\n\tIf set, look for DTDs in the given directory", + @"DTDs", nil]; argSet = [NSSet setWithArray: [argsRecognized allKeys]]; argsGiven = [[NSProcessInfo processInfo] arguments]; @@ -853,6 +855,10 @@ main(int argc, char **argv, char **env) mgr = [NSFileManager defaultManager]; + if ([GSXMLParser respondsToSelector: @selector(setDTDs:)]) + { + [GSXMLParser setDTDs: [defs stringForKey: @"DTDs"]]; + } verbose = [defs boolForKey: @"Verbose"]; warn = [defs boolForKey: @"Warn"];