From fb2d96cadaacc63a1e71359e4bde45a86bfdd069 Mon Sep 17 00:00:00 2001 From: CaS Date: Thu, 29 Nov 2001 07:38:04 +0000 Subject: [PATCH] Implemented external referencing git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11569 72102866-910b-0410-8b05-ffd578937521 --- Tools/AGSHtml.m | 2 +- Tools/AGSIndex.h | 1 + Tools/AGSIndex.m | 33 ++++++++ Tools/autogsdoc.m | 192 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 216 insertions(+), 12 deletions(-) diff --git a/Tools/AGSHtml.m b/Tools/AGSHtml.m index b8baa65d7..d3cc6ad25 100644 --- a/Tools/AGSHtml.m +++ b/Tools/AGSHtml.m @@ -474,7 +474,7 @@ NSLog(@"Element '%@' not implemented", name); // FIXME else { sel = @"-"; - str = [NSString stringWithFormat: @"- (%@)", + str = [NSString stringWithFormat: @"- (%@) ", [self typeRef: str]]; } children = nil; diff --git a/Tools/AGSIndex.h b/Tools/AGSIndex.h index 8c641f806..793bb6e22 100644 --- a/Tools/AGSIndex.h +++ b/Tools/AGSIndex.h @@ -35,6 +35,7 @@ - (void) makeRefs: (GSXMLNode*)node; - (void) mergeRefs: (NSDictionary*)more; - (NSMutableDictionary*) refs; +- (void) setDirectory: (NSString*)path; - (void) setGlobalRef: (NSString*)ref type: (NSString*)type; - (void) setUnitRef: (NSString*)ref type: (NSString*)type; - (NSDictionary*) unitRef: (NSString*)ref type: (NSString*)type; diff --git a/Tools/AGSIndex.m b/Tools/AGSIndex.m index 4ebd2f1c1..40afafaaa 100644 --- a/Tools/AGSIndex.m +++ b/Tools/AGSIndex.m @@ -84,6 +84,29 @@ mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src) } } +static void +setDirectory(NSMutableDictionary *dict, NSString *path) +{ + NSArray *a = [dict allKeys]; + NSEnumerator *e = [a objectEnumerator]; + NSString *k; + + while ((k = [e nextObject]) != nil) + { + id o = [dict objectForKey: k]; + + if ([o isKindOfClass: [NSString class]] == YES) + { + o = [path stringByAppendingPathComponent: [o lastPathComponent]]; + [dict setObject: o forKey: k]; + } + else if ([o isKindOfClass: [NSDictionary class]] == YES) + { + setDirectory(o, path); + } + } +} + @implementation AGSIndex + (void) initialize @@ -316,6 +339,16 @@ mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src) return refs; } +- (void) setDirectory: (NSString*)path +{ + if (path != nil) + { + CREATE_AUTORELEASE_POOL(pool); + setDirectory(refs, path); + RELEASE(pool); + } +} + - (void) setGlobalRef: (NSString*)ref type: (NSString*)type { diff --git a/Tools/autogsdoc.m b/Tools/autogsdoc.m index 00b7f2a06..fab752d86 100644 --- a/Tools/autogsdoc.m +++ b/Tools/autogsdoc.m @@ -176,17 +176,55 @@ If this is not specified, headers are looked for relative to the current directory or using absolute path names if given. - Project + LocalProjects + This value is used to control the automatic inclusion of local + external projects into the indexing system for generation of + cross-references in final document output.
+ If set to 'None', then no local project references are done, + otherwise, the 'Local' GNUstep documentation directory is recursively + searched for files with a .igsdoc extension, and the + indexing information from those files is used.
+ The value of this string is also used to generate the filenames in + the cross reference ... if it is an empty string, the path to use + is assumed to be a file in the same directory where the igsdoc + file was found, otherwise it is used as a prefix to the name in + the index. +
+ Project May be used to specify the name of this project ... determines the name of the index reference file produced as part of the documentation to provide information enabling other projects to cross-reference to items in this project. + Projects + This value may be supplies as a dictionary containing the paths to + the igsdoc index/reference files used by external projects, along + with values to be used to map the filenames found in the indexes.
+ For example, if a project index (igsdoc) file says that the class + Foo is found in the file Foo, and the + path associated with that project index is /usr/doc/proj, + Then generated html output may reference the class as being in + /usr/doc/prj/Foo.html +
SourceDirectory May be used to specify the directory to be searched for header files. If this is not specified, headers are looked for relative to the current directory or using absolute path names if given. + SystemProjects + This value is used to control the automatic inclusion of system + external projects into the indexing system for generation of + cross-references in final document output.
+ If set to 'None', then no system project references are done, + otherwise, the 'System' GNUstep documentation directory is recursively + searched for files with a .igsdoc extension, and the + indexing information from those files is used.
+ The value of this string is also used to generate the filenames in + the cross reference ... if it is an empty string, the path to use + is assumed to be a file in the same directory where the igsdoc + file was found, otherwise it is used as a prefix to the name in + the index. +
Inter-document linkage @@ -227,14 +265,17 @@ main(int argc, char **argv, char **env) NSString *declared; NSString *headerDirectory; NSString *sourceDirectory; - NSString *projectName; + NSString *project; NSString *refsFile; + NSString *systemProjects; + NSString *localProjects; AGSIndex *prjRefs; AGSIndex *indexer; AGSParser *parser; AGSOutput *output; NSString *up = nil; NSString *prev = nil; + id o; CREATE_AUTORELEASE_POOL(outer); CREATE_AUTORELEASE_POOL(pool); @@ -244,13 +285,21 @@ main(int argc, char **argv, char **env) defs = [NSUserDefaults standardUserDefaults]; [defs registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys: - @"Untitled", @"ProjectName", + @"Untitled", @"Project", nil]]; - projectName = [defs stringForKey: @"ProjectName"]; - declared = [defs stringForKey: @"Declared"]; - + project = [defs stringForKey: @"Project"]; + localProjects = [defs stringForKey: @"LocalProjects"]; + if (localProjects == nil) + { + localProjects = @""; + } + systemProjects = [defs stringForKey: @"SystemProjects"]; + if (systemProjects == nil) + { + systemProjects = @""; + } projects = [defs dictionaryForKey: @"Projects"]; headerDirectory = [defs stringForKey: @"HeaderDirectory"]; @@ -285,6 +334,122 @@ main(int argc, char **argv, char **env) parser = [AGSParser new]; output = [AGSOutput new]; + /* + * Merge any external project references into the + * main cross reference index. + */ + + if ([systemProjects caseInsensitiveCompare: @"None"] != NSOrderedSame) + { + NSString *base = [NSSearchPathForDirectoriesInDomains( + NSDocumentationDirectory, NSSystemDomainMask, NO) lastObject]; + + base = [base stringByStandardizingPath]; + if (base != nil) + { + NSDirectoryEnumerator *enumerator = [mgr enumeratorAtPath: base]; + NSString *file; + + if ([systemProjects isEqual: @""] == YES) + { + systemProjects = base; // Absolute path + } + while ((file = [enumerator nextObject]) != nil) + { + NSString *ext = [file pathExtension]; + + if ([ext isEqualToString: @"igsdoc"] == YES) + { + NSString *key; + NSString *val; + + if (projects == nil) + { + projects = [NSMutableDictionary dictionary]; + } + key = [base stringByAppendingPathComponent: file]; + val = [file stringByDeletingLastPathComponent]; + val = [systemProjects stringByAppendingPathComponent: val]; + [projects setObject: val forKey: key]; + } + } + } + } + + if ([localProjects caseInsensitiveCompare: @"None"] != NSOrderedSame) + { + NSString *base = [NSSearchPathForDirectoriesInDomains( + NSDocumentationDirectory, NSLocalDomainMask, NO) lastObject]; + + base = [base stringByStandardizingPath]; + if (base != nil) + { + NSDirectoryEnumerator *enumerator = [mgr enumeratorAtPath: base]; + NSString *file; + + if ([localProjects isEqual: @""] == YES) + { + localProjects = base; // Absolute path + } + while ((file = [enumerator nextObject]) != nil) + { + NSString *ext = [file pathExtension]; + + if ([ext isEqualToString: @"igsdoc"] == YES) + { + NSString *key; + NSString *val; + + if (projects == nil) + { + projects = [NSMutableDictionary dictionary]; + } + key = [base stringByAppendingPathComponent: file]; + val = [file stringByDeletingLastPathComponent]; + val = [localProjects stringByAppendingPathComponent: val]; + [projects setObject: val forKey: key]; + } + } + } + } + + if (projects != nil) + { + NSEnumerator *e = [projects keyEnumerator]; + NSString *k; + + while ((k = [e nextObject]) != nil) + { + NSDictionary *dict; + + if ([mgr isReadableFileAtPath: k] == NO + || (dict = [[NSDictionary alloc] initWithContentsOfFile: k]) == nil) + { + NSLog(@"Unable to read project file '%@'", k); + } + else + { + AGSIndex *tmp; + NSString *p; + + tmp = [AGSIndex new]; + [tmp mergeRefs: dict]; + RELEASE(dict); + /* + * Adjust path to external project files ... + */ + p = [projects objectForKey: k]; + if ([p isEqual: @""] == YES) + { + p = [k stringByDeletingLastPathComponent]; + } + [tmp setDirectory: p]; + [indexer mergeRefs: [tmp refs]]; + RELEASE(tmp); + } + } + } + args = [proc arguments]; for (i = 1; i < [args count]; i++) @@ -483,6 +648,7 @@ main(int argc, char **argv, char **env) parser = [GSXMLParser parserWithContentsOfFile: gsdocfile]; [parser substituteEntities: YES]; [parser doValidityChecking: YES]; + [parser keepBlanks: NO]; if ([parser parse] == NO) { NSLog(@"WARNING %@ is not a valid document", gsdocfile); @@ -498,9 +664,8 @@ main(int argc, char **argv, char **env) [locRefs makeRefs: [[parser doc] root]]; /* - * accumulate index info + * accumulate index info in project references */ - [indexer mergeRefs: [locRefs refs]]; [prjRefs mergeRefs: [locRefs refs]]; } else if (isDocumentation) @@ -515,6 +680,11 @@ main(int argc, char **argv, char **env) } } + /* + * accumulate project index info into global index + */ + [indexer mergeRefs: [prjRefs refs]]; + for (i = 1; i < [args count]; i++) { NSString *arg = [args objectAtIndex: i]; @@ -570,6 +740,7 @@ main(int argc, char **argv, char **env) parser = [GSXMLParser parserWithContentsOfFile: gsdocfile]; [parser substituteEntities: YES]; [parser doValidityChecking: YES]; + [parser keepBlanks: NO]; if ([parser parse] == NO) { NSLog(@"WARNING %@ is not a valid document", gsdocfile); @@ -588,7 +759,7 @@ main(int argc, char **argv, char **env) * We perform final output */ html = AUTORELEASE([AGSHtml new]); - [html setGlobalRefs: prjRefs]; + [html setGlobalRefs: indexer]; [html setLocalRefs: locRefs]; generated = [html outputDocument: [[parser doc] root]]; if ([generated writeToFile: htmlfile atomically: YES] == NO) @@ -616,8 +787,7 @@ main(int argc, char **argv, char **env) /* * Save references. */ - refsFile = [documentationDirectory stringByAppendingPathComponent: - projectName]; + refsFile = [documentationDirectory stringByAppendingPathComponent: project]; refsFile = [refsFile stringByAppendingPathExtension: @"igsdoc"]; if ([[prjRefs refs] writeToFile: refsFile atomically: YES] == NO) {