yard-sorbet 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yard-sorbet.rb +1 -3
- data/lib/yard-sorbet/handlers/abstract_dsl_handler.rb +1 -1
- data/lib/yard-sorbet/handlers/enums_handler.rb +1 -1
- data/lib/yard-sorbet/handlers/sig_handler.rb +5 -3
- data/lib/yard-sorbet/handlers/struct_handler.rb +8 -8
- data/lib/yard-sorbet/handlers/struct_handler.rbi +5 -0
- data/lib/yard-sorbet/node_utils.rb +1 -0
- data/lib/yard-sorbet/sig_to_yard.rb +1 -1
- data/lib/yard-sorbet/version.rb +2 -1
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca3c823cd78ea11784724185ff336604d2e7b131082945c3fc19200d1b3294cf
|
4
|
+
data.tar.gz: 43b2a6a38cb3161d2452eaa823ac336cbb5dcb0782fb40d0b5ddbf12afe33467
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aff435511b0e40b212c3ffcfd8194cec04a70d9e05ce82865dbbf074376cc6da7d9503a71f395aafde9615c99f524051977d9c6b9aaac971ee1c8f378ab4aa5f
|
7
|
+
data.tar.gz: 746934d64c6bfd728551b43b380cf6efd3da0ccbb9224cbb29bbabe065d17821530e640c3a8377e5935a05d1f9527d51f36da995c21dd0c5821903b86482017f
|
data/lib/yard-sorbet.rb
CHANGED
@@ -4,11 +4,9 @@
|
|
4
4
|
require 'sorbet-runtime'
|
5
5
|
require 'yard'
|
6
6
|
|
7
|
-
|
8
|
-
module YARDSorbet; end
|
7
|
+
require_relative 'yard-sorbet/version'
|
9
8
|
|
10
9
|
require_relative 'yard-sorbet/directives'
|
11
10
|
require_relative 'yard-sorbet/handlers'
|
12
11
|
require_relative 'yard-sorbet/node_utils'
|
13
12
|
require_relative 'yard-sorbet/sig_to_yard'
|
14
|
-
require_relative 'yard-sorbet/version'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Apllies an
|
4
|
+
# Apllies an `@abstract` tag to `abstract!`/`interface!` modules (if not alerady present).
|
5
5
|
class YARDSorbet::Handlers::AbstractDSLHandler < YARD::Handlers::Ruby::Base
|
6
6
|
extend T::Sig
|
7
7
|
|
@@ -15,15 +15,17 @@ class YARDSorbet::Handlers::SigHandler < YARD::Handlers::Ruby::Base
|
|
15
15
|
prop :return, T.nilable(T::Array[String])
|
16
16
|
end
|
17
17
|
|
18
|
+
# These node types attached to sigs represent attr_* declarations
|
19
|
+
ATTR_NODE_TYPES = T.let(%i[command fcall], T::Array[Symbol])
|
18
20
|
# Skip these node types when parsing `sig` params
|
19
21
|
PARAM_EXCLUDES = T.let(%i[array call hash].freeze, T::Array[Symbol])
|
20
22
|
# Skip these node types when parsing `sig`s
|
21
23
|
SIG_EXCLUDES = T.let(%i[array hash].freeze, T::Array[Symbol])
|
22
24
|
|
23
|
-
private_constant :ParsedSig, :PARAM_EXCLUDES, :SIG_EXCLUDES
|
25
|
+
private_constant :ParsedSig, :ATTR_NODE_TYPES, :PARAM_EXCLUDES, :SIG_EXCLUDES
|
24
26
|
|
25
27
|
# Swap the method definition docstring and the sig docstring.
|
26
|
-
# Parse relevant parts of the
|
28
|
+
# Parse relevant parts of the `sig` and include them as well.
|
27
29
|
sig { void }
|
28
30
|
def process
|
29
31
|
method_node = YARDSorbet::NodeUtils.get_method_node(YARDSorbet::NodeUtils.sibling_node(statement))
|
@@ -31,7 +33,7 @@ class YARDSorbet::Handlers::SigHandler < YARD::Handlers::Ruby::Base
|
|
31
33
|
parsed_sig = parse_sig(statement)
|
32
34
|
enhance_tag(docstring, :abstract, parsed_sig)
|
33
35
|
enhance_tag(docstring, :return, parsed_sig)
|
34
|
-
|
36
|
+
unless ATTR_NODE_TYPES.include?(method_node.type)
|
35
37
|
parsed_sig.params.each do |name, types|
|
36
38
|
enhance_param(docstring, name, types)
|
37
39
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Handles all
|
4
|
+
# Handles all `const`/`prop` calls, creating accessor methods, and compiles them for later usage at the class level
|
5
5
|
# in creating a constructor
|
6
6
|
class YARDSorbet::Handlers::StructHandler < YARD::Handlers::Ruby::Base
|
7
7
|
extend T::Sig
|
@@ -39,7 +39,8 @@ class YARDSorbet::Handlers::StructHandler < YARD::Handlers::Ruby::Base
|
|
39
39
|
object = MethodObject.new(namespace, name, scope)
|
40
40
|
object.source = source
|
41
41
|
|
42
|
-
|
42
|
+
# TODO: this should use `+` to delimit the attribute name when markdown is disabled
|
43
|
+
reader_docstring = doc.empty? ? "Returns the value of attribute `#{name}`." : doc
|
43
44
|
docstring = YARD::DocstringParser.new.parse(reader_docstring).to_docstring
|
44
45
|
docstring.add_tag(YARD::Tags::Tag.new(:return, '', types))
|
45
46
|
object.docstring = docstring.to_raw
|
@@ -53,14 +54,13 @@ class YARDSorbet::Handlers::StructHandler < YARD::Handlers::Ruby::Base
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
|
-
# Class-level handler that folds all
|
57
|
+
# Class-level handler that folds all `const` and `prop` declarations into the constructor documentation
|
57
58
|
# this needs to be injected as a module otherwise the default Class handler will overwrite documentation
|
58
|
-
|
59
|
-
|
59
|
+
#
|
60
|
+
# @note this module is included in `YARD::Handlers::Ruby::ClassHandler`
|
61
|
+
module YARDSorbet::Handlers::StructClassHandler
|
60
62
|
extend T::Sig
|
61
63
|
|
62
|
-
requires_ancestor YARD::Handlers::Ruby::ClassHandler
|
63
|
-
|
64
64
|
sig { void }
|
65
65
|
def process
|
66
66
|
super
|
@@ -106,4 +106,4 @@ module YARDSorbet::StructClassHandler
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
YARD::Handlers::Ruby::ClassHandler.include YARDSorbet::StructClassHandler
|
109
|
+
YARD::Handlers::Ruby::ClassHandler.include YARDSorbet::Handlers::StructClassHandler
|
data/lib/yard-sorbet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-sorbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Douglas Eichelberger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler-audit
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: redcarpet
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.5'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +86,14 @@ dependencies:
|
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
89
|
+
version: 1.16.0
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
96
|
+
version: 1.16.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rubocop-performance
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +184,14 @@ dependencies:
|
|
170
184
|
requirements:
|
171
185
|
- - ">="
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.5.
|
187
|
+
version: 0.5.5845
|
174
188
|
type: :runtime
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
192
|
- - ">="
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.5.
|
194
|
+
version: 0.5.5845
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: yard
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,6 +222,7 @@ files:
|
|
208
222
|
- lib/yard-sorbet/handlers/enums_handler.rb
|
209
223
|
- lib/yard-sorbet/handlers/sig_handler.rb
|
210
224
|
- lib/yard-sorbet/handlers/struct_handler.rb
|
225
|
+
- lib/yard-sorbet/handlers/struct_handler.rbi
|
211
226
|
- lib/yard-sorbet/node_utils.rb
|
212
227
|
- lib/yard-sorbet/sig_to_yard.rb
|
213
228
|
- lib/yard-sorbet/version.rb
|