mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
Added automatic markup of method arguments.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11138 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
69fd54f1fa
commit
c5df5288f5
4 changed files with 126 additions and 49 deletions
|
@ -28,6 +28,7 @@
|
|||
NSCharacterSet *identStart; // Legit initial char of identifier
|
||||
NSCharacterSet *spaces; // All blank characters
|
||||
NSCharacterSet *spacenl; // Blanks excluding newline
|
||||
NSArray *args; // Not retained.
|
||||
}
|
||||
|
||||
- (unsigned) fitWords: (NSArray*)a
|
||||
|
|
|
@ -32,7 +32,7 @@ static BOOL snuggleEnd(NSString *t)
|
|||
}
|
||||
if (set == nil)
|
||||
{
|
||||
set = [NSCharacterSet characterSetWithCharactersInString: @"]}).,;"];
|
||||
set = [NSCharacterSet characterSetWithCharactersInString: @"]}).,;?!"];
|
||||
RETAIN(set);
|
||||
}
|
||||
return [set characterIsMember: [t characterAtIndex: 0]];
|
||||
|
@ -388,7 +388,6 @@ static BOOL snuggleStart(NSString *t)
|
|||
*/
|
||||
- (void) outputMethod: (NSDictionary*)d to: (NSMutableString*)str
|
||||
{
|
||||
NSArray *args = [d objectForKey: @"Args"];
|
||||
NSArray *sels = [d objectForKey: @"Sels"];
|
||||
NSArray *types = [d objectForKey: @"Types"];
|
||||
NSString *name = [d objectForKey: @"Name"];
|
||||
|
@ -398,6 +397,8 @@ static BOOL snuggleStart(NSString *t)
|
|||
NSString *override = nil;
|
||||
NSString *standards = nil;
|
||||
|
||||
args = [d objectForKey: @"Args"]; // Used when splitting.
|
||||
|
||||
tmp = [d objectForKey: @"Comment"];
|
||||
|
||||
/**
|
||||
|
@ -527,6 +528,7 @@ static BOOL snuggleStart(NSString *t)
|
|||
[self reformat: standards withIndent: 10 to: str];
|
||||
}
|
||||
[str appendString: @" </method>\n"];
|
||||
args = nil;
|
||||
}
|
||||
|
||||
- (void) outputUnit: (NSDictionary*)d to: (NSMutableString*)str
|
||||
|
@ -753,6 +755,7 @@ static BOOL snuggleStart(NSString *t)
|
|||
* end marks is tidied for consistency. The resulting data is made
|
||||
* into an array of strings, each containing either an element start
|
||||
* or end tag, or one of the whitespace separated words.
|
||||
* What about str?
|
||||
*/
|
||||
data = [[NSMutableData alloc] initWithLength: l * sizeof(unichar)];
|
||||
ptr = buf = [data mutableBytes];
|
||||
|
@ -895,22 +898,25 @@ static BOOL snuggleStart(NSString *t)
|
|||
for (l = 0; l < [a count]; l++)
|
||||
{
|
||||
static NSArray *constants = nil;
|
||||
static unsigned cCount = 0;
|
||||
unsigned count;
|
||||
NSString *tmp = [a objectAtIndex: l];
|
||||
unsigned pos;
|
||||
NSRange r;
|
||||
BOOL hadMethod = NO;
|
||||
|
||||
/*
|
||||
* Ensure that well known constants are rendered as 'code'
|
||||
*/
|
||||
if (constants == nil)
|
||||
{
|
||||
constants = [[NSArray alloc] initWithObjects:
|
||||
@"YES", @"NO", @"nil", nil];
|
||||
cCount = [constants count];
|
||||
}
|
||||
for (pos = 0; pos < cCount; pos++)
|
||||
|
||||
if (l == 0 || [[a objectAtIndex: l-1] isEqual: @"<code>"] == NO)
|
||||
{
|
||||
/*
|
||||
* Ensure that well known constants are rendered as 'code'
|
||||
*/
|
||||
count = [constants count];
|
||||
for (pos = 0; pos < count; pos++)
|
||||
{
|
||||
NSString *c = [constants objectAtIndex: pos];
|
||||
|
||||
|
@ -968,6 +974,73 @@ static BOOL snuggleStart(NSString *t)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that method arguments are rendered as 'var'
|
||||
*/
|
||||
if (l == 0 || [[a objectAtIndex: l-1] isEqual: @"<var>"] == NO)
|
||||
{
|
||||
count = [args count];
|
||||
for (pos = 0; pos < count; pos++)
|
||||
{
|
||||
NSString *c = [args objectAtIndex: pos];
|
||||
|
||||
r = [tmp rangeOfString: c];
|
||||
|
||||
if (r.length > 0)
|
||||
{
|
||||
NSString *start;
|
||||
NSString *end;
|
||||
|
||||
if (r.location > 0)
|
||||
{
|
||||
start = [tmp substringToIndex: r.location];
|
||||
}
|
||||
else
|
||||
{
|
||||
start = nil;
|
||||
}
|
||||
if (NSMaxRange(r) < [tmp length])
|
||||
{
|
||||
end = [tmp substringFromIndex: NSMaxRange(r)];
|
||||
}
|
||||
else
|
||||
{
|
||||
end = nil;
|
||||
}
|
||||
if ((start == nil || snuggleStart(start) == YES)
|
||||
&& (end == nil || snuggleEnd(end) == YES))
|
||||
{
|
||||
NSString *sub;
|
||||
|
||||
if (start != nil || end != nil)
|
||||
{
|
||||
sub = [tmp substringWithRange: r];
|
||||
}
|
||||
else
|
||||
{
|
||||
sub = nil;
|
||||
}
|
||||
if (start != nil)
|
||||
{
|
||||
[a insertObject: start atIndex: l++];
|
||||
}
|
||||
[a insertObject: @"<var>" atIndex: l++];
|
||||
if (sub != nil)
|
||||
{
|
||||
[a replaceObjectAtIndex: l withObject: sub];
|
||||
}
|
||||
l++;
|
||||
[a insertObject: @"</var>" atIndex: l];
|
||||
if (end != nil)
|
||||
{
|
||||
[a insertObject: end atIndex: ++l];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that methods are rendered as references.
|
||||
|
|
|
@ -127,6 +127,9 @@
|
|||
<item>Certain well known constants such as YES, NO, and nil are
|
||||
enclosed in <code> ... </code> markup.
|
||||
</item>
|
||||
<item>The names of method arguments within method descriptions are
|
||||
enclosed in <var> ... </var> markup.
|
||||
</item>
|
||||
<item>Method names (beginning with a plus or minus) are enclosed
|
||||
in <ref...> ... </ref> markup.
|
||||
</item>
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
|
||||
<!--***** Phrase elements. *****-->
|
||||
|
||||
<!-- The content is a metasyntactic variable name. -->
|
||||
<!-- The content is a metasyntactic variable or argument name. -->
|
||||
<!ELEMENT var (%text;)*>
|
||||
|
||||
<!-- The content is a metasyntactic ivariable name. -->
|
||||
|
|
Loading…
Reference in a new issue