-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy path_export.js
More file actions
58 lines (57 loc) · 2.2 KB
/
_export.js
File metadata and controls
58 lines (57 loc) · 2.2 KB
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
// https://runtime.fivem.net/doc/reference.html
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://code.jquery.com/jquery-3.2.1.min.js";
document.head.appendChild(script);
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
$("main").each(function() {
var doc = "";
var $main = $(this);
var module = $main.data("name").toLowerCase();
var $sections = $main.find("section");
$sections.each(function() {
var $section = $(this);
var original = $section.data("native");
if(!original.startsWith("0x") && !original.startsWith("_")) {
var method = {};
method.module = "native";
method.submodule = module;
method.native = original;
method.function = original.toLowerCase().capitalize().replace(/_([a-z])/g, function (g) { return g[1].toUpperCase(); });
method.description = $section.find(".desc").text().trim();
method.usage = $section.find(".code").text().trim().split("\n")[1].trim();
var splittedUsage = method.usage.split(" ");
method.return = splittedUsage.shift().trim();
method.see = splittedUsage.join(" ").trim();
method.params = {};
$.each(method.see.match("\\((.*)\\)")[1].split(","), function() {
if(this.trim() != "") {
var param = this.trim().split(" ");
method.params[param[1]] = param[0];
}
});
console.log(method.params);
var description = method.description.split("\n").join(" ").trim();
doc += ""
+ "-- "+(description == "" ? "@todo" : description)+"\n"
+ "-- @module "+method.module+"\n"
+ "-- @submodule "+method.submodule+"\n"
+ "-- @see "+method.native+"\n"
+ "-- @usage "+method.usage+"\n";
$.each(method.params, function(name, type) {
doc += "-- @param "+name+" "+type+"\n";
});
doc += "-- @return "+method.return+"\n";
var methodParams = "";
if(Object.keys(method.params).length > 0) {
methodParams = Object.keys(method.params).join(", ");
}
doc += "function "+method.function+"("+methodParams+") end"+"\n\n";
}
});
$main.html(
"<h4>"+module+"</h4><textarea rows='5'>"+doc.trim()+"</textarea>"
);
});