Skip to content

Commit

Permalink
add project authors in index
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Dec 21, 2023
1 parent 9acd9f8 commit 695b650
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Tools/AGSParser.m: Replace GS_GENERIC macros in method types etc
with the basic type name.
* Tools/AGSIndex.h:
* Tools/AGSIndex.m: Create index of all authors in the project

2023-12-09 Richard Frith-Macdonald <[email protected]>

Expand Down
2 changes: 2 additions & 0 deletions Tools/AGSIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
unsigned ssect;
unsigned sssect;
}
- (NSDictionary*) authors;
- (NSArray*) find: (NSString*)key;
- (NSString*) globalRef: (NSString*)ref type: (NSString*)type;
- (void) makeRefs: (GSXMLNode*)node;
Expand All @@ -50,6 +51,7 @@
- (NSArray*) methodsInUnit: (NSString*)aUnit;
- (NSMutableDictionary*) refs;
- (void) setDirectory: (NSString*)path;
- (void) setEmail: (NSString*)address forAuthor: (NSString*)name;
- (void) setGlobalRef: (NSString*)ref type: (NSString*)type;
- (void) setOutputs: (NSArray*)a forHeader: (NSString*)h;
- (void) setRelationship: (NSString*)r from: (NSString*)from to: (NSString*)to;
Expand Down
77 changes: 75 additions & 2 deletions Tools/AGSIndex.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,23 @@
}
else if ([d isEqual: s] == NO)
{
if (override == YES)
if ([[stack firstObject] isEqualToString: @"author"])
{
NSMutableArray *m = AUTORELEASE([s mutableCopy]);
NSUInteger c = [d count];

while (c-- > 0)
{
NSString *e = [d objectAtIndex: c];

if (NO == [m containsObject: e])
{
[m addObject: e];
}
}
[dst setObject: m forKey: k];
}
else if (override == YES)
{
[dst setObject: s forKey: k];
}
Expand Down Expand Up @@ -291,7 +307,32 @@ - (void) makeRefs: (GSXMLNode*)node
[self setGlobalRef: base type: @"tool"];
}

if ([name isEqual: @"category"] == YES)
if ([name isEqual: @"author"] == YES)
{
NSString *author = [prop objectForKey: @"name"];

if ([author length] > 0)
{
GSXMLNode *tmp = [node firstChild];

[self setEmail: nil forAuthor: author];
while (tmp)
{
if ([[tmp name] isEqual: @"email"])
{
NSDictionary *prop = [tmp attributes];

name = [prop objectForKey: @"address"];
if ([name length] > 0)
{
[self setEmail: name forAuthor: author];
}
}
tmp = [tmp next];
}
}
}
else if ([name isEqual: @"category"] == YES)
{
newUnit = YES;
classname = [prop objectForKey: @"class"];
Expand Down Expand Up @@ -597,6 +638,38 @@ - (void) setDirectory: (NSString*)path
}
}

- (NSDictionary*) authors
{
return [refs objectForKey: @"author"];
}

/**
* Set up an array of email addresses for author.
*/
- (void) setEmail: (NSString*)address forAuthor: (NSString*)name
{
NSMutableDictionary *dict;
NSMutableArray *array;

dict = [refs objectForKey: @"author"];
if (dict == nil)
{
dict = [NSMutableDictionary new];
[refs setObject: dict forKey: @"author"];
RELEASE(dict);
}
if (nil == (array = [dict objectForKey: name]))
{
array = [NSMutableArray array];
[dict setObject: array forKey: name];
}
address = [address lowercaseString];
if (address != nil && NO == [array containsObject: address])
{
[array addObject: address];
}
}

- (void) setGlobalRef: (NSString*)ref
type: (NSString*)type
{
Expand Down

0 comments on commit 695b650

Please sign in to comment.