mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@12508 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f537c83c85
commit
3fb2ea3e30
3 changed files with 113 additions and 61 deletions
|
@ -39,9 +39,7 @@
|
||||||
to: (unsigned)end
|
to: (unsigned)end
|
||||||
maxSize: (unsigned)limit
|
maxSize: (unsigned)limit
|
||||||
output: (NSMutableString*)buf;
|
output: (NSMutableString*)buf;
|
||||||
- (BOOL) output: (NSDictionary*)d
|
- (NSArray*) output: (NSDictionary*)d;
|
||||||
file: (NSString*)name
|
|
||||||
directory: (NSString*)dest;
|
|
||||||
- (void) outputDecl: (NSDictionary*)d
|
- (void) outputDecl: (NSDictionary*)d
|
||||||
kind: (NSString*)kind
|
kind: (NSString*)kind
|
||||||
to: (NSMutableString*)str;
|
to: (NSMutableString*)str;
|
||||||
|
|
|
@ -23,9 +23,8 @@
|
||||||
#include "AGSOutput.h"
|
#include "AGSOutput.h"
|
||||||
|
|
||||||
@interface AGSOutput (Private)
|
@interface AGSOutput (Private)
|
||||||
- (BOOL) mergeMarkup: (NSString*)markup
|
- (NSString*) mergeMarkup: (NSString*)markup
|
||||||
ofKind: (NSString*)kind
|
ofKind: (NSString*)kind;
|
||||||
directory: (NSString*)dest;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static NSString *escapeType(NSString *str)
|
static NSString *escapeType(NSString *str)
|
||||||
|
@ -198,12 +197,10 @@ static BOOL snuggleStart(NSString *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a string containing a gsdoc document generated from d (the
|
* Return an array containing the names of any files modified as
|
||||||
* parse tree)
|
* a result of outputing the specified data structure.
|
||||||
*/
|
*/
|
||||||
- (BOOL) output: (NSDictionary*)d
|
- (NSArray*) output: (NSDictionary*)d
|
||||||
file: (NSString*)name
|
|
||||||
directory: (NSString*)dest
|
|
||||||
{
|
{
|
||||||
NSMutableString *str = [NSMutableString stringWithCapacity: 10240];
|
NSMutableString *str = [NSMutableString stringWithCapacity: 10240];
|
||||||
NSDictionary *classes;
|
NSDictionary *classes;
|
||||||
|
@ -213,11 +210,28 @@ static BOOL snuggleStart(NSString *t)
|
||||||
NSDictionary *types;
|
NSDictionary *types;
|
||||||
NSDictionary *variables;
|
NSDictionary *variables;
|
||||||
NSDictionary *constants;
|
NSDictionary *constants;
|
||||||
|
NSMutableArray *files;
|
||||||
NSArray *authors;
|
NSArray *authors;
|
||||||
|
NSString *base;
|
||||||
NSString *tmp;
|
NSString *tmp;
|
||||||
|
NSString *file;
|
||||||
|
NSString *dest;
|
||||||
unsigned chapters = 0;
|
unsigned chapters = 0;
|
||||||
|
|
||||||
|
files = [NSMutableArray arrayWithCapacity: 5];
|
||||||
|
|
||||||
info = d;
|
info = d;
|
||||||
|
base = [info objectForKey: @"base"];
|
||||||
|
file = base;
|
||||||
|
if ([[file pathExtension] isEqualToString: @"gsdoc"] == NO)
|
||||||
|
{
|
||||||
|
file = [file stringByAppendingPathExtension: @"gsdoc"];
|
||||||
|
}
|
||||||
|
dest = [info objectForKey: @"directory"];
|
||||||
|
if ([dest length] > 0 && [file isAbsolutePath] == NO)
|
||||||
|
{
|
||||||
|
file = [dest stringByAppendingPathComponent: file];
|
||||||
|
}
|
||||||
|
|
||||||
classes = [info objectForKey: @"Classes"];
|
classes = [info objectForKey: @"Classes"];
|
||||||
categories = [info objectForKey: @"Categories"];
|
categories = [info objectForKey: @"Categories"];
|
||||||
|
@ -233,11 +247,10 @@ static BOOL snuggleStart(NSString *t)
|
||||||
[str appendString: @"\"http://www.gnustep.org/gsdoc-0_6_7.xml\">\n"];
|
[str appendString: @"\"http://www.gnustep.org/gsdoc-0_6_7.xml\">\n"];
|
||||||
[str appendFormat: @"<gsdoc"];
|
[str appendFormat: @"<gsdoc"];
|
||||||
|
|
||||||
tmp = [info objectForKey: @"base"];
|
if (base != nil)
|
||||||
if (tmp != nil)
|
|
||||||
{
|
{
|
||||||
[str appendString: @" base=\""];
|
[str appendString: @" base=\""];
|
||||||
[str appendString: tmp];
|
[str appendString: base];
|
||||||
[str appendString: @"\""];
|
[str appendString: @"\""];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,10 +433,9 @@ static BOOL snuggleStart(NSString *t)
|
||||||
unsigned c = [types count];
|
unsigned c = [types count];
|
||||||
|
|
||||||
[m appendString: @" <chapter>\n"];
|
[m appendString: @" <chapter>\n"];
|
||||||
[m appendString: @" <heading>Types</heading>\n"];
|
[m appendFormat: @" <heading>%@ types</heading>\n", base];
|
||||||
[m appendString: @" <p></p>\n"];
|
[m appendString: @" <p></p>\n"];
|
||||||
|
|
||||||
chapters++;
|
|
||||||
names = [types allKeys];
|
names = [types allKeys];
|
||||||
names = [names sortedArrayUsingSelector: @selector(compare:)];
|
names = [names sortedArrayUsingSelector: @selector(compare:)];
|
||||||
for (i = 0; i < c; i++)
|
for (i = 0; i < c; i++)
|
||||||
|
@ -436,11 +448,16 @@ static BOOL snuggleStart(NSString *t)
|
||||||
|
|
||||||
[m appendString: @" </chapter>\n"];
|
[m appendString: @" </chapter>\n"];
|
||||||
|
|
||||||
if ([self mergeMarkup: m ofKind: @"Typedefs" directory: dest] == NO)
|
tmp = [self mergeMarkup: m ofKind: @"Typedefs"];
|
||||||
|
if (tmp == nil)
|
||||||
{
|
{
|
||||||
[str appendString: m];
|
[str appendString: m];
|
||||||
chapters++;
|
chapters++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[files addObject: tmp];
|
||||||
|
}
|
||||||
RELEASE(m);
|
RELEASE(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,10 +469,9 @@ static BOOL snuggleStart(NSString *t)
|
||||||
unsigned c = [constants count];
|
unsigned c = [constants count];
|
||||||
|
|
||||||
[m appendString: @" <chapter>\n"];
|
[m appendString: @" <chapter>\n"];
|
||||||
[m appendString: @" <heading>Constants</heading>\n"];
|
[m appendFormat: @" <heading>%@ constants</heading>\n", base];
|
||||||
[m appendString: @" <p></p>\n"];
|
[m appendString: @" <p></p>\n"];
|
||||||
|
|
||||||
chapters++;
|
|
||||||
names = [constants allKeys];
|
names = [constants allKeys];
|
||||||
names = [names sortedArrayUsingSelector: @selector(compare:)];
|
names = [names sortedArrayUsingSelector: @selector(compare:)];
|
||||||
for (i = 0; i < c; i++)
|
for (i = 0; i < c; i++)
|
||||||
|
@ -468,11 +484,16 @@ static BOOL snuggleStart(NSString *t)
|
||||||
|
|
||||||
[m appendString: @" </chapter>\n"];
|
[m appendString: @" </chapter>\n"];
|
||||||
|
|
||||||
if ([self mergeMarkup: m ofKind: @"Constants" directory: dest] == NO)
|
tmp = [self mergeMarkup: m ofKind: @"Constants"];
|
||||||
|
if (tmp == nil)
|
||||||
{
|
{
|
||||||
[str appendString: m];
|
[str appendString: m];
|
||||||
chapters++;
|
chapters++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[files addObject: tmp];
|
||||||
|
}
|
||||||
RELEASE(m);
|
RELEASE(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,10 +505,9 @@ static BOOL snuggleStart(NSString *t)
|
||||||
unsigned c = [variables count];
|
unsigned c = [variables count];
|
||||||
|
|
||||||
[m appendString: @" <chapter>\n"];
|
[m appendString: @" <chapter>\n"];
|
||||||
[m appendString: @" <heading>Variables</heading>\n"];
|
[m appendFormat: @" <heading>%@ variables</heading>\n", base];
|
||||||
[m appendString: @" <p></p>\n"];
|
[m appendString: @" <p></p>\n"];
|
||||||
|
|
||||||
chapters++;
|
|
||||||
names = [variables allKeys];
|
names = [variables allKeys];
|
||||||
names = [names sortedArrayUsingSelector: @selector(compare:)];
|
names = [names sortedArrayUsingSelector: @selector(compare:)];
|
||||||
for (i = 0; i < c; i++)
|
for (i = 0; i < c; i++)
|
||||||
|
@ -500,11 +520,16 @@ static BOOL snuggleStart(NSString *t)
|
||||||
|
|
||||||
[m appendString: @" </chapter>\n"];
|
[m appendString: @" </chapter>\n"];
|
||||||
|
|
||||||
if ([self mergeMarkup: m ofKind: @"Variables" directory: dest] == NO)
|
tmp = [self mergeMarkup: m ofKind: @"Variables"];
|
||||||
|
if (tmp == nil)
|
||||||
{
|
{
|
||||||
[str appendString: m];
|
[str appendString: m];
|
||||||
chapters++;
|
chapters++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[files addObject: tmp];
|
||||||
|
}
|
||||||
RELEASE(m);
|
RELEASE(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +541,7 @@ static BOOL snuggleStart(NSString *t)
|
||||||
unsigned c = [functions count];
|
unsigned c = [functions count];
|
||||||
|
|
||||||
[m appendString: @" <chapter>\n"];
|
[m appendString: @" <chapter>\n"];
|
||||||
[m appendString: @" <heading>Functions</heading>\n"];
|
[m appendFormat: @" <heading>%@ functions</heading>\n", base];
|
||||||
[m appendString: @" <p></p>\n"];
|
[m appendString: @" <p></p>\n"];
|
||||||
|
|
||||||
names = [functions allKeys];
|
names = [functions allKeys];
|
||||||
|
@ -530,34 +555,40 @@ static BOOL snuggleStart(NSString *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
[m appendString: @" </chapter>\n"];
|
[m appendString: @" </chapter>\n"];
|
||||||
if ([self mergeMarkup: m ofKind: @"Functions" directory: dest] == NO)
|
tmp = [self mergeMarkup: m ofKind: @"Functions"];
|
||||||
|
if (tmp == nil)
|
||||||
{
|
{
|
||||||
[str appendString: m];
|
[str appendString: m];
|
||||||
chapters++;
|
chapters++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[files addObject: tmp];
|
||||||
|
}
|
||||||
RELEASE(m);
|
RELEASE(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chapters == 0)
|
if (chapters > 0)
|
||||||
{
|
{
|
||||||
// We must have at least one chapter!
|
// Output document appendix if available.
|
||||||
[str appendString: @" <chapter>\n"];
|
tmp = [info objectForKey: @"back"];
|
||||||
[str appendString:
|
if (tmp != nil)
|
||||||
@" <heading>No contents found by autogsdoc</heading>\n"];
|
{
|
||||||
[str appendString: @" <p></p>\n"];
|
[self reformat: tmp withIndent: 4 to: str];
|
||||||
[str appendString: @" </chapter>\n"];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Output document appendix if available.
|
[str appendString: @" </body>\n"];
|
||||||
tmp = [info objectForKey: @"back"];
|
[str appendString: @"</gsdoc>\n"];
|
||||||
if (tmp != nil)
|
if ([str writeToFile: file atomically: YES] == YES)
|
||||||
{
|
{
|
||||||
[self reformat: tmp withIndent: 4 to: str];
|
[files addObject: file];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
files = nil;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return files;
|
||||||
[str appendString: @" </body>\n"];
|
|
||||||
[str appendString: @"</gsdoc>\n"];
|
|
||||||
return [str writeToFile: name atomically: YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1882,9 +1913,8 @@ static BOOL snuggleStart(NSString *t)
|
||||||
|
|
||||||
|
|
||||||
@implementation AGSOutput (Private)
|
@implementation AGSOutput (Private)
|
||||||
- (BOOL) mergeMarkup: (NSString*)markup
|
- (NSString*) mergeMarkup: (NSString*)markup
|
||||||
ofKind: (NSString*)kind
|
ofKind: (NSString*)kind
|
||||||
directory: (NSString*)dest
|
|
||||||
{
|
{
|
||||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||||
NSString *key = [kind stringByAppendingString: @"Template"];
|
NSString *key = [kind stringByAppendingString: @"Template"];
|
||||||
|
@ -1897,14 +1927,16 @@ static BOOL snuggleStart(NSString *t)
|
||||||
NSRange range;
|
NSRange range;
|
||||||
NSRange start;
|
NSRange start;
|
||||||
NSRange end;
|
NSRange end;
|
||||||
|
NSString *dest;
|
||||||
|
|
||||||
|
dest = [info objectForKey: @"directory"];
|
||||||
if ([name length] == 0)
|
if ([name length] == 0)
|
||||||
{
|
{
|
||||||
return NO; // No common document.
|
return nil; // No common document.
|
||||||
}
|
}
|
||||||
|
|
||||||
file = [name stringByAppendingPathExtension: @"gsdoc"];
|
file = [name stringByAppendingPathExtension: @"gsdoc"];
|
||||||
if (dest != nil && [file isAbsolutePath] == NO)
|
if ([dest length] > 0 && [file isAbsolutePath] == NO)
|
||||||
{
|
{
|
||||||
file = [dest stringByAppendingPathComponent: file];
|
file = [dest stringByAppendingPathComponent: file];
|
||||||
}
|
}
|
||||||
|
@ -1944,7 +1976,7 @@ static BOOL snuggleStart(NSString *t)
|
||||||
[str appendString: @" <head>\n"];
|
[str appendString: @" <head>\n"];
|
||||||
[str appendString: @" <title>"];
|
[str appendString: @" <title>"];
|
||||||
[str appendString: kind];
|
[str appendString: kind];
|
||||||
[str appendString: @"<\title>\n"];
|
[str appendString: @"</title>\n"];
|
||||||
tmp = [NSString stringWithFormat: @"Generated by %@", NSUserName()];
|
tmp = [NSString stringWithFormat: @"Generated by %@", NSUserName()];
|
||||||
[str appendString: @" <author name=\""];
|
[str appendString: @" <author name=\""];
|
||||||
[str appendString: tmp];
|
[str appendString: tmp];
|
||||||
|
@ -1959,7 +1991,7 @@ static BOOL snuggleStart(NSString *t)
|
||||||
/*
|
/*
|
||||||
* Locate start and end points for all markup of this 'kind'.
|
* Locate start and end points for all markup of this 'kind'.
|
||||||
*/
|
*/
|
||||||
tmp = [NSString stringWithFormat: @"<!--Start%@-->", kind];
|
tmp = [NSString stringWithFormat: @"<!--Start%@-->\n", kind];
|
||||||
start = [str rangeOfString: tmp];
|
start = [str rangeOfString: tmp];
|
||||||
if (start.length == 0)
|
if (start.length == 0)
|
||||||
{
|
{
|
||||||
|
@ -1972,7 +2004,7 @@ static BOOL snuggleStart(NSString *t)
|
||||||
[str insertString: tmp atIndex: start.location];
|
[str insertString: tmp atIndex: start.location];
|
||||||
start.length = [tmp length];
|
start.length = [tmp length];
|
||||||
}
|
}
|
||||||
tmp = [NSString stringWithFormat: @"<!--End%@-->", kind];
|
tmp = [NSString stringWithFormat: @"<!--End%@-->\n", kind];
|
||||||
end = [str rangeOfString: tmp];
|
end = [str rangeOfString: tmp];
|
||||||
if (end.length == 0)
|
if (end.length == 0)
|
||||||
{
|
{
|
||||||
|
@ -1989,7 +2021,7 @@ static BOOL snuggleStart(NSString *t)
|
||||||
/*
|
/*
|
||||||
* Now locate start and end points for markup for this file.
|
* Now locate start and end points for markup for this file.
|
||||||
*/
|
*/
|
||||||
tmp = [NSString stringWithFormat: @"<!--Start%@%@-->", base, kind];
|
tmp = [NSString stringWithFormat: @"<!--Start%@%@-->\n", base, kind];
|
||||||
start = [str rangeOfString: tmp];
|
start = [str rangeOfString: tmp];
|
||||||
if (start.length == 0)
|
if (start.length == 0)
|
||||||
{
|
{
|
||||||
|
@ -1997,7 +2029,7 @@ static BOOL snuggleStart(NSString *t)
|
||||||
start.length = [tmp length];
|
start.length = [tmp length];
|
||||||
[str insertString: tmp atIndex: end.location];
|
[str insertString: tmp atIndex: end.location];
|
||||||
}
|
}
|
||||||
tmp = [NSString stringWithFormat: @"<!--End%@%@-->", base, kind];
|
tmp = [NSString stringWithFormat: @"<!--End%@%@-->\n", base, kind];
|
||||||
end = [str rangeOfString: tmp];
|
end = [str rangeOfString: tmp];
|
||||||
if (end.length == 0)
|
if (end.length == 0)
|
||||||
{
|
{
|
||||||
|
@ -2012,8 +2044,9 @@ static BOOL snuggleStart(NSString *t)
|
||||||
if ([str writeToFile: file atomically: YES] == NO)
|
if ([str writeToFile: file atomically: YES] == NO)
|
||||||
{
|
{
|
||||||
NSLog(@"Unable to write %@ markup to %@", kind, file);
|
NSLog(@"Unable to write %@ markup to %@", kind, file);
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
return YES;
|
return file;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -591,6 +591,8 @@ main(int argc, char **argv, char **env)
|
||||||
|
|
||||||
if (gDate == nil || [sDate earlierDate: gDate] == gDate)
|
if (gDate == nil || [sDate earlierDate: gDate] == gDate)
|
||||||
{
|
{
|
||||||
|
NSArray *modified;
|
||||||
|
|
||||||
if (showDependencies == YES)
|
if (showDependencies == YES)
|
||||||
{
|
{
|
||||||
NSLog(@"%@: source %@, gsdoc %@ ==> regenerate",
|
NSLog(@"%@: source %@, gsdoc %@ ==> regenerate",
|
||||||
|
@ -639,6 +641,8 @@ main(int argc, char **argv, char **env)
|
||||||
* Set up linkage for this file.
|
* Set up linkage for this file.
|
||||||
*/
|
*/
|
||||||
[[parser info] setObject: file forKey: @"base"];
|
[[parser info] setObject: file forKey: @"base"];
|
||||||
|
[[parser info] setObject: documentationDirectory
|
||||||
|
forKey: @"directory"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only produce linkage if the up link is not empty.
|
* Only produce linkage if the up link is not empty.
|
||||||
|
@ -649,18 +653,35 @@ main(int argc, char **argv, char **env)
|
||||||
[[parser info] setObject: up forKey: @"up"];
|
[[parser info] setObject: up forKey: @"up"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([output output: [parser info]
|
modified = [output output: [parser info]];
|
||||||
file: gsdocfile
|
if (modified == nil)
|
||||||
directory: documentationDirectory] == NO)
|
|
||||||
{
|
{
|
||||||
NSLog(@"Sorry unable to write %@", gsdocfile);
|
NSLog(@"Sorry unable to write %@", gsdocfile);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned c = [modified count];
|
||||||
|
|
||||||
|
while (c-- > 0)
|
||||||
|
{
|
||||||
|
NSString *f;
|
||||||
|
|
||||||
|
f = [[modified objectAtIndex: c] lastPathComponent];
|
||||||
|
if ([gFiles containsObject: f] == NO)
|
||||||
|
{
|
||||||
|
[gFiles addObject: f];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Add the gsdoc file corresponding to the .h file to the list of
|
||||||
|
* those to process.
|
||||||
|
*/
|
||||||
|
[gFiles addObject: [gsdocfile lastPathComponent]];
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Add the gsdoc file corresponding to the .h file to the list of
|
|
||||||
* those to process.
|
|
||||||
*/
|
|
||||||
[gFiles addObject: [gsdocfile lastPathComponent]];
|
|
||||||
}
|
}
|
||||||
DESTROY(pool);
|
DESTROY(pool);
|
||||||
DESTROY(parser);
|
DESTROY(parser);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue