yard-sketchup 1.0.2 → 1.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77bebdce209cac8110d5d0d3a303f75595b3de7fa7dcaf5929e82074c223f367
4
- data.tar.gz: 0f8e28fc2c450acaf5e768cd502a0bd1f2e376318f3c3c8f9394278a112bd58c
3
+ metadata.gz: b423474c8d87b8f7f225b0b9711005e4cce42cdae47f40b8016b0a8dc7336525
4
+ data.tar.gz: 50c9651f436c50cda5c46bb3682a16d4141bd7c380c0e174fb724fbd98376720
5
5
  SHA512:
6
- metadata.gz: 997b7d58b5c35972834cf14ae082fa44e8e26146fd86cf0239adfbd5a548caca3bfbef855c1341255cf9dc93242a451c91365db35862afa2955376bb262d7953
7
- data.tar.gz: 6313c798ed9e2e87900114c8a0de01be265cfa6c3ae0319615b2e18bdebe24b38cea8308efae29be8f640bf8eaa412e58f2c6cedb9d1aed6d7f6c4a1bec93aa6
6
+ metadata.gz: 34e49e6029571fd60cd6b73995a5859af78f991ee252d09b63f8bd5270a0f8a118830ce79a6d281a103c5a1e3c6d78fe26e9d4a3f9463993f3caa47b92abfd3a
7
+ data.tar.gz: e96a7090401e217445ebd31c05394b558d298017ed5dc24b353dbb777197216f7f4dbb3fb05d84900867a980839e09068f3507fd14a6cecb58c6faf9fc7bef6e
@@ -1,9 +1,11 @@
1
1
  require 'yard'
2
2
  require 'yard-sketchup/version'
3
+ require 'yard-sketchup/stubs/autoload'
3
4
  require 'yard-sketchup/yard/logger'
4
5
  require 'yard-sketchup/yard/handlers/class_constants'
5
6
  require 'yard-sketchup/yard/handlers/class_enum_constants'
6
7
  require 'yard-sketchup/yard/handlers/global_constants'
8
+ require 'yard-sketchup/patches/c_base_handler'
7
9
 
8
10
  module SketchUpYARD
9
11
 
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ module YARD
3
+ module Handlers
4
+ module C
5
+ class Base < Handlers::Base
6
+
7
+ # Temporary workaround until a proper fix can be applied to YARD master.
8
+ alias_method :namespace_for_variable_original, :namespace_for_variable
9
+ def namespace_for_variable(var)
10
+ patch_namespace_for_variable(var) ||
11
+ namespace_for_variable_original(var)
12
+ end
13
+
14
+ private
15
+
16
+ def patch_namespace_for_variable(var)
17
+ name = PATCH_ERROR_NAME[var]
18
+ # $stderr.puts "Mapped #{var} to #{name}" if name
19
+ name.nil? ? nil : P(name)
20
+ end
21
+
22
+ # Generated by update_error_map.rb (Copy+past results)
23
+ PATCH_ERROR_NAME = {
24
+ 'rb_eException' => 'Exception',
25
+ 'rb_eSystemExit' => 'SystemExit',
26
+ 'rb_eFatal' => 'fatal',
27
+ 'rb_eSignal' => 'SignalException',
28
+ 'rb_eInterrupt' => 'Interrupt',
29
+ 'rb_eStandardError' => 'StandardError',
30
+ 'rb_eTypeError' => 'TypeError',
31
+ 'rb_eArgError' => 'ArgumentError',
32
+ 'rb_eIndexError' => 'IndexError',
33
+ 'rb_eKeyError' => 'KeyError',
34
+ 'rb_eRangeError' => 'RangeError',
35
+ 'rb_eScriptError' => 'ScriptError',
36
+ 'rb_eSyntaxError' => 'SyntaxError',
37
+ 'rb_eLoadError' => 'LoadError',
38
+ 'rb_eNotImpError' => 'NotImplementedError',
39
+ 'rb_eNameError' => 'NameError',
40
+ 'rb_eNoMethodError' => 'NoMethodError',
41
+ 'rb_eRuntimeError' => 'RuntimeError',
42
+ 'rb_eFrozenError' => 'FrozenError',
43
+ 'rb_eSecurityError' => 'SecurityError',
44
+ 'rb_eNoMemError' => 'NoMemoryError',
45
+ 'rb_eEncodingError' => 'EncodingError',
46
+ 'rb_eSystemCallError' => 'SystemCallError',
47
+ }
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,134 @@
1
+ module SketchUpYARD
2
+ module Stubs
3
+ class AutoLoadGenerator
4
+
5
+ # @param [YARD::CodeObject::Base] namespace_objects
6
+ # @param [IO] out
7
+ def generate(namespace_objects, out)
8
+ dependencies = resolve_dependencies(namespace_objects)
9
+ out.puts "# This file is auto-generated by the `thor stubs` command."
10
+ required = Set.new
11
+ # Top level is special case.
12
+ top_level_path = File.join(sketchup_stubs_path, '_top_level.rb')
13
+ out.puts "require '#{top_level_path}'"
14
+ # The rest is resolved recursively.
15
+ dependencies.each { |object|
16
+ recurse_require(object, required, out)
17
+ }
18
+ end
19
+
20
+ private
21
+
22
+ class Node
23
+
24
+ attr_reader :object
25
+ attr_reader :dependencies
26
+
27
+ def initialize(object)
28
+ @object = object
29
+ @dependencies = SortedSet.new
30
+ end
31
+
32
+ def root?
33
+ @object.namespace.root?
34
+ end
35
+
36
+ def path
37
+ @object.path
38
+ end
39
+
40
+ def namespace
41
+ @object.namespace
42
+ end
43
+
44
+ def <<(object)
45
+ @dependencies << object
46
+ end
47
+
48
+ def <=>(other)
49
+ @object.path <=> other.path
50
+ end
51
+
52
+ def hash
53
+ @object.path.hash
54
+ end
55
+
56
+ end
57
+
58
+
59
+ class NodeFactory
60
+
61
+ def initialize
62
+ @dependencies = {}
63
+ end
64
+
65
+ def node(yard_object)
66
+ item = @dependencies[yard_object.path]
67
+ return item if item
68
+ item = Node.new(yard_object)
69
+ @dependencies[yard_object.path] = item
70
+ item
71
+ end
72
+
73
+ end
74
+
75
+
76
+ def resolve_dependencies(yard_objects)
77
+ factory = NodeFactory.new
78
+ dependencies = SortedSet.new
79
+
80
+ yard_objects.each { |yard_object|
81
+ object = factory.node(yard_object)
82
+
83
+ if yard_object.type == :class && yard_object.superclass.name != :Object
84
+ object << factory.node(yard_object.superclass)
85
+ end
86
+
87
+ unless yard_object.namespace.path.empty?
88
+ object << factory.node(yard_object.namespace)
89
+ end
90
+
91
+ dependencies << object
92
+ }
93
+ dependencies
94
+ end
95
+
96
+ def print_dependencies(object, indent = 0)
97
+ indent_space = ' ' * indent
98
+ puts "#{indent_space}#{object.path}"
99
+ object.dependencies.each { |dependency|
100
+ print_dependencies(dependency, indent + 1)
101
+ }
102
+ end
103
+
104
+ def sketchup_stubs_path
105
+ File.join('sketchup-api-stubs', 'stubs')
106
+ end
107
+
108
+ def stub_filename(object)
109
+ basename = object.path.gsub('::', '/')
110
+ basename = '_top_level' if basename.empty?
111
+ File.join(sketchup_stubs_path, "#{basename}.rb")
112
+ end
113
+
114
+ def recurse_require(object, required, out, indent = 0)
115
+ return if required.include?(object.path)
116
+ # If a class inherit from a core Ruby class we might get a Proxy code
117
+ # object here. We don't generate stubs for those and thus we don't want
118
+ # to create a require for them either.
119
+ return if object.object.is_a?(YARD::CodeObjects::Proxy)
120
+ # First require the dependencies.
121
+ object.dependencies.each { |dependency|
122
+ recurse_require(dependency, required, out, indent + 1)
123
+ }
124
+ # Then we're good to require this object.
125
+ require_path = stub_filename(object)
126
+ # indent_space = ' ' * indent
127
+ # out.puts "#{indent_space}require '#{require_path}'"
128
+ out.puts "require '#{require_path}'"
129
+ required << object.path
130
+ end
131
+
132
+ end
133
+ end
134
+ end
@@ -28,6 +28,9 @@ def generate_manifest
28
28
  # TODO(thomthom): Currently the manifest doesn't distinguish between
29
29
  # class and instance methods. This should be addressed, but we need to
30
30
  # update TestUp to handle this first.
31
+ # TODO(thomthom): Make this a configurable filter.
32
+ # Layout has its own tests - and should be isolated so its own suite.
33
+ next if method.namespace.to_s.start_with?('Layout')
31
34
  methods << "#{method.namespace}.#{method.name}"
32
35
  }
33
36
  end
@@ -102,6 +102,16 @@ h2 small a {
102
102
  }
103
103
 
104
104
 
105
+ p.signature .aliases,
106
+ h3.signature .aliases {
107
+ color: #ccc;
108
+ }
109
+ p.signature .aliases .names,
110
+ h3.signature .aliases .names {
111
+ color: #fff;
112
+ }
113
+
114
+
105
115
  /* Ensure content is scrollable on small screens. */
106
116
  @media (max-width: 920px) {
107
117
  #main {
@@ -1,7 +1,29 @@
1
+ # Helpers:
2
+
3
+ # Copy verbatim an asset file to the target output. By default it uses the
4
+ # same relative path as the source for the target path.
5
+ def copy(source, target = nil)
6
+ path = self.class.find_file(source)
7
+ # puts "copy(#{source}, #{target})"
8
+ # puts "> path: #{path}"
9
+ raise ArgumentError, "no file for '#{source}' in #{self.class.path}" unless path
10
+ target ||= source
11
+ asset(target, File.binread(path))
12
+ end
13
+
14
+ # Template overrides:
15
+
1
16
  def javascripts_full_list
2
17
  %w(js/jquery.js js/full_list.js js/sketchup.js)
3
18
  end
4
19
 
20
+ def generate_assets
21
+ super
22
+ copy('favicon.ico')
23
+ copy('images/SU_Developer-RedWhite.png')
24
+ copy('images/trimble-logo-white.png')
25
+ end
26
+
5
27
  # Custom search list grouping the classes in the API into similar groups.
6
28
  # TODO(thomthom): This file is just a stub.
7
29
 
@@ -2,32 +2,32 @@
2
2
  case object
3
3
  when String
4
4
  if object == "_index.html" || object == "index.html"
5
- su_page_url = "http://ruby.sketchup.com/index.html"
5
+ su_page_url = "https://ruby.sketchup.com/index.html"
6
6
  su_page_title = "Alphabetic Index"
7
7
  su_page_desc = "Alphabetic Index of Files and API Namespaces. This is the main landing page for the SketchUp Ruby API Documentation."
8
8
  else
9
- su_page_url = "http://ruby.sketchup.com/"+(object =~ /(.html)\z/ ? object : "#{File.basename(object,'.*')}.html" )
9
+ su_page_url = "https://ruby.sketchup.com/"+(object =~ /(.html)\z/ ? object : "#{File.basename(object,'.*')}.html" )
10
10
  su_page_title = (@page_title && !@page_title.empty?) ? (h @page_title) : object.split('.')[0]
11
11
  su_page_desc = "The #{su_page_title} page."
12
12
  end
13
13
  when YARD::CodeObjects::Base # or subclass
14
- if object.root?
14
+ if object.root?
15
15
  if @file # Generating a YARD::CodeObjects::ExtraFileObject
16
- su_page_url = "http://ruby.sketchup.com/file.#{File.basename(@file.filename,'.*')}.html"
16
+ su_page_url = "https://ruby.sketchup.com/file.#{File.basename(@file.filename,'.*')}.html"
17
17
  su_page_title = h @page_title
18
18
  su_page_desc = @file.title
19
19
  elsif h @page_title == "Top Level Namespace"
20
- su_page_url = "http://ruby.sketchup.com/top-level-namespace.html"
20
+ su_page_url = "https://ruby.sketchup.com/top-level-namespace.html"
21
21
  su_page_title = h @page_title
22
22
  su_page_desc = "The Top Level Namespace for Ruby and the SketchUp API, listing global constants, and a summary of toplevel modules and classes."
23
23
  else %>
24
24
  <!-- <%= "YARD Error - (embed_meta.erb) Unknown root object - using site name." %>--><%
25
25
  su_page_title = su_site_name
26
- su_page_url = "http://ruby.sketchup.com/"
26
+ su_page_url = "https://ruby.sketchup.com/"
27
27
  su_page_desc = "#{su_site_name}."
28
28
  end
29
29
  else # Generating a Class or Module page:
30
- su_page_url = "http://ruby.sketchup.com/#{@path.gsub('::','/')}.html"
30
+ su_page_url = "https://ruby.sketchup.com/#{@path.gsub('::','/')}.html"
31
31
  su_page_title = h @page_title
32
32
  if object.docstring.blank?
33
33
  if object.is_a?(YARD::CodeObjects::ClassObject)
@@ -45,7 +45,7 @@
45
45
  else # object is unexpected type %>
46
46
  <!-- <%= "YARD Error - (embed_meta.erb) Unexpected type: #{object.class.name}" %>--><%
47
47
  su_page_title = su_site_name
48
- su_page_url = "http://ruby.sketchup.com/"
48
+ su_page_url = "https://ruby.sketchup.com/"
49
49
  if object.respond_to?(:docstring)
50
50
  su_page_desc = object.docstring.summary.gsub(/[{}+]/,'')
51
51
  else
@@ -75,4 +75,4 @@
75
75
  <meta name="twitter:title" content="<%= su_page_title %>" />
76
76
  <meta name="twitter:description" content="<%= su_page_desc %>" />
77
77
  <meta name="twitter:image:src" content="<%= su_page_img %>?s=120" />
78
- <meta name="twitter:url" content="<%= su_page_url %>" />
78
+ <meta name="twitter:url" content="<%= su_page_url %>" />
@@ -1,4 +1,4 @@
1
1
  <div id="footer">
2
2
  Generated by
3
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
3
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
4
4
  </div>
@@ -3,7 +3,7 @@
3
3
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
4
4
  <!-- AUTHOR and GENERATOR -->
5
5
  <meta name="author" content="SketchUp Extensibility Team">
6
- <meta name="generator" content="YARD http://yardoc.org">
6
+ <meta name="generator" content="YARD https://yardoc.org">
7
7
  <!-- TITLE -->
8
8
  <title><% if object == "_index.html" || object == "index.html" %>
9
9
  Alphabetic Index &mdash; <%= h options.title %><% else %>
@@ -11,5 +11,5 @@
11
11
  </title>
12
12
  <!-- SHORTCUT ICON -->
13
13
  <link rel="shortcut icon" type="image/vnd.microsoft.icon"
14
- href="https://developer.sketchup.com/sites/all/themes/sketch_help/favicon.ico" />
15
- <%= erb(:embed_meta) %>
14
+ href="https://ruby.sketchup.com/favicon.ico" />
15
+ <%= erb(:embed_meta) %>
@@ -2,8 +2,8 @@
2
2
  <header id="navbar" role="banner" class="navbar navbar-fixed-top navbar-inverse">
3
3
  <div id="api-documentation-header">
4
4
  <div class="navbar-header">
5
- <a class="logo navbar-btn pull-left" href="http://developer.sketchup.com" title="Home">
6
- <img src="https://www.sketchup.com/sites/www.sketchup.com/files/ruby/SU_Developer-RedWhite.png" alt="Home">
5
+ <a class="logo navbar-btn pull-left" href="https://developer.sketchup.com" title="Home">
6
+ <img src="https://ruby.sketchup.com/images/SU_Developer-RedWhite.png" alt="Home">
7
7
  </a>
8
8
  <a class="name navbar-brand" href="/en" title="Home">SketchUp Developer Center</a>
9
9
  <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
@@ -17,15 +17,15 @@
17
17
  <div class="navbar-collapse collapse">
18
18
  <nav role="navigation">
19
19
  <ul class="menu nav navbar-nav">
20
- <li class="first leaf"><a href="http://forums.sketchup.com/c/developers">Community</a></li>
21
- <li class="leaf"><a href="http://blog.sketchup.com/tags/developers">SketchUpdate Blog</a></li>
22
- <li class="leaf"><a href="http://www.sketchup.com/download" class="top-menu--download-button">Download</a></li>
20
+ <li class="first leaf"><a href="https://forums.sketchup.com/c/developers">Community</a></li>
21
+ <li class="leaf"><a href="https://blog.sketchup.com/">SketchUp Blog</a></li>
22
+ <li class="leaf"><a href="https://www.sketchup.com/download" class="top-menu--download-button">Download</a></li>
23
23
  <li class="last expanded dropdown">
24
- <a href="http://www.trimble.com" class="trimble-top-menu-item dropdown-toggle" data-target="#" data-toggle="dropdown"><img src="https://www.sketchup.com/sites/www.sketchup.com/files/ruby/trimble-logo-white.png"><span class="caret"></span></a>
24
+ <a href="https://www.trimble.com" class="trimble-top-menu-item dropdown-toggle" data-target="#" data-toggle="dropdown"><img src="https://ruby.sketchup.com/images/trimble-logo-white.png"><span class="caret"></span></a>
25
25
  <ul class="dropdown-menu">
26
- <li class="first leaf"><a href="http://connect.trimble.com/">Trimble Connect</a></li>
26
+ <li class="first leaf"><a href="https://connect.trimble.com/">Trimble Connect</a></li>
27
27
  <li class="leaf"><a href="https://www.trimble.com/Corporate/About_Trimble.aspx">About Trimble</a></li>
28
- <li class="last leaf"><a href="http://buildings.trimble.com/">Trimble Buildings</a></li>
28
+ <li class="last leaf"><a href="https://buildings.trimble.com/">Trimble Buildings</a></li>
29
29
  </ul>
30
30
  </li>
31
31
  </ul>
@@ -1,75 +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
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
@@ -17,31 +17,21 @@ def namespace_objects
17
17
  run_verifier(Registry.all(:class, :module))
18
18
  end
19
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
20
  def generate_stubs
39
21
  puts "Generating stubs..."
40
22
  generate_module_stubs(Registry.root)
41
23
  namespace_objects.each do |object|
42
24
  generate_module_stubs(object)
43
25
  end
44
- generate_autoload
26
+ generate_autoloader(namespace_objects)
27
+ end
28
+
29
+ def generate_autoloader(namespace_objects)
30
+ generator = SketchUpYARD::Stubs::AutoLoadGenerator.new
31
+ autoload_file = File.join(stubs_gem_path, 'sketchup.rb')
32
+ File.open(autoload_file, 'w') do |file|
33
+ generator.generate(namespace_objects, file)
34
+ end
45
35
  end
46
36
 
47
37
  def print_section(io, title, content)
@@ -101,22 +91,34 @@ def output_path
101
91
  options.serializer.options[:basepath] || File.join(Dir.pwd, 'stubs')
102
92
  end
103
93
 
104
- def stubs_path
94
+ def stubs_root_path
105
95
  ensure_exist(output_path)
106
96
  end
107
97
 
108
- def autoload_stubs_path
109
- ensure_exist(File.join(stubs_path, 'autoload'))
98
+ def stubs_lib_path
99
+ ensure_exist(File.join(stubs_root_path, 'lib'))
110
100
  end
111
101
 
112
- def sketchup_stubs_path
113
- ensure_exist(File.join(stubs_path, 'SketchUp'))
102
+ def stubs_gem_path
103
+ ensure_exist(File.join(stubs_lib_path, 'sketchup-api-stubs'))
104
+ end
105
+
106
+ def stubs_path
107
+ ensure_exist(File.join(stubs_gem_path, 'stubs'))
114
108
  end
115
109
 
116
110
  def stub_filename(object)
117
111
  basename = object.path.gsub('::', '/')
118
112
  basename = '_top_level' if basename.empty?
119
- File.join(sketchup_stubs_path, "#{basename}.rb")
113
+ File.join(stubs_path, "#{basename}.rb")
114
+ end
115
+
116
+ # A stable sort_by method.
117
+ #
118
+ # @param [Enumerable]
119
+ # @return [Array]
120
+ def stable_sort_by(list)
121
+ list.each_with_index.sort_by { |item, i| [yield(item), i] }.map(&:first)
120
122
  end
121
123
 
122
124
  CAMELCASE_CONSTANT = /^([A-Z]+[a-z]+)/
@@ -150,9 +152,7 @@ def generate_constants_grouped(object)
150
152
  grouped_output = groups.map { |group, group_constants|
151
153
  output = StringIO.new
152
154
  # 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
- }
155
+ sorted = stable_sort_by(group_constants, &:name)
156
156
  sorted.each { |constant|
157
157
  output.puts " #{constant.name} = nil # Stub value."
158
158
  }
@@ -160,17 +160,14 @@ def generate_constants_grouped(object)
160
160
  }
161
161
  # Finally each group is also sorted, again to ease scanning for a particular
162
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")
163
+ stable_sort_by(grouped_output) { |item| item.lstrip[0] }.join("\n")
166
164
  end
167
165
 
168
166
  # Sort constants without grouping.
169
167
  def generate_constants(object)
170
168
  output = StringIO.new
171
- constants = run_verifier(object.constants(object_options)).sort { |a, b|
172
- a.name <=> b.name
173
- }
169
+ constants = run_verifier(object.constants(object_options))
170
+ constants = stable_sort_by(constants, &:name)
174
171
  constants.each { |constant|
175
172
  output.puts " #{constant.name} = nil # Stub value."
176
173
  }
@@ -180,9 +177,8 @@ end
180
177
  def generate_mixins(object, scope)
181
178
  output = StringIO.new
182
179
  mixin_type = (scope == :class) ? 'extend' : 'include'
183
- mixins = run_verifier(object.mixins(scope)).sort { |a, b|
184
- a.path <=> b.path
185
- }
180
+ mixins = run_verifier(object.mixins(scope))
181
+ mixins = stable_sort_by(mixins, &:path)
186
182
  mixins.each { |mixin|
187
183
  output.puts " #{mixin_type} #{mixin.path}"
188
184
  }
@@ -261,9 +257,7 @@ def sort_methods(object, scope)
261
257
  objects = methods.select { |method|
262
258
  method.scope == scope
263
259
  }
264
- objects.sort { |a, b|
265
- a.name <=> b.name
266
- }
260
+ stable_sort_by(objects, &:name)
267
261
  end
268
262
 
269
263
  def object_options
@@ -1,3 +1,3 @@
1
1
  module SketchUpYARD
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.1.4'.freeze
3
3
  end
@@ -1,17 +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
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
@@ -1,17 +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
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
@@ -1,19 +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
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
@@ -1,45 +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.
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.
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
  ]
22
22
 
23
23
  spec.add_dependency 'yard', '~> 0.9.18'
24
- spec.add_development_dependency 'bundler', '~> 1.13'
24
+ spec.add_development_dependency 'bundler', '>= 1.15.0', '< 3.0'
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-sketchup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trimble Inc, SketchUp Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-28 00:00:00.000000000 Z
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.15.0
34
+ - - "<"
32
35
  - !ruby/object:Gem::Version
33
- version: '1.13'
36
+ version: '3.0'
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.15.0
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: '1.13'
46
+ version: '3.0'
41
47
  description: SketchUp Ruby API YARD template.
42
48
  email:
43
49
  executables: []
@@ -46,11 +52,16 @@ extra_rdoc_files: []
46
52
  files:
47
53
  - Gemfile
48
54
  - lib/yard-sketchup.rb
55
+ - lib/yard-sketchup/patches/c_base_handler.rb
56
+ - lib/yard-sketchup/stubs/autoload.rb
49
57
  - lib/yard-sketchup/templates/changelog/fulldoc/text/setup.rb
50
58
  - lib/yard-sketchup/templates/coverage/fulldoc/text/setup.rb
51
59
  - lib/yard-sketchup/templates/default/fulldoc/html/css/rubyapi.css
52
60
  - lib/yard-sketchup/templates/default/fulldoc/html/css/sketchup.css
61
+ - lib/yard-sketchup/templates/default/fulldoc/html/favicon.ico
53
62
  - lib/yard-sketchup/templates/default/fulldoc/html/full_list_object_types.erb
63
+ - lib/yard-sketchup/templates/default/fulldoc/html/images/SU_Developer-RedWhite.png
64
+ - lib/yard-sketchup/templates/default/fulldoc/html/images/trimble-logo-white.png
54
65
  - lib/yard-sketchup/templates/default/fulldoc/html/js/sketchup.js
55
66
  - lib/yard-sketchup/templates/default/fulldoc/html/setup.rb
56
67
  - lib/yard-sketchup/templates/default/layout/html/embed_meta.erb