Skip to content

Commit 837fe82

Browse files
committed
Add emmylua build script
1 parent 997f154 commit 837fe82

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

build_emmylua.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require "bundler/inline"
2+
3+
gemfile do
4+
source "https://rubygems.org"
5+
6+
require "json"
7+
require "pathname"
8+
9+
gem "pry"
10+
end
11+
12+
BUILD_DIR = Pathname.new("build/")
13+
SRC_DIR = Pathname.new("src/")
14+
15+
globals = JSON.parse((BUILD_DIR + "globals.json").read)
16+
17+
contents = []
18+
contents << "--[[EmmyLua]]"
19+
20+
globals.sort.each do |global, functions|
21+
contents << ""
22+
contents << "-- #{global}:"
23+
contents << ""
24+
contents << "#{global} = {}"
25+
contents << ""
26+
27+
functions.each do |name, documentation|
28+
contents << "---"
29+
30+
if documentation.key? "description"
31+
contents << "--- #{documentation["description"]}"
32+
contents << "---"
33+
end
34+
documentation["args"].each do |arg|
35+
contents << "--- `#{arg["name"]}`#{arg.key?("description") ? ": #{arg["description"]}" : ""}"
36+
end
37+
documentation["args"].each do |arg|
38+
contents << "---@param #{arg["name"]}#{arg.key?("type") ? " #{arg["type"]}" : ""}"
39+
end
40+
41+
contents << "---@return #{documentation["return_type"]}#{documentation.key?("return_description") ? " #{documentation["return_description"]}" : ""}" if documentation.key? "return_type"
42+
contents << "function #{global}.#{name}(#{documentation["args"].map{|arg| arg["name"]}.join(", ")}) end"
43+
contents << ""
44+
end
45+
end
46+
47+
puts contents.join("\n")

0 commit comments

Comments
 (0)