-
Notifications
You must be signed in to change notification settings - Fork 2
/
php_func_method.js
75 lines (62 loc) · 2.42 KB
/
php_func_method.js
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
jquery_script.onload = function() {
//this might contain links to classes
jQuery("ul.chunklist_reference li a:not(.external)").each(function() {
WeBuilderExtract("php_func_method.js", this.href);
});
jQuery("div.classsynopsis").remove();
jQuery(".methodparam .initializer:contains(\")").remove();
//process class
//find no more than one class method with most commas (most parameters)
var matches = jQuery();
var maxcommacount = -1;
var bestmatch = null;
jQuery("div.description div.methodsynopsis:contains(::), div.description div.constructorsynopsis:contains(::)").each(function() {
var funccall = $(this).text().trim().normalize_spaces();
var commacount = funccall.split(",").length - 1;
if (commacount > maxcommacount) {
bestmatch = this;
maxcommacount = commacount;
}
});
if (bestmatch) {
matches = matches.add(bestmatch);
}
//and no more than one function with most commas
maxcommacount = -1;
bestmatch = null;
jQuery("div.description div.methodsynopsis:not(:contains(::)), div.description div.constructorsynopsis:not(:contains(::))").each(function() {
var funccall = $(this).text().trim().normalize_spaces();
var commacount = funccall.split(",").length - 1;
if (commacount > maxcommacount) {
bestmatch = this;
maxcommacount = commacount;
}
});
if (bestmatch) {
matches = matches.add(bestmatch);
}
matches.each(function() {
var synopsis = $(this);
var funccall = synopsis.text().trim().normalize_spaces();
var funcname = synopsis.find("span.methodname").text().remove_spaces();
var funcdesc = jQuery("p.refpurpose span.dc-title").text().trim().normalize_spaces();
var restype = synopsis.children("span.type").last().text().remove_spaces();
var className;
var argsRegex = /\(.*\)/;
var funcargs = funccall.match(argsRegex);
var methodRegex = /^(.*)?\:\:(.*)$/;
var methodCall = funcname.match(methodRegex);
if (methodCall) {
className = methodCall[1];
funcname = methodCall[2];
funccall = funccall.replace(methodCall[0], funcname);
} else {
className = '';
}
if (className != "") {
WeBuilderAddPHPBuiltInMethod(className, funcname, funccall + " - " + funcdesc);
} else {
WeBuilderAddPHPBuiltInFunction(funcname, funcargs, restype, funcdesc)
}
});
}