diff --git a/Tools/AGSParser.m b/Tools/AGSParser.m index 1b2baaa4c..fbf12349c 100644 --- a/Tools/AGSParser.m +++ b/Tools/AGSParser.m @@ -796,7 +796,8 @@ fail: /** * We initially assume that the location of a source file is the * same as the header, but if there is no file at that location, - * we expect the source to be in the current directory instead. + * we expect the source to be in the documentatation directory + * or the current directory instead. */ path = [fileName stringByDeletingPathExtension]; path = [path stringByAppendingPathExtension: @"m"]; @@ -805,7 +806,23 @@ fail: path = [path lastPathComponent]; if ([mgr isReadableFileAtPath: path] == NO) { - path = nil; // No default source file found. + NSUserDefaults *defs; + NSString *ddir; + + defs = [NSUserDefaults standardUserDefaults]; + ddir = [defs stringForKey: @"DocumentationDirectory"]; + if ([ddir length] > 0) + { + path = [ddir stringByAppendingPathComponent: path]; + if ([mgr isReadableFileAtPath: path] == NO) + { + path = nil; // No default source file found. + } + } + else + { + path = nil; // No default source file found. + } } } if (path != nil) @@ -2645,36 +2662,60 @@ fail: * header. */ mgr = [NSFileManager defaultManager]; - if ([mgr isReadableFileAtPath: line] == NO) + if ([line isAbsolutePath] == YES) { - if ([line isAbsolutePath] == YES) + if ([mgr isReadableFileAtPath: line] == NO) { [self log: @"AutogsdocSource: %@ not found!", line]; line = nil; } - else - { - NSString *p; + } + else + { + NSString *p; - /* - * Try forming a path relative to the - * header file if the source file was not - * found in the specified location. - */ - p = [info objectForKey: @"Header"]; - p = [p stringByDeletingLastPathComponent]; - p = [p stringByAppendingPathComponent: line]; - if ([mgr isReadableFileAtPath: p] == NO) + /* + * Try forming a path relative to the header. + */ + p = [info objectForKey: @"Header"]; + p = [p stringByDeletingLastPathComponent]; + p = [p stringByAppendingPathComponent: line]; + if ([mgr isReadableFileAtPath: p] == YES) + { + line = p; + } + else if ([mgr isReadableFileAtPath: line] == NO) + { + NSUserDefaults *defs; + NSString *ddir; + NSString *old = p; + + defs = [NSUserDefaults standardUserDefaults]; + ddir = [defs stringForKey: + @"DocumentationDirectory"]; + if ([ddir length] > 0) { - [self log: @"AutogsdocSource: %@ not " - @"found (tried %@ too)!", - line, p]; - line = nil; + p = [ddir stringByAppendingPathComponent: + line]; + if ([mgr isReadableFileAtPath: p] == YES) + { + line = p; + } + else + { + [self log: @"AutogsdocSource: %@ not " + @"found (tried %@ and %@ too)!", + line, old, p]; + line = nil; + } } else { - line = p; + [self log: @"AutogsdocSource: %@ not " + @"found (tried %@ too)!", + line, old]; + line = nil; } } } diff --git a/Tools/autogsdoc.m b/Tools/autogsdoc.m index 93b94e416..4406218af 100644 --- a/Tools/autogsdoc.m +++ b/Tools/autogsdoc.m @@ -29,9 +29,10 @@

The simple way to use this is to run the command with one or more header file names as arguments ... the tool will automatically - parse corresponding source files in the same directory (or the - directory specified using the DocumentationDirectory default), - and produce gsdoc files as output.
+ parse corresponding source files in the same directory as the + headers (or the current directory, or the directory specified + using the DocumentationDirectory default), and produce gsdoc + files as output.

Even without any human assistance, this tool will produce skeleton @@ -61,9 +62,10 @@ multiple source files.
If a file name is absolute, it is used just as supplied.
If on the other hand, it is a relative path, the software looks for - the source file first relative to the direcotory in which autogsdoc - is running and then, if not found there, relative to the directory - in which the header file is located. + the source file first relative to the location of the header file, + and if not found there, relative to the current directory in which + autogsdoc is running, and finally relative to the directory + specified by the DocumentationDirectory default. <abstract> An abstract of the content of the document ... placed in the head