orthoses-yard 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4360149f5950080699830fd17881758b818f6b02df358056975744cb3f883e47
4
- data.tar.gz: 877833515ad18d0e39f04a7526a055eacbc5bd92d6b3404363a747f67cb38edb
3
+ metadata.gz: 6417c32f741a5dfc134166c945908278cbd986d2a2004a8fa4cdede7155e63d0
4
+ data.tar.gz: 45d9288f5ddfe277dd5592cc65103d3961aa195df8af80a3707f1309ee0d8344
5
5
  SHA512:
6
- metadata.gz: a20fe50f64fd4b0bef16fe325b80a539a6fe3424cbaab57a42e6f20a290c3497d519f629a5509ee181493d05019f10fa1dda10f85bdb7c44ef4fced8c0283d84
7
- data.tar.gz: 87ea6a5128e5a37635e6f294f8fb1c96491bcd672cfce54f4682982727943f69e037fa683283800cc3fd62d8198671969817d040f34cce5210450f0a20499fc1
6
+ metadata.gz: c929d6d2754ba40898f13213289da72cf66a4977a04626c3670a3dbb85717007f93c254654fbd50d86f0b91c1a179ed47c180496b5210b22182ad6008fb8f358
7
+ data.tar.gz: e918f5642b21d48b95c3b47c774c71537481310829206a73ab6e1f4844ed4a66cec81b1243bed6734993d5cecddd46fb9a9777053fbf18cd8e416f8ca3920d1b
data/README.md CHANGED
@@ -50,7 +50,14 @@ end
50
50
 
51
51
  ## Usage
52
52
 
53
- Please see https://github.com/ksss/orthoses-yard/blob/main/examples/yard/Rakefile
53
+ ```rb
54
+ use Orthoses::YARD,
55
+ parse: ['{lib,app}/**/*.rb'], # Target files (require)
56
+ use_cache: true, # Use cache .yardoc database (optional default=true)
57
+ log_level: :debug # Set log level for YARD (optional default=nil)
58
+ ```
59
+
60
+ Please see also https://github.com/ksss/orthoses-yard/blob/main/examples/yard/generate.rb
54
61
 
55
62
  ## Development
56
63
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Orthoses
4
4
  class YARD
5
- VERSION = "0.2.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
@@ -48,6 +48,32 @@ module Orthoses
48
48
  generate_for_classvariable
49
49
  end
50
50
 
51
+ # @return [RBS::Types::t]
52
+ def tag_types_to_rbs_type(tag_types)
53
+ return untyped if tag_types.nil?
54
+
55
+ tag_types = tag_types.compact.uniq
56
+ return untyped if tag_types.empty?
57
+
58
+ begin
59
+ types_explainers = ::YARD::Tags::TypesExplainer::Parser.parse(tag_types.join(", "))
60
+ rescue SyntaxError => e
61
+ Orthoses.logger.warn("#{tag_types} in #{yardoc.inspect} cannot parse as tags. use untyped instead")
62
+ Orthoses.logger.warn(" => exception message=`#{e.message}`")
63
+ return untyped
64
+ end
65
+
66
+ Utils::TypeList.new(recursive_resolve(types_explainers)).inject.tap do |rbs|
67
+ Orthoses.logger.debug("#{yardoc.inspect} tag #{tag_types} => #{rbs}")
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def class_of(mod)
74
+ Kernel.instance_method(:class).bind_call(mod)
75
+ end
76
+
51
77
  # @return [void]
52
78
  def generate_for_attributes
53
79
  yardoc.attributes.each do |kind, attributes|
@@ -88,13 +114,13 @@ module Orthoses
88
114
 
89
115
  begin
90
116
  mod = Object.const_get(namespace.to_s)
91
- case meth.scope
92
- when :class
93
- prefix = 'self.'
94
- method_object = mod.method(method_name)
95
- when :instance
117
+ case
118
+ when meth.scope == :instance || class_of(meth) == ::YARD::CodeObjects::ExtendedMethodObject
96
119
  prefix = ''
97
120
  method_object = mod.instance_method(method_name)
121
+ when meth.scope == :class
122
+ prefix = 'self.'
123
+ method_object = mod.method(method_name)
98
124
  else
99
125
  raise "bug"
100
126
  end
@@ -116,8 +142,6 @@ module Orthoses
116
142
  required_keywords = {}
117
143
  optional_keywords = {}
118
144
  rest_keywords = nil
119
- yield_params = []
120
- yield_return = nil
121
145
 
122
146
  requireds = required_positionals
123
147
 
@@ -224,65 +248,6 @@ module Orthoses
224
248
  end
225
249
  end
226
250
 
227
- # @return [RBS::Types::t]
228
- def tag_types_to_rbs_type(tag_types)
229
- return untyped if tag_types.nil?
230
- return untyped if tag_types.empty?
231
-
232
- begin
233
- types_explainers = ::YARD::Tags::TypesExplainer::Parser.parse(tag_types.uniq.join(", "))
234
- rescue SyntaxError
235
- Orthoses.logger.warn("#{tag_types} in #{yardoc.inspect} cannot parse as tags. use untyped instead")
236
- return untyped
237
- end
238
-
239
- wrap(recursive_resolve(types_explainers)).tap do |rbs|
240
- Orthoses.logger.debug("#{yardoc.inspect} tag #{tag_types} => #{rbs}")
241
- end
242
- end
243
-
244
- # @return [RBS::Types::t]
245
- def wrap(types)
246
- if types.nil? || types.empty? || types == [untyped]
247
- return untyped
248
- end
249
-
250
- if 1 < types.length
251
- if index = types.find_index { |t| t.to_s == "nil" }
252
- types.delete_at(index)
253
- is_optional = true
254
- if types == [untyped]
255
- return untyped
256
- end
257
- end
258
- end
259
- is_union = 1 < types.length
260
-
261
- if is_union
262
- if is_optional
263
- ::RBS::Types::Optional.new(
264
- type: ::RBS::Types::Union.new(
265
- types: types,
266
- location: nil,
267
- ),
268
- location: nil,
269
- )
270
- else
271
- ::RBS::Types::Union.new(
272
- types: types,
273
- location: nil,
274
- )
275
- end
276
- elsif is_optional
277
- ::RBS::Types::Optional.new(
278
- type: types.first,
279
- location: nil,
280
- )
281
- else
282
- types.first
283
- end
284
- end
285
-
286
251
  # @return [Array<RBS::Types::t>]
287
252
  def recursive_resolve(types_explainer_types)
288
253
  types_explainer_types.map do |types_explainer_type|
@@ -293,7 +258,7 @@ module Orthoses
293
258
  location: nil
294
259
  )
295
260
  when ::YARD::Tags::TypesExplainer::CollectionType
296
- type = wrap(recursive_resolve(types_explainer_type.types))
261
+ type = Utils::TypeList.new(recursive_resolve(types_explainer_type.types)).inject
297
262
  if types_explainer_type.name == "Class"
298
263
  if type.to_s == "untyped"
299
264
  untyped
@@ -314,8 +279,8 @@ module Orthoses
314
279
  ::RBS::Types::ClassInstance.new(
315
280
  name: TypeName(types_explainer_type.name),
316
281
  args: [
317
- wrap(recursive_resolve(types_explainer_type.key_types)),
318
- wrap(recursive_resolve(types_explainer_type.value_types)),
282
+ Utils::TypeList.new(recursive_resolve(types_explainer_type.key_types)).inject,
283
+ Utils::TypeList.new(recursive_resolve(types_explainer_type.value_types)).inject,
319
284
  ],
320
285
  location: nil
321
286
  )
@@ -349,8 +314,14 @@ module Orthoses
349
314
  # end
350
315
  else
351
316
  case types_explainer_type.name
352
- when "Object" then next untyped
353
- when "Boolean" then next bool
317
+ when "Object"
318
+ next untyped
319
+ when "Boolean", "TrueClass", "FalseClass", "true", "false"
320
+ next bool
321
+ when "NilClass", "nil"
322
+ next ::RBS::Types::Bases::Nil.new(location: nil)
323
+ when "Fixnum"
324
+ next ::RBS::Types::ClassInstance.new(name: TypeName("Integer"), args: [], location: nil)
354
325
  end
355
326
 
356
327
  begin
@@ -361,6 +332,7 @@ module Orthoses
361
332
  when ::RBS::Types::Alias
362
333
  end
363
334
  rescue ::RBS::ParsingError
335
+ # will be unresolve type
364
336
  end
365
337
 
366
338
  if Utils.rbs_defined_class?(types_explainer_type.name, collection: true)
@@ -370,22 +342,13 @@ module Orthoses
370
342
  location: nil
371
343
  )
372
344
  else
373
- name =
374
- case types_explainer_type.name
375
- when "Fixnum"
376
- "Integer"
377
- else
378
- resolved = ::YARD::Registry.resolve(yardoc.namespace, types_explainer_type.name, true, false)
379
- if resolved
380
- resolved.to_s
381
- else
382
- Orthoses.logger.warn("#{types_explainer_type.name} in #{yardoc.namespace} set `untyped` because it cannot resolved type")
383
- next untyped
384
- end
385
- end
386
-
345
+ resolved = ::YARD::Registry.resolve(yardoc, types_explainer_type.name, true, false)
346
+ unless resolved
347
+ Orthoses.logger.warn("yardoc type=[#{types_explainer_type.name}] in #{yardoc.path} set `untyped` because it cannot resolved type by `::YARD::Registry.resolve`")
348
+ next untyped
349
+ end
387
350
  ::RBS::Types::ClassInstance.new(
388
- name: TypeName(name),
351
+ name: TypeName(resolved.to_s),
389
352
  args: [],
390
353
  location: nil
391
354
  )
data/lib/orthoses/yard.rb CHANGED
@@ -6,22 +6,39 @@ require_relative "yard/yard2rbs"
6
6
  module Orthoses
7
7
  # use Orthoses::YARD, parse: "lib/**/*.rb"
8
8
  class YARD
9
- def initialize(loader, parse:)
9
+ # @param loader
10
+ # @param [<String>, String] parse Target files
11
+ # @param [Boolean] use_cache Use cache .yardoc
12
+ # @param [Symbol, nil] log_level Set YARD log level
13
+ def initialize(loader, parse:, use_cache: true, log_level: nil)
10
14
  @loader = loader
11
15
  @parse = Array(parse)
16
+ @use_cache = use_cache
17
+ @log_level = log_level
12
18
  end
13
19
 
20
+ # @return [void]
14
21
  def call
15
22
  @loader.call.tap do |store|
16
23
  require 'yard'
17
24
 
25
+ log.level = @log_level if @log_level
26
+
27
+ ::YARD::Registry.load if @use_cache
18
28
  ::YARD.parse(@parse)
29
+ ::YARD::Registry.save(true) if @use_cache
19
30
  ::YARD::Registry.root.children.each do |yardoc|
31
+ # Skip anonymous yardoc
32
+ next unless yardoc.file
33
+
34
+ # Skip external doc (e.g. pry-doc)
35
+ next unless @parse.any? { |pattern| File.fnmatch(pattern, yardoc.file, File::FNM_EXTGLOB | File::FNM_PATHNAME) }
36
+
20
37
  case yardoc.type
21
38
  when :class, :module
22
39
  YARD2RBS.run(yardoc: yardoc) do |namespace, docstring, rbs|
23
40
  comment = docstring.each_line.map { |line| "# #{line}" }.join
24
- if rbs.nil?
41
+ if rbs.nil? && comment && !store.has_key?(namespace)
25
42
  store[namespace].comment = comment
26
43
  else
27
44
  Orthoses.logger.debug("#{namespace} << #{rbs}")
data/sig/orthoses.rbs ADDED
@@ -0,0 +1,43 @@
1
+ # GENERATED FILE
2
+
3
+ # use Orthoses::YARD, parse: "lib/**/*.rb"
4
+ class Orthoses::YARD
5
+ # @param loader
6
+ # @param [<String>, String] parse Target files
7
+ # @param [Boolean] use_cache Use cache .yardoc
8
+ # @param [Symbol, nil] log_level Set YARD log level
9
+ def initialize: (untyped loader, parse: Array[String] | String, ?use_cache: bool, ?log_level: Symbol?) -> void
10
+ # @return [void]
11
+ def call: () -> void
12
+ VERSION: untyped
13
+ end
14
+
15
+ class Orthoses::YARD::YARD2RBS
16
+ # @return [YARD::CodeObjects::t]
17
+ attr_reader yardoc: untyped
18
+ # @return [Proc]
19
+ attr_reader block: Proc
20
+ # @return [RBS::Types::Bases::Any]
21
+ attr_reader untyped: RBS::Types::Bases::Any
22
+ # @return [RBS::Types::Bases::Void]
23
+ attr_reader void: RBS::Types::Bases::Void
24
+ # @return [RBS::Types::Bases::Bool]
25
+ attr_reader bool: RBS::Types::Bases::Bool
26
+ def initialize: (yardoc: untyped, block: untyped) -> void
27
+ # @return [void]
28
+ def run: () -> void
29
+ # @return [RBS::Types::t]
30
+ def tag_types_to_rbs_type: (untyped tag_types) -> untyped
31
+ # @return [void]
32
+ private def generate_for_attributes: () -> void
33
+ # @return [void]
34
+ private def generate_for_methods: () -> void
35
+ # @return [void]
36
+ private def generate_for_constants: () -> void
37
+ # @return [void]
38
+ private def generate_for_classvariable: () -> void
39
+ # @return [Array<RBS::Types::t>]
40
+ private def recursive_resolve: (untyped types_explainer_types) -> untyped
41
+ # @return [Array<RBS::Types::Bases::Any>]
42
+ private def temporary_type_params: (untyped name) -> Array[RBS::Types::Bases::Any]
43
+ end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orthoses-yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-12 00:00:00.000000000 Z
11
+ date: 2023-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orthoses
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.5.0
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 1.3.0
22
+ version: '2.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.0
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 1.3.0
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: yard
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -46,29 +52,13 @@ extensions: []
46
52
  extra_rdoc_files: []
47
53
  files:
48
54
  - CODE_OF_CONDUCT.md
49
- - Gemfile
50
- - Gemfile.lock
51
55
  - LICENSE.txt
52
56
  - README.md
53
- - examples/yard/Gemfile
54
- - examples/yard/Gemfile.lock
55
- - examples/yard/Rakefile
56
- - examples/yard/generate.rb
57
- - examples/yard/rbs_collection.lock.yaml
58
- - examples/yard/rbs_collection.yaml
59
- - examples/yard/templates/EXTERNAL_TODO.rbs
60
- - examples/yard/templates/_scripts/test.erb
61
- - examples/yard/templates/_test/Steepfile.erb
62
- - examples/yard/templates/_test/yard.rb
63
- - examples/yard/templates/manifest.yaml.erb
64
57
  - lib/orthoses-yard.rb
65
58
  - lib/orthoses/yard.rb
66
59
  - lib/orthoses/yard/version.rb
67
60
  - lib/orthoses/yard/yard2rbs.rb
68
- - orthoses-yard.gemspec
69
- - sig/orthoses/yard.rbs
70
- - sig/orthoses/yard/yard2_rbs.rbs
71
- - sig_patch/yard.rbs
61
+ - sig/orthoses.rbs
72
62
  homepage: https://github.com/ksss/orthoses-yard
73
63
  licenses:
74
64
  - MIT
@@ -91,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
81
  - !ruby/object:Gem::Version
92
82
  version: '0'
93
83
  requirements: []
94
- rubygems_version: 3.3.16
84
+ rubygems_version: 3.4.10
95
85
  signing_key:
96
86
  specification_version: 4
97
87
  summary: Orthoses extention for YARD.
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in orthoses-yard.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
- gem "rgot", "~> 1.1"
10
- gem "rbs"
11
- gem "steep"
12
- gem "debug"
data/Gemfile.lock DELETED
@@ -1,79 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- orthoses-yard (0.2.0)
5
- orthoses (~> 1.3.0)
6
- yard
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activesupport (7.0.4)
12
- concurrent-ruby (~> 1.0, >= 1.0.2)
13
- i18n (>= 1.6, < 2)
14
- minitest (>= 5.1)
15
- tzinfo (~> 2.0)
16
- ast (2.4.2)
17
- concurrent-ruby (1.1.10)
18
- debug (1.6.2)
19
- irb (>= 1.3.6)
20
- reline (>= 0.3.1)
21
- ffi (1.15.5)
22
- i18n (1.12.0)
23
- concurrent-ruby (~> 1.0)
24
- io-console (0.5.11)
25
- irb (1.4.2)
26
- reline (>= 0.3.0)
27
- language_server-protocol (3.17.0.1)
28
- listen (3.7.1)
29
- rb-fsevent (~> 0.10, >= 0.10.3)
30
- rb-inotify (~> 0.9, >= 0.9.10)
31
- minitest (5.16.3)
32
- orthoses (1.3.0)
33
- rbs (~> 2.0)
34
- parallel (1.22.1)
35
- parser (3.1.2.1)
36
- ast (~> 2.4.1)
37
- rainbow (3.1.1)
38
- rake (13.0.6)
39
- rb-fsevent (0.11.2)
40
- rb-inotify (0.10.1)
41
- ffi (~> 1.0)
42
- rbs (2.7.0)
43
- reline (0.3.1)
44
- io-console (~> 0.5)
45
- rgot (1.1.0)
46
- securerandom (0.2.0)
47
- steep (1.2.0)
48
- activesupport (>= 5.1)
49
- language_server-protocol (>= 3.15, < 4.0)
50
- listen (~> 3.0)
51
- parallel (>= 1.0.0)
52
- parser (>= 3.1)
53
- rainbow (>= 2.2.2, < 4.0)
54
- rbs (>= 2.7.0)
55
- securerandom (>= 0.1)
56
- terminal-table (>= 2, < 4)
57
- terminal-table (3.0.2)
58
- unicode-display_width (>= 1.1.1, < 3)
59
- tzinfo (2.0.5)
60
- concurrent-ruby (~> 1.0)
61
- unicode-display_width (2.3.0)
62
- webrick (1.7.0)
63
- yard (0.9.28)
64
- webrick (~> 1.7.0)
65
-
66
- PLATFORMS
67
- arm64-darwin-21
68
- x86_64-linux
69
-
70
- DEPENDENCIES
71
- debug
72
- orthoses-yard!
73
- rake (~> 13.0)
74
- rbs
75
- rgot (~> 1.1)
76
- steep
77
-
78
- BUNDLED WITH
79
- 2.3.16
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "yard"
6
- gem "orthoses-yard", path: "../../"
7
- gem "rake"
8
- gem "rack"
9
- gem "sord"
10
- gem "debug"
@@ -1,59 +0,0 @@
1
- PATH
2
- remote: ../..
3
- specs:
4
- orthoses-yard (0.1.0)
5
- orthoses (~> 1.2.0)
6
- yard
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- ast (2.4.2)
12
- commander (4.6.0)
13
- highline (~> 2.0.0)
14
- debug (1.6.2)
15
- irb (>= 1.3.6)
16
- reline (>= 0.3.1)
17
- highline (2.0.3)
18
- io-console (0.5.11)
19
- irb (1.4.2)
20
- reline (>= 0.3.0)
21
- orthoses (1.2.0)
22
- rbs (~> 2.0)
23
- parlour (5.0.0)
24
- commander (~> 4.5)
25
- parser
26
- rainbow (~> 3.0)
27
- sorbet-runtime (>= 0.5)
28
- parser (3.1.2.1)
29
- ast (~> 2.4.1)
30
- rack (3.0.0)
31
- rainbow (3.1.1)
32
- rake (13.0.6)
33
- rbs (2.7.0)
34
- reline (0.3.1)
35
- io-console (~> 0.5)
36
- sorbet-runtime (0.5.10482)
37
- sord (5.0.0)
38
- commander (~> 4.5)
39
- parlour (~> 5.0)
40
- rbs (~> 2.0)
41
- sorbet-runtime
42
- yard
43
- webrick (1.7.0)
44
- yard (0.9.28)
45
- webrick (~> 1.7.0)
46
-
47
- PLATFORMS
48
- arm64-darwin-21
49
-
50
- DEPENDENCIES
51
- debug
52
- orthoses-yard!
53
- rack
54
- rake
55
- sord
56
- yard
57
-
58
- BUNDLED WITH
59
- 2.3.16
@@ -1,7 +0,0 @@
1
- task :generate do
2
- load 'generate.rb'
3
- end
4
-
5
- task :validate do
6
- sh "rbs -I out validate --silent"
7
- end
@@ -1,81 +0,0 @@
1
- require 'orthoses-yard'
2
- require 'fileutils'
3
- require 'pathname'
4
- require 'erb'
5
-
6
- output_dir = 'out'
7
- FileUtils.rm_rf(output_dir)
8
- Orthoses.logger.level = :warn
9
-
10
- gem_path = Gem::Specification.find_by_name("yard").load_paths.first
11
- notice = "# !!! GENERATED FILE !!!\n# Please see generators/yard-generator/README.md\n"
12
-
13
- Orthoses::Builder.new do
14
- use Orthoses::CreateFileByName,
15
- base_dir: output_dir,
16
- header: notice
17
- use Orthoses::Filter do |name, content|
18
- name.start_with?('YARD') ||
19
- name.start_with?('Ripper') ||
20
- name.start_with?('OpenStruct') ||
21
- name.start_with?('SymbolHash') ||
22
- name.start_with?('Rake') ||
23
- name.start_with?('WEBrick') ||
24
- name.start_with?('RDoc')
25
- end
26
- use Orthoses::Tap do |store|
27
- store['YARD'].header = 'module YARD'
28
- store['YARD::CodeObjects'].header = 'module YARD::CodeObjects'
29
- store['YARD::Handlers'].header = 'module YARD::Handlers'
30
- store['YARD::Handlers::C'].header = 'module YARD::Handlers::C'
31
- store['YARD::Handlers::Common'].header = 'module YARD::Handlers::Common'
32
- store['YARD::Handlers::Ruby'].header = 'module YARD::Handlers::Ruby'
33
- # TODO: support generics
34
- store['YARD::Tags::Library'] << 'def self.labels: () -> SymbolHash'
35
-
36
- # FIXME: YARD's issue?
37
- store['YARD::CLI::YardocOptions'].delete("# @return [Numeric] An index value for rendering sequentially related templates\nattr_accessor index: Numeric")
38
- end
39
- use Orthoses::YARD,
40
- parse: [
41
- "#{gem_path}/yard.rb",
42
- "#{gem_path}/yard/**/*.rb",
43
- ]
44
- use Orthoses::Autoload
45
- run -> {
46
- require 'yard'
47
- YARD::Tags::Library.define_tag("YARD Tag Signature", 'yard.signature'.to_sym, nil)
48
- YARD::Tags::Library.define_tag("YARD Tag", 'yard.tag'.to_sym, :with_types_and_name)
49
- YARD::Tags::Library.define_tag("YARD Directive", 'yard.directive'.to_sym, :with_types_and_name)
50
- }
51
- end.call
52
-
53
- stdlib_dependencies = %w[
54
- set
55
- optparse
56
- logger
57
- monitor
58
- ]
59
-
60
- def erb(template_filename, **vars)
61
- "templates/#{template_filename}.erb"
62
- .then { File.expand_path(_1) }
63
- .then { File.read(_1) }
64
- .then { ERB.new(_1, trim_mode: '<>').result_with_hash(vars) }
65
- end
66
-
67
- out = Pathname(output_dir)
68
- out.join("EXTERNAL_TODO.rbs").write(erb("EXTERNAL_TODO.rbs", notice: notice))
69
- out.join("manifest.yaml").write(erb("manifest.yaml", notice: notice, stdlib_dependencies: stdlib_dependencies))
70
- out.join('_scripts').tap do |scripts|
71
- scripts.mkpath
72
- scripts.join("test").tap do |test|
73
- test.write(erb("_scripts/test", notice: notice, stdlib_dependencies: stdlib_dependencies))
74
- test.chmod(0o755)
75
- end
76
- end
77
- out.join('_test').tap do |test|
78
- test.mkpath
79
- test.join("yard.rb").write(erb("_test/yard.rb", notice: notice))
80
- test.join('Steepfile').write(erb("_test/Steepfile", notice: notice, stdlib_dependencies: stdlib_dependencies))
81
- end
@@ -1,80 +0,0 @@
1
- ---
2
- sources:
3
- - name: ruby/gem_rbs_collection
4
- remote: https://github.com/ruby/gem_rbs_collection.git
5
- revision: main
6
- repo_dir: gems
7
- path: ".gem_rbs_collection"
8
- gems:
9
- - name: rbs
10
- version: 2.7.0
11
- source:
12
- type: rubygems
13
- - name: ast
14
- version: '2.4'
15
- source:
16
- type: git
17
- name: ruby/gem_rbs_collection
18
- revision: 6b07483f37484e2b7df168598b95b0c79be2924f
19
- remote: https://github.com/ruby/gem_rbs_collection.git
20
- repo_dir: gems
21
- - name: io-console
22
- version: '0'
23
- source:
24
- type: stdlib
25
- - name: orthoses
26
- version: 1.2.0
27
- source:
28
- type: rubygems
29
- - name: orthoses-yard
30
- version: 0.1.0
31
- source:
32
- type: rubygems
33
- - name: rack
34
- version: '2.2'
35
- source:
36
- type: git
37
- name: ruby/gem_rbs_collection
38
- revision: 6b07483f37484e2b7df168598b95b0c79be2924f
39
- remote: https://github.com/ruby/gem_rbs_collection.git
40
- repo_dir: gems
41
- - name: rainbow
42
- version: '3.0'
43
- source:
44
- type: git
45
- name: ruby/gem_rbs_collection
46
- revision: 6b07483f37484e2b7df168598b95b0c79be2924f
47
- remote: https://github.com/ruby/gem_rbs_collection.git
48
- repo_dir: gems
49
- - name: logger
50
- version: '0'
51
- source:
52
- type: stdlib
53
- - name: set
54
- version: '0'
55
- source:
56
- type: stdlib
57
- - name: pathname
58
- version: '0'
59
- source:
60
- type: stdlib
61
- - name: json
62
- version: '0'
63
- source:
64
- type: stdlib
65
- - name: optparse
66
- version: '0'
67
- source:
68
- type: stdlib
69
- - name: tsort
70
- version: '0'
71
- source:
72
- type: stdlib
73
- - name: rdoc
74
- version: '0'
75
- source:
76
- type: stdlib
77
- - name: monitor
78
- version: '0'
79
- source:
80
- type: stdlib
@@ -1,12 +0,0 @@
1
- # Download sources
2
- sources:
3
- - name: ruby/gem_rbs_collection
4
- remote: https://github.com/ruby/gem_rbs_collection.git
5
- revision: main
6
- repo_dir: gems
7
-
8
- # A directory to install the downloaded RBSs
9
- path: .gem_rbs_collection
10
-
11
- gems:
12
- - name: rbs
@@ -1,30 +0,0 @@
1
- # It is a temporary definition of a type definition
2
- # for which the library RBS does not currently exist.
3
- # Once the library RBS is defined and included in rbs_collection.lock.yaml,
4
- # the duplicate type definitions in this file should be removed.
5
-
6
- class OpenStruct
7
- end
8
-
9
- class Ripper
10
- end
11
-
12
- module Rake
13
- class TaskLib
14
- end
15
- end
16
-
17
-
18
- module WEBrick
19
- module HTTPServlet
20
- class AbstractServlet
21
- end
22
- end
23
- end
24
-
25
- module RDoc
26
- module Markup
27
- class ToHtml
28
- end
29
- end
30
- end
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting.
4
- set -eou pipefail
5
- # Internal Field Separator - Linux shell variable
6
- IFS=$'
7
- '
8
- # Print shell input lines
9
- set -v
10
-
11
- # Set RBS_DIR variable to change directory to execute type checks using `steep check`
12
- RBS_DIR=$(cd $(dirname $0)/..; pwd)
13
- # Set REPO_DIR variable to validate RBS files added to the corresponding folder
14
- REPO_DIR=$(cd $(dirname $0)/../../..; pwd)
15
- # Validate RBS files, using the bundler environment present
16
- bundle exec rbs --repo $REPO_DIR -r yard:0.9 <%= stdlib_dependencies.map { "-r #{_1}" }.join(' ') %> -r rack:2.2.2 validate --silent
17
-
18
- cd ${RBS_DIR}/_test
19
- # Run type checks
20
- bundle exec steep check
@@ -1,17 +0,0 @@
1
- D = Steep::Diagnostic
2
-
3
- target :test do
4
- check "."
5
- signature '.'
6
-
7
- repo_path "../../../"
8
-
9
- <% stdlib_dependencies.each do |stdlib| %>
10
- library "<%= stdlib %>"
11
- <% end %>
12
-
13
- library "yard:0.9"
14
- library "rack:2.2.2"
15
-
16
- configure_code_diagnostics(D::Ruby.all_error)
17
- end
@@ -1,6 +0,0 @@
1
- require 'yard'
2
-
3
- YARD::Registry.root.children.each do |child|
4
- child.name(false)
5
- child.docstring.all
6
- end
@@ -1,4 +0,0 @@
1
- dependencies:
2
- <% stdlib_dependencies.each do |stdlib| %>
3
- - <%= stdlib %>
4
- <% end %>
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/orthoses/yard/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "orthoses-yard"
7
- spec.version = Orthoses::YARD::VERSION
8
- spec.authors = ["ksss"]
9
- spec.email = ["co000ri@gmail.com"]
10
-
11
- spec.summary = "Orthoses extention for YARD."
12
- spec.description = "Orthoses extention for YARD."
13
- spec.homepage = "https://github.com/ksss/orthoses-yard"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = spec.homepage
20
-
21
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
- `git ls-files -z`.split("\x0").reject do |f|
23
- next true if (f == __FILE__)
24
- next true if f.match?(%r{\A(?:bin|known_sig)/}) # dir
25
- next true if f.match?(%r{\A\.(?:git)}) # git
26
- next true if f.match?(%r{\A(?:rbs_collection|Steepfile|Rakefile)}) # top file
27
- next true if f.match?(%r{_test\.rb\z}) # test
28
- false
29
- end
30
- end
31
- spec.bindir = "exe"
32
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
- spec.require_paths = ["lib"]
34
-
35
- spec.add_dependency "orthoses", "~> 1.3.0"
36
- spec.add_dependency "yard"
37
- end
@@ -1,31 +0,0 @@
1
- # GENERATED FILE
2
-
3
- class Orthoses::YARD::YARD2RBS
4
- # @return [YARD::CodeObjects::t]
5
- attr_reader yardoc: untyped
6
- # @return [Proc]
7
- attr_reader block: Proc
8
- # @return [RBS::Types::Bases::Any]
9
- attr_reader untyped: RBS::Types::Bases::Any
10
- # @return [RBS::Types::Bases::Void]
11
- attr_reader void: RBS::Types::Bases::Void
12
- # @return [RBS::Types::Bases::Bool]
13
- attr_reader bool: RBS::Types::Bases::Bool
14
- def initialize: (yardoc: untyped, block: untyped) -> void
15
- # @return [void]
16
- def run: () -> void
17
- # @return [void]
18
- def generate_for_attributes: () -> void
19
- # @return [void]
20
- def generate_for_methods: () -> void
21
- # @return [void]
22
- def generate_for_constants: () -> void
23
- # @return [RBS::Types::t]
24
- def tag_types_to_rbs_type: (untyped tag_types) -> untyped
25
- # @return [RBS::Types::t]
26
- def wrap: (untyped types) -> untyped
27
- # @return [Array<RBS::Types::t>]
28
- def recursive_resolve: (untyped types_explainer_types) -> untyped
29
- # @return [Array<RBS::Types::Bases::Any>]
30
- def temporary_type_params: (untyped name) -> Array[RBS::Types::Bases::Any]
31
- end
@@ -1,6 +0,0 @@
1
- # GENERATED FILE
2
-
3
- class Orthoses::YARD
4
- def initialize: (untyped loader, parse: untyped) -> void
5
- VERSION: untyped
6
- end
data/sig_patch/yard.rbs DELETED
@@ -1,38 +0,0 @@
1
- module YARD
2
- module Registry
3
- end
4
-
5
- module Tags
6
- module TypesExplainer
7
- class Parser
8
- end
9
-
10
- class Type
11
- end
12
-
13
- class CollectionType < Type
14
- end
15
-
16
- class FixedCollectionType < CollectionType
17
- end
18
-
19
- class HashCollectionType < Type
20
- end
21
- end
22
- end
23
-
24
- module CodeObjects
25
- type t = ModuleObject | ClassObject | MethodObject
26
- class Base
27
- def attributes: () -> { class: Hash[Symbol, untyped], instance: Hash[Symbol, untyped] }
28
- end
29
- class NamespaceObject < Base
30
- end
31
- class ModuleObject < NamespaceObject
32
- end
33
- class ClassObject < NamespaceObject
34
- end
35
- class MethodObject < Base
36
- end
37
- end
38
- end