-
Notifications
You must be signed in to change notification settings - Fork 2
/
DocFunction.m
122 lines (97 loc) · 3.28 KB
/
DocFunction.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Copyright (C) 2008 Nicolas Roard
Author: Nicolas Roard
Author: Quentin Mathe <[email protected]>
Date: June 2008
License: Modified BSD (see COPYING)
*/
#import "DocFunction.h"
#import "DocHTMLElement.h"
#import "DocDescriptionParser.h"
#import "DocIndex.h"
#import "DocParameter.h"
@implementation DocFunction
// TODO: We could use better span class names perhaps rather than just reusing
// the DocMethod ones... not sure though.
- (DocHTMLElement *) HTMLRepresentation
{
H hReturn = [[self returnParameter] HTMLRepresentationWithParentheses: NO];
H hSignature = [SPAN class: @"methodSignature"
with: hReturn
and: [SPAN class: @"selector" with: @" " and: [self name]]
and: @"("];
BOOL isFirst = YES;
for (DocParameter *param in [self parameters])
{
H hParam = [param HTMLRepresentationWithParentheses: NO];
if (NO == isFirst)
{
[hSignature and: @", "];
}
[hSignature and: hParam];
isFirst = NO;
}
[hSignature with: @")"];
H hFunctionDesc = [DIV class: @"methodDescription"
with: [self HTMLDescriptionWithDocIndex: [DocIndex currentIndex]]
and: [self HTMLAddendumRepresentation]];
H hFunctionBlock = [DIV class: @"method" with: [DL class: @"collapsable" with: [DT with: hSignature]
and: [DD with: hFunctionDesc]]];
//NSLog(@"Function %@", hFunctionBlock);
return hFunctionBlock;
}
- (NSString *) GSDocElementName
{
return @"function";
}
- (SEL) weaveSelector
{
return @selector(weaveFunction:);
}
- (void) parser: (GSDocParser *)parser
startElement: (NSString *)elementName
withAttributes: (NSDictionary *)attributeDict
{
if ([elementName isEqualToString: [self GSDocElementName]]) /* Opening tag */
{
BEGINLOG();
[self setReturnType: [attributeDict objectForKey: @"type"]];
[self setName: [attributeDict objectForKey: @"name"]];
}
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (void) parser: (GSDocParser *)parser
endElement: (NSString *)elementName
withContent: (NSString *)trimmed
{
if ([elementName isEqualToString: @"arg"])
{
NSString *type = [parser argTypeFromArgsAttributes: [parser currentAttributes]];
[self addParameter: [DocParameter parameterWithName: trimmed type: type]];
}
else if ([elementName isEqualToString: @"desc"])
{
[self appendToRawDescription: trimmed];
CONTENTLOG();
}
else if ([elementName isEqualToString: [self GSDocElementName]]) /* Closing tag */
{
DocDescriptionParser* descParser = [DocDescriptionParser new];
[descParser parse: [self rawDescription]];
//NSLog(@"Function raw description <%@>", [self rawDescription]);
[self addInformationFrom: descParser];
[(id)[parser weaver] performSelector: [self weaveSelector] withObject: self];
ENDLOG2(name, [self task]);
}
}
- (void) parseProgramComponent: (SCKFunction *)aFunction
{
[self setName: [aFunction name]];
[self appendToRawDescription: [[aFunction documentation] string]];
DocDescriptionParser *descriptionParser = [DocDescriptionParser new];
[descriptionParser parse: [self rawDescription]];
[self addInformationFrom: descriptionParser];
}
#pragma clang diagnostic pop
@end