yard-sketchup 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +15 -0
- data/lib/yard-sketchup/templates/changelog/fulldoc/text/setup.rb +44 -0
- data/lib/yard-sketchup/templates/coverage/fulldoc/text/setup.rb +38 -0
- data/lib/yard-sketchup/templates/default/fulldoc/html/css/rubyapi.css +11 -0
- data/lib/yard-sketchup/templates/default/fulldoc/html/css/sketchup.css +110 -0
- data/lib/yard-sketchup/templates/default/fulldoc/html/full_list_object_types.erb +1 -0
- data/lib/yard-sketchup/templates/default/fulldoc/html/js/sketchup.js +37 -0
- data/lib/yard-sketchup/templates/default/fulldoc/html/setup.rb +44 -0
- data/lib/yard-sketchup/templates/default/layout/html/embed_meta.erb +78 -0
- data/lib/yard-sketchup/templates/default/layout/html/footer.erb +4 -0
- data/lib/yard-sketchup/templates/default/layout/html/headers.erb +15 -0
- data/lib/yard-sketchup/templates/default/layout/html/layout.erb +55 -0
- data/lib/yard-sketchup/templates/default/layout/html/navbar.erb +36 -0
- data/lib/yard-sketchup/templates/default/layout/html/setup.rb +19 -0
- data/lib/yard-sketchup/templates/default/method_details/html/method_signature.erb +26 -0
- data/lib/yard-sketchup/templates/default/method_details/setup.rb +12 -0
- data/lib/yard-sketchup/templates/default/module/html/box_info.erb +37 -0
- data/lib/yard-sketchup/templates/default/module/html/constant_summary.erb +17 -0
- data/lib/yard-sketchup/templates/default/module/html/defines.erb +1 -0
- data/lib/yard-sketchup/templates/default/module/html/method_summary.erb +18 -0
- data/lib/yard-sketchup/templates/rubocop-changelog/fulldoc/text/setup.rb +75 -0
- data/lib/yard-sketchup/templates/stubs/fulldoc/text/setup.rb +363 -0
- data/lib/yard-sketchup/templates/versions/fulldoc/text/setup.rb +25 -0
- data/lib/yard-sketchup/version.rb +3 -0
- data/lib/yard-sketchup/yard/handlers/class_constants.rb +17 -0
- data/lib/yard-sketchup/yard/handlers/class_enum_constants.rb +17 -0
- data/lib/yard-sketchup/yard/handlers/global_constants.rb +19 -0
- data/lib/yard-sketchup/yard/logger.rb +45 -0
- data/lib/yard-sketchup.rb +29 -0
- data/yard-sketchup.gemspec +25 -0
- metadata +101 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
<% if method_listing.size > 0 %>
|
2
|
+
<% groups(method_listing) do |list, name| %>
|
3
|
+
<h2>
|
4
|
+
<%= name %>
|
5
|
+
<a
|
6
|
+
id="<%= name.gsub(' ', '_').downcase %>"
|
7
|
+
href="#<%= name.gsub(' ', '_').downcase %>"
|
8
|
+
title="Permalink">#</a>
|
9
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
10
|
+
</h2>
|
11
|
+
|
12
|
+
<ul class="summary">
|
13
|
+
<% list.each do |meth| %>
|
14
|
+
<%= yieldall :item => meth %>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'set'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
include Helpers::ModuleHelper
|
6
|
+
|
7
|
+
def init
|
8
|
+
generate_changelog
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def all_objects
|
13
|
+
run_verifier(Registry.all())
|
14
|
+
end
|
15
|
+
|
16
|
+
def namespace_objects
|
17
|
+
run_verifier(Registry.all(:class, :module))
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def changelog_filename
|
22
|
+
'Changelog SU201x.log'
|
23
|
+
end
|
24
|
+
|
25
|
+
VERSION_MATCH = /^\D+([0-9.]+)(?:\s+M(\d+))?$/
|
26
|
+
|
27
|
+
def generate_changelog
|
28
|
+
output = StringIO.new
|
29
|
+
|
30
|
+
versions = Hash.new
|
31
|
+
all_objects.each { |object|
|
32
|
+
version_tag = object.tag(:version)
|
33
|
+
next if version_tag.nil?
|
34
|
+
version = version_tag.text
|
35
|
+
|
36
|
+
# Don't list SU6 or older.
|
37
|
+
next if version.match(VERSION_MATCH).captures[0].to_i <= 6
|
38
|
+
|
39
|
+
versions[version] ||= {}
|
40
|
+
versions[version][object.type] ||= []
|
41
|
+
versions[version][object.type] << object.path
|
42
|
+
}
|
43
|
+
versions = versions.sort { |a, b|
|
44
|
+
v1, mv1 = a[0].match(VERSION_MATCH).captures
|
45
|
+
v2, mv2 = b[0].match(VERSION_MATCH).captures
|
46
|
+
if v1 == v2
|
47
|
+
(mv2 || '0').to_i <=> (mv1 || '0').to_i
|
48
|
+
else
|
49
|
+
v2.to_f <=> v1.to_f
|
50
|
+
end
|
51
|
+
}
|
52
|
+
|
53
|
+
output.puts "FEATURES = ["
|
54
|
+
versions.each { |version, features|
|
55
|
+
output.puts ""
|
56
|
+
output.puts " {"
|
57
|
+
output.puts " version: '#{version}',"
|
58
|
+
output.puts " types: {"
|
59
|
+
features.sort.each { |type, objects|
|
60
|
+
unless objects.empty?
|
61
|
+
output.puts " #{type}: ["
|
62
|
+
objects.sort.each { |object|
|
63
|
+
output.puts " '#{object}',"
|
64
|
+
}
|
65
|
+
output.puts " ],"
|
66
|
+
end
|
67
|
+
}
|
68
|
+
output.puts " },"
|
69
|
+
output.puts " },"
|
70
|
+
}
|
71
|
+
output.puts "]"
|
72
|
+
|
73
|
+
puts output.string
|
74
|
+
exit # Avoid the YARD summary
|
75
|
+
end
|
@@ -0,0 +1,363 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'pathname'
|
3
|
+
require 'set'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
include Helpers::ModuleHelper
|
7
|
+
|
8
|
+
def init
|
9
|
+
generate_stubs
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# NOTE: Remember to run objects outputted through `run_verifier` first in order
|
14
|
+
# to filter out items that should be excluded by command line arguments.
|
15
|
+
|
16
|
+
def namespace_objects
|
17
|
+
run_verifier(Registry.all(:class, :module))
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def generate_autoload
|
22
|
+
generate_sketchup_autoload
|
23
|
+
end
|
24
|
+
|
25
|
+
def generate_sketchup_autoload
|
26
|
+
base = Pathname.new(autoload_stubs_path)
|
27
|
+
autoload_file = File.join(autoload_stubs_path, 'sketchup.rb')
|
28
|
+
File.open(autoload_file, 'w') { |file|
|
29
|
+
pattern = File.join(sketchup_stubs_path, '**/*.rb')
|
30
|
+
Dir.glob(pattern) { |filename|
|
31
|
+
pathname = Pathname.new(filename)
|
32
|
+
relative = pathname.relative_path_from(base)
|
33
|
+
file.puts "require '#{relative.to_s}'"
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate_stubs
|
39
|
+
puts "Generating stubs..."
|
40
|
+
generate_module_stubs(Registry.root)
|
41
|
+
namespace_objects.each do |object|
|
42
|
+
generate_module_stubs(object)
|
43
|
+
end
|
44
|
+
generate_autoload
|
45
|
+
end
|
46
|
+
|
47
|
+
def print_section(io, title, content)
|
48
|
+
return if content.strip.empty?
|
49
|
+
io.puts
|
50
|
+
io.puts " # #{title}"
|
51
|
+
io.puts
|
52
|
+
io.puts content
|
53
|
+
end
|
54
|
+
|
55
|
+
def generate_module_stubs(object)
|
56
|
+
filename = stub_filename(object)
|
57
|
+
ensure_exist(File.dirname(filename))
|
58
|
+
StubFile.open(filename, 'w') { |file|
|
59
|
+
file.puts file_header(object)
|
60
|
+
file.puts
|
61
|
+
file.puts namespace_definition(object)
|
62
|
+
print_section(file, 'Extends', generate_mixins(object, :class))
|
63
|
+
print_section(file, 'Includes', generate_mixins(object, :instance))
|
64
|
+
print_section(file, 'Constants', generate_constants_grouped(object))
|
65
|
+
print_section(file, 'Class Methods', generate_class_methods(object))
|
66
|
+
print_section(file, 'Instance Methods', generate_instance_methods(object))
|
67
|
+
file.puts
|
68
|
+
file.puts file_footer(object)
|
69
|
+
}
|
70
|
+
#trim_trailing_white_space(filename)
|
71
|
+
end
|
72
|
+
|
73
|
+
def file_header(object)
|
74
|
+
header = StringIO.new
|
75
|
+
header.puts "# Copyright:: Copyright #{Time.now.year} Trimble Inc."
|
76
|
+
header.puts "# License:: The MIT License (MIT)"
|
77
|
+
#header.puts "# Generated:: #{Time.now.strftime('%F %R')}"
|
78
|
+
header.string
|
79
|
+
end
|
80
|
+
|
81
|
+
def file_footer(object)
|
82
|
+
return if object.root?
|
83
|
+
footer = StringIO.new
|
84
|
+
footer.puts 'end'
|
85
|
+
footer.string
|
86
|
+
end
|
87
|
+
|
88
|
+
def namespace_definition(object)
|
89
|
+
return if object.root?
|
90
|
+
definition = "#{object.type} #{object.path}"
|
91
|
+
if object.type == :class && object.superclass.name != :Object
|
92
|
+
definition << " < #{object.superclass.path}"
|
93
|
+
end
|
94
|
+
output = StringIO.new
|
95
|
+
output.puts generate_docstring(object)
|
96
|
+
output.puts definition
|
97
|
+
output.string
|
98
|
+
end
|
99
|
+
|
100
|
+
def output_path
|
101
|
+
options.serializer.options[:basepath] || File.join(Dir.pwd, 'stubs')
|
102
|
+
end
|
103
|
+
|
104
|
+
def stubs_path
|
105
|
+
ensure_exist(output_path)
|
106
|
+
end
|
107
|
+
|
108
|
+
def autoload_stubs_path
|
109
|
+
ensure_exist(File.join(stubs_path, 'autoload'))
|
110
|
+
end
|
111
|
+
|
112
|
+
def sketchup_stubs_path
|
113
|
+
ensure_exist(File.join(stubs_path, 'SketchUp'))
|
114
|
+
end
|
115
|
+
|
116
|
+
def stub_filename(object)
|
117
|
+
basename = object.path.gsub('::', '/')
|
118
|
+
basename = '_top_level' if basename.empty?
|
119
|
+
File.join(sketchup_stubs_path, "#{basename}.rb")
|
120
|
+
end
|
121
|
+
|
122
|
+
CAMELCASE_CONSTANT = /^([A-Z]+[a-z]+)/
|
123
|
+
|
124
|
+
def group_constant(constant)
|
125
|
+
constant_name = constant.name.to_s
|
126
|
+
MANUAL_CONSTANT_GROUPS.each { |rule|
|
127
|
+
if rule[:constants]
|
128
|
+
return rule[:group] if rule[:constants].include?(constant_name)
|
129
|
+
else
|
130
|
+
return rule[:group] if rule[:regex].match(constant_name)
|
131
|
+
end
|
132
|
+
}
|
133
|
+
if constant_name.include?('_')
|
134
|
+
constant_name.split('_').first
|
135
|
+
else
|
136
|
+
constant_name[CAMELCASE_CONSTANT] || constant_name
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# Sorts and groups constants for easier reading.
|
141
|
+
def generate_constants_grouped(object)
|
142
|
+
constants = run_verifier(object.constants(object_options))
|
143
|
+
# The constants are not sorted before chunking. This is because `chunk` groups
|
144
|
+
# consecutive items - and we want to chunk them based their relationship
|
145
|
+
# with each other. This ensure that constants that doesn't follow the normal
|
146
|
+
# pattern of PREFIX_SOME_NAME will still be grouped next to each other.
|
147
|
+
groups = constants.chunk { |constant|
|
148
|
+
group_constant(constant)
|
149
|
+
}
|
150
|
+
grouped_output = groups.map { |group, group_constants|
|
151
|
+
output = StringIO.new
|
152
|
+
# Each group itself is sorted in order to more easily scan the list.
|
153
|
+
sorted = group_constants.sort { |a, b|
|
154
|
+
a.name <=> b.name
|
155
|
+
}
|
156
|
+
sorted.each { |constant|
|
157
|
+
output.puts " #{constant.name} = nil # Stub value."
|
158
|
+
}
|
159
|
+
output.string
|
160
|
+
}
|
161
|
+
# Finally each group is also sorted, again to ease scanning for a particular
|
162
|
+
# name. We simply use the first character of each group.
|
163
|
+
grouped_output.sort { |a, b|
|
164
|
+
a.lstrip[0] <=> b.lstrip[0]
|
165
|
+
}.join("\n")
|
166
|
+
end
|
167
|
+
|
168
|
+
# Sort constants without grouping.
|
169
|
+
def generate_constants(object)
|
170
|
+
output = StringIO.new
|
171
|
+
constants = run_verifier(object.constants(object_options)).sort { |a, b|
|
172
|
+
a.name <=> b.name
|
173
|
+
}
|
174
|
+
constants.each { |constant|
|
175
|
+
output.puts " #{constant.name} = nil # Stub value."
|
176
|
+
}
|
177
|
+
output.string
|
178
|
+
end
|
179
|
+
|
180
|
+
def generate_mixins(object, scope)
|
181
|
+
output = StringIO.new
|
182
|
+
mixin_type = (scope == :class) ? 'extend' : 'include'
|
183
|
+
mixins = run_verifier(object.mixins(scope)).sort { |a, b|
|
184
|
+
a.path <=> b.path
|
185
|
+
}
|
186
|
+
mixins.each { |mixin|
|
187
|
+
output.puts " #{mixin_type} #{mixin.path}"
|
188
|
+
}
|
189
|
+
output.string
|
190
|
+
end
|
191
|
+
|
192
|
+
def generate_class_methods(object)
|
193
|
+
generate_methods(object, :class, 'self.')
|
194
|
+
end
|
195
|
+
|
196
|
+
def generate_instance_methods(object)
|
197
|
+
generate_methods(object, :instance)
|
198
|
+
end
|
199
|
+
|
200
|
+
def generate_methods(object, scope, prefix = '')
|
201
|
+
methods = sort_methods(object, scope)
|
202
|
+
signatures = methods.map { |method|
|
203
|
+
output = StringIO.new
|
204
|
+
# Cannot use `methods.signature` here as it would return the C/C++ function
|
205
|
+
# signature. Must generate one from the YARD data.
|
206
|
+
signature = generate_method_signature(method)
|
207
|
+
# NOTE: We must call `generate_docstring` after `generate_method_signature`
|
208
|
+
# because `generate_method_signature` will also clean up docstrings with
|
209
|
+
# a single @overload tag.
|
210
|
+
output.puts generate_docstring(method, 1)
|
211
|
+
output.puts " def #{prefix}#{signature}"
|
212
|
+
output.puts " end"
|
213
|
+
output.string
|
214
|
+
}
|
215
|
+
signatures.join("\n")
|
216
|
+
end
|
217
|
+
|
218
|
+
# NOTE: This may modify the docstring of the object.
|
219
|
+
def generate_method_signature(object)
|
220
|
+
signature = "#{object.name}"
|
221
|
+
# If there is a single overload then use that as the parameter list. Many of
|
222
|
+
# the SketchUp Ruby API methods will have this as it was safer to add an
|
223
|
+
# @overload tag instead of renaming the function argument names.
|
224
|
+
overloads = object.docstring.tags(:overload)
|
225
|
+
if overloads.size == 1
|
226
|
+
overload = overloads.first
|
227
|
+
parameters = overload.parameters
|
228
|
+
# Move the tags from the @overload tag to the root of the docstring. No need
|
229
|
+
# for a single overload tag - it's unexpected when reading the source.
|
230
|
+
object.docstring.add_tag(*overload.tags)
|
231
|
+
object.docstring.delete_tags(:overload)
|
232
|
+
else
|
233
|
+
parameters = object.parameters
|
234
|
+
end
|
235
|
+
# Compile the signature for the arguments and default values.
|
236
|
+
params = parameters.map { |param|
|
237
|
+
param.last.nil? ? param.first : param.join(' = ')
|
238
|
+
}.join(', ')
|
239
|
+
signature << "(#{params})" unless params.empty?
|
240
|
+
signature
|
241
|
+
end
|
242
|
+
|
243
|
+
def generate_docstring(object, indent_step = 0)
|
244
|
+
output = StringIO.new
|
245
|
+
indent = ' ' * indent_step
|
246
|
+
docstring = object.docstring
|
247
|
+
docstring.delete_tags(:par) # Remove obsolete @par tags.
|
248
|
+
docstring.to_raw.lines.each { |line|
|
249
|
+
# Naive check for tags with no indent - if it is we insert an extra line
|
250
|
+
# in order to get some space for easier reader. Doing it this way in order
|
251
|
+
# to avoid hacking YARD too much.
|
252
|
+
output.puts "#{indent}#" if line.start_with?('@')
|
253
|
+
# This is the original docstring line.
|
254
|
+
output.puts "#{indent}# #{line}"
|
255
|
+
}
|
256
|
+
output.string
|
257
|
+
end
|
258
|
+
|
259
|
+
def sort_methods(object, scope)
|
260
|
+
methods = run_verifier(object.meths(object_options))
|
261
|
+
objects = methods.select { |method|
|
262
|
+
method.scope == scope
|
263
|
+
}
|
264
|
+
objects.sort { |a, b|
|
265
|
+
a.name <=> b.name
|
266
|
+
}
|
267
|
+
end
|
268
|
+
|
269
|
+
def object_options
|
270
|
+
{
|
271
|
+
:inherited => false,
|
272
|
+
:included => false
|
273
|
+
}
|
274
|
+
end
|
275
|
+
|
276
|
+
|
277
|
+
def ensure_exist(path)
|
278
|
+
unless File.directory?(path)
|
279
|
+
FileUtils.mkdir_p(path)
|
280
|
+
end
|
281
|
+
path
|
282
|
+
end
|
283
|
+
|
284
|
+
|
285
|
+
class StubFile < File
|
286
|
+
|
287
|
+
def puts(*args)
|
288
|
+
case args.size
|
289
|
+
when 0
|
290
|
+
super
|
291
|
+
when 1
|
292
|
+
super trim_trailing_white_space(args[0].to_s)
|
293
|
+
else
|
294
|
+
raise NotImplementedError
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
private
|
299
|
+
|
300
|
+
TRAILING_WHITE_SPACE = /([\t ]+)$/
|
301
|
+
def trim_trailing_white_space(string)
|
302
|
+
string.gsub(TRAILING_WHITE_SPACE, '')
|
303
|
+
end
|
304
|
+
|
305
|
+
end
|
306
|
+
|
307
|
+
|
308
|
+
MANUAL_CONSTANT_GROUPS = [
|
309
|
+
# UI.messagebox return values.
|
310
|
+
{
|
311
|
+
constants: %w{IDABORT IDCANCEL IDIGNORE IDNO IDOK IDRETRY IDYES},
|
312
|
+
group: 'ID_MESSAGEBOX'
|
313
|
+
},
|
314
|
+
# Axes
|
315
|
+
{
|
316
|
+
constants: %w{X_AXIS Y_AXIS Z_AXIS},
|
317
|
+
group: 'AXES'
|
318
|
+
},
|
319
|
+
# Axes 2D
|
320
|
+
{
|
321
|
+
constants: %w{X_AXIS_2D Y_AXIS_2D},
|
322
|
+
group: 'AXES2D'
|
323
|
+
},
|
324
|
+
# Transformation
|
325
|
+
{
|
326
|
+
constants: %w{IDENTITY IDENTITY_2D},
|
327
|
+
group: 'IDENTITY'
|
328
|
+
},
|
329
|
+
# Geom::PolygonMesh
|
330
|
+
{
|
331
|
+
constants: %w{
|
332
|
+
AUTO_SOFTEN HIDE_BASED_ON_INDEX NO_SMOOTH_OR_HIDE SMOOTH_SOFT_EDGES
|
333
|
+
SOFTEN_BASED_ON_INDEX},
|
334
|
+
group: 'SOFTEN'
|
335
|
+
},
|
336
|
+
# Sketchup::Importer
|
337
|
+
# The other constants start with Import, this was odd one out.
|
338
|
+
{
|
339
|
+
constants: %w{ImporterNotFound},
|
340
|
+
group: 'Import'
|
341
|
+
},
|
342
|
+
# Sketchup::Http
|
343
|
+
{
|
344
|
+
constants: %w{DELETE GET HEAD OPTIONS PATCH POST PUT},
|
345
|
+
group: 'HTTP'
|
346
|
+
},
|
347
|
+
# Sketchup::Licensing
|
348
|
+
{
|
349
|
+
constants: %w{EXPIRED LICENSED NOT_LICENSED TRIAL TRIAL_EXPIRED},
|
350
|
+
group: 'EX_LICENSE'
|
351
|
+
},
|
352
|
+
# Sketchup::Model
|
353
|
+
{
|
354
|
+
constants: %w{Make MakeTrial ProLicensed ProTrial},
|
355
|
+
group: 'SU_LICENSE'
|
356
|
+
},
|
357
|
+
# Sketchup::RenderingOptions
|
358
|
+
# Most ROP constants start with ROPSet, with a handful of exceptions.
|
359
|
+
{
|
360
|
+
regex: /^ROP/,
|
361
|
+
group: 'ROP'
|
362
|
+
},
|
363
|
+
]
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
include Helpers::ModuleHelper
|
4
|
+
|
5
|
+
MANIFEST_FILENAME = 'coverage.manifest'.freeze
|
6
|
+
|
7
|
+
def init
|
8
|
+
find_all_versions
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def all_objects
|
13
|
+
run_verifier(Registry.all)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def find_all_versions
|
18
|
+
versions = Set.new
|
19
|
+
all_objects.each { |object|
|
20
|
+
version_tag = object.tag(:version)
|
21
|
+
versions << version_tag.text if version_tag
|
22
|
+
}
|
23
|
+
puts versions.sort.join("\n")
|
24
|
+
exit # Avoid the YARD summary
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SketchUpYARD
|
2
|
+
class ClassConstantHandler < YARD::Handlers::C::Base
|
3
|
+
|
4
|
+
MATCH = %r{\bDEFINE_RUBY_CLASS_CONSTANT\s*\(([^,]+)\s*,\s*([^,]+)\s*,\s*(\w+)\s*\)\s*;}xm
|
5
|
+
handles MATCH
|
6
|
+
statement_class BodyStatement
|
7
|
+
|
8
|
+
process do
|
9
|
+
statement.source.scan(MATCH) do |klass_name, value, const_name|
|
10
|
+
type = "const"
|
11
|
+
value = "nil"
|
12
|
+
handle_constants(type, klass_name, const_name, value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SketchUpYARD
|
2
|
+
class ClassEnumConstantHandler < YARD::Handlers::C::Base
|
3
|
+
|
4
|
+
MATCH = %r{\bDEFINE_RUBY_CLASS_ENUM\s*\(([^,]+)\s*,\s*(\w+)\s*\)\s*;}xm
|
5
|
+
handles MATCH
|
6
|
+
statement_class BodyStatement
|
7
|
+
|
8
|
+
process do
|
9
|
+
statement.source.scan(MATCH) do |klass_name, const_name|
|
10
|
+
type = "const"
|
11
|
+
value = "nil"
|
12
|
+
handle_constants(type, klass_name, const_name, value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SketchUpYARD
|
2
|
+
class GlobalConstantHandler < YARD::Handlers::C::Base
|
3
|
+
|
4
|
+
MATCH = %r{\bDEFINE_RUBY_(?:(?:NAMED_)?CONSTANT|ENUM)\s*\((?:[^)]+,\s*)?(\w+)\)\s*;}xm
|
5
|
+
handles MATCH
|
6
|
+
statement_class BodyStatement
|
7
|
+
|
8
|
+
process do
|
9
|
+
statement.source.scan(MATCH) do |captures|
|
10
|
+
const_name = captures.first
|
11
|
+
type = "global_const"
|
12
|
+
var_name = nil
|
13
|
+
value = "nil"
|
14
|
+
handle_constants(type, var_name, const_name, value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'yard/logging'
|
2
|
+
|
3
|
+
# Hack to show some progress on Windows while building the docs.
|
4
|
+
# Helpful in seeing what takes most time.
|
5
|
+
# It's Copy+Paste from YARD 0.9.9 with some noted edits.
|
6
|
+
module YARD
|
7
|
+
class Logger < ::Logger
|
8
|
+
|
9
|
+
def show_progress
|
10
|
+
return false if YARD.ruby18? # threading is too ineffective for progress support
|
11
|
+
# <hack>
|
12
|
+
# return false if YARD.windows? # windows has poor ANSI support
|
13
|
+
# </hack>
|
14
|
+
return false unless io.tty? # no TTY support on IO
|
15
|
+
return false unless level > INFO # no progress in verbose/debug modes
|
16
|
+
@show_progress
|
17
|
+
end
|
18
|
+
|
19
|
+
def progress(msg, nontty_log = :debug)
|
20
|
+
send(nontty_log, msg) if nontty_log
|
21
|
+
return unless show_progress
|
22
|
+
icon = ""
|
23
|
+
if defined?(::Encoding)
|
24
|
+
icon = PROGRESS_INDICATORS[@progress_indicator] + " "
|
25
|
+
end
|
26
|
+
@mutex.synchronize do
|
27
|
+
print("\e[2K\e[?25l\e[1m#{icon}#{msg}\e[0m\r")
|
28
|
+
@progress_msg = msg
|
29
|
+
if Time.now - @progress_last_update > 0.2
|
30
|
+
@progress_indicator += 1
|
31
|
+
@progress_indicator %= PROGRESS_INDICATORS.size
|
32
|
+
@progress_last_update = Time.now
|
33
|
+
end
|
34
|
+
end
|
35
|
+
Thread.new do
|
36
|
+
sleep(0.05)
|
37
|
+
# <hack>
|
38
|
+
# progress(msg + ".", nil) if @progress_msg == msg
|
39
|
+
# </hack>
|
40
|
+
progress(msg, nil) if @progress_msg == msg
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end if true # Set to false to disable hack.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'yard'
|
2
|
+
require 'yard-sketchup/version'
|
3
|
+
require 'yard-sketchup/yard/logger'
|
4
|
+
require 'yard-sketchup/yard/handlers/class_constants'
|
5
|
+
require 'yard-sketchup/yard/handlers/class_enum_constants'
|
6
|
+
require 'yard-sketchup/yard/handlers/global_constants'
|
7
|
+
|
8
|
+
module SketchUpYARD
|
9
|
+
|
10
|
+
def self.init
|
11
|
+
# https://github.com/burtlo/yard-cucumber/blob/master/lib/yard-cucumber.rb
|
12
|
+
# This registered template works for yardoc
|
13
|
+
# YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/templates'
|
14
|
+
# The following static paths and templates are for yard server
|
15
|
+
# YARD::Server.register_static_path File.dirname(__FILE__) + "/templates/default/fulldoc/html"
|
16
|
+
|
17
|
+
YARD::Templates::Engine.register_template_path self.templates_path
|
18
|
+
|
19
|
+
# https://www.rubydoc.info/gems/yard/file/docs/TagsArch.md#Adding_Custom_Tags
|
20
|
+
YARD::Tags::Library.define_tag('Known Bugs', :bug)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.templates_path
|
24
|
+
File.join(__dir__, 'yard-sketchup', 'templates')
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
SketchUpYARD.init
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
2
|
+
require 'yard-sketchup/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'yard-sketchup'
|
6
|
+
spec.summary = 'SketchUp Ruby API YARD template.'
|
7
|
+
spec.description = 'SketchUp Ruby API YARD template.'
|
8
|
+
spec.homepage = 'https://github.com/SketchUp/sketchup-yard-template'
|
9
|
+
spec.authors = ['Trimble Inc, SketchUp Team']
|
10
|
+
spec.licenses = ['MIT']
|
11
|
+
|
12
|
+
spec.version = SketchUpYARD::VERSION
|
13
|
+
spec.platform = Gem::Platform::RUBY
|
14
|
+
spec.required_ruby_version = '>= 2.2.0'
|
15
|
+
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
spec.files = Dir[
|
18
|
+
'lib/**/*',
|
19
|
+
'*.gemspec',
|
20
|
+
'Gemfile'
|
21
|
+
]
|
22
|
+
|
23
|
+
spec.add_dependency 'yard', '~> 0.9.18'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
25
|
+
end
|