Skip to content

Commit a58bf08

Browse files
committed
Update build scripts
1 parent 518eb4d commit a58bf08

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

build_gitbook.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
end
6262

6363
func_text = "`#{data["name"]}(#{data["all_optional"] ? "[#{arg_names}]" : arg_names})`"
64-
func_text << ": #{data["return_type"]}" if data.key? "return_type"
64+
func_text << ": #{data["return_type"]}#{data.key?("return_description") ? " (#{data["return_description"]})" : ""}" if data.key? "return_type"
6565

6666
func_name = data["name"] || "#{global}.#{name}"
6767
func_name = func_name.include?(":") ? (":" + func_name.split(":").last) : func_name
@@ -93,7 +93,12 @@
9393
description.gsub!(orig, rep)
9494
end
9595

96-
contents << (ARGS_AS_TABLE ? " **#{argument["name"]}** | #{argument["type"] || ""} | #{description}" : " - **#{argument["name"]}**: #{description}")
96+
contents << if ARGS_AS_TABLE
97+
" **#{argument["name"]}** | #{"#{argument["type"]}#{argument.key?("type_description") ? " (#{argument["type_description"]})" : ""}" || ""} | #{description}"
98+
else
99+
" - **#{argument["name"]}**: #{description}"
100+
end
101+
97102
end
98103
contents << ""
99104
end

build_globals.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
gem "activesupport", :require => ["active_support/core_ext/hash", "active_support/core_ext/string/inflections"]
1313
end
1414

15-
SORT_ORDER = %w[name description return_type deprecated args]
15+
SORT_ORDER = %w[name description return_type return_description deprecated args]
1616

1717
BUILD_DIR = Pathname.new("build/")
1818
SRC_DIR = Pathname.new("src/")
@@ -25,6 +25,7 @@
2525
globals_replacements = extra_docs["globals_replacements"]
2626
globals_deprecated_regex = Regexp.new(extra_docs["globals_deprecated_regex"])
2727
globals_optional_regex = Regexp.new(extra_docs["globals_optional_regex"])
28+
globals_type_description_regex = Regexp.new(extra_docs["globals_type_description_regex"])
2829

2930
class ReturnTypes
3031
def initialize()
@@ -178,7 +179,12 @@ def get_argument_type(arg, data)
178179
return_type = rettypes.get_return_type(data["name"], data)
179180
data["return_type"] = return_type unless return_type.nil?
180181
end
181-
unless data.key? "return_type"
182+
if data.key? "return_type"
183+
if match = data["return_type"].match(globals_type_description_regex)
184+
data["return_type"] = match[1]
185+
data["return_description"] = match[2]
186+
end
187+
else
182188
puts "#{global}.#{name}: No return type"
183189
end
184190
data["deprecated"] = true if !data.key?("deprecated") && data["name"].match?(globals_deprecated_regex)
@@ -203,6 +209,13 @@ def get_argument_type(arg, data)
203209
argument["type"] ||= type_info
204210
end
205211

212+
if argument.key? "type"
213+
if match = argument["type"].match(globals_type_description_regex)
214+
argument["type"] = match[1]
215+
argument["type_description"] = match[2]
216+
end
217+
end
218+
206219
if !argument.key?("type") && argument["name"] != "..."
207220
puts "#{global}.#{name}: Type of argument #{argument.inspect} unknown"
208221
end

0 commit comments

Comments
 (0)