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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 360c73bcd93390b21ebf0206cce339822368fca005d03fa3d08a4444a3cab367
4
- data.tar.gz: 7b03b59846235fd395bca99868561eaa299b7dbe21eea7c91307c602236baec9
3
+ metadata.gz: ca3c823cd78ea11784724185ff336604d2e7b131082945c3fc19200d1b3294cf
4
+ data.tar.gz: 43b2a6a38cb3161d2452eaa823ac336cbb5dcb0782fb40d0b5ddbf12afe33467
5
5
  SHA512:
6
- metadata.gz: 364ee6ff02687a3a4e2ffd3384c2eb68a848afe60ad0e94c8d675df81ae9a820e805ed07ce1537cee59eb3e979ce2488a1a2210aa19cc1b40365b9dc97368864
7
- data.tar.gz: f26eb01fcad908815f27afc9a42ad72050625e5279e3b3b7576991aa1b14ba685148c12d74bbc2cdba19e69b1f416f48fa89253d34a5635259794d088ad7415f
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
- # top-level namespace
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 +@abstract+ tag to +abstract!+/+interface!+ modules (if not alerady present).
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
 
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- # Handle +enums+ calls, registering enum values as constants
4
+ # Handle `enums` calls, registering enum values as constants
5
5
  class YARDSorbet::Handlers::EnumsHandler < 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 +sig+ and include them as well.
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
- if method_node.type != :command
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 +const+/+prop+ calls, creating accessor methods, and compiles them for later usage at the class level
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
- reader_docstring = doc.empty? ? "Returns the value of attribute +#{name}+." : doc
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 +const+ and +prop+ declarations into the constructor documentation
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
- module YARDSorbet::StructClassHandler
59
- extend T::Helpers
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
@@ -0,0 +1,5 @@
1
+ # typed: strict
2
+ # This is in an rbi so the runtime doesn't depend on experimental sorbet features
3
+ module YARDSorbet::Handlers::StructClassHandler
4
+ requires_ancestor YARD::Handlers::Ruby::ClassHandler
5
+ end
@@ -14,6 +14,7 @@ module YARDSorbet::NodeUtils
14
14
 
15
15
  private_constant :ATTRIBUTE_METHODS, :SIGABLE_NODE
16
16
 
17
+ # Traverese AST nodes in breadth-first order
17
18
  # @yield [YARD::Parser::Ruby::AstNode]
18
19
  sig do
19
20
  params(
@@ -1,7 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- # Translate +sig+ type syntax to +YARD+ type syntax.
4
+ # Translate `sig` type syntax to `YARD` type syntax.
5
5
  module YARDSorbet::SigToYARD
6
6
  extend T::Sig
7
7
 
@@ -1,7 +1,8 @@
1
1
  # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
+ # Types are documentation
4
5
  module YARDSorbet
5
6
  # {https://rubygems.org/gems/yard-sorbet Version history}
6
- VERSION = '0.5.0'
7
+ VERSION = '0.5.1'
7
8
  end
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.0
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-05-28 00:00:00.000000000 Z
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.15.0
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.15.0
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.6289
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.6289
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