Skip to content

Commit 61a6b3e

Browse files
authored
Fix SmartProperties docs to show module structure (#2331)
### Motivation <!-- Explain why you are making this change. Include links to issues or describe the problem being solved, not the solution. --> The `SmartProperties` compiler generates methods inside a `SmartPropertiesGeneratedMethods` module that gets included in the class, but the documentation example showed methods directly on the class. This updates the docs to match the actual implementation, consistent with how other compilers like `ActiveRecordColumns` work. ### Implementation <!-- How did you implement your changes? Explain your solution, design decisions, things reviewers should watch out for. --> Updated the doc to reflect the actual module structure. ### Tests <!-- We hope you added tests as part of your changes, just state that you have. If you haven't, state why. --> No tests were added as this is a documentation-only change
2 parents 6833758 + d67caf5 commit 61a6b3e

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

lib/tapioca/dsl/compilers/smart_properties.rb

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,33 @@ module Compilers
2929
# # post.rbi
3030
# # typed: true
3131
# class Post
32-
# sig { returns(T.nilable(::String)) }
33-
# def title; end
32+
# include SmartPropertiesGeneratedMethods
3433
#
35-
# sig { params(title: T.nilable(::String)).returns(T.nilable(::String)) }
36-
# def title=(title); end
34+
# module SmartPropertiesGeneratedMethods
35+
# sig { returns(T.nilable(::String)) }
36+
# def title; end
3737
#
38-
# sig { returns(::String) }
39-
# def description; end
38+
# sig { params(title: T.nilable(::String)).returns(T.nilable(::String)) }
39+
# def title=(title); end
4040
#
41-
# sig { params(description: ::String).returns(::String) }
42-
# def description=(description); end
41+
# sig { returns(::String) }
42+
# def description; end
4343
#
44-
# sig { returns(T.nilable(T::Boolean)) }
45-
# def published?; end
44+
# sig { params(description: ::String).returns(::String) }
45+
# def description=(description); end
4646
#
47-
# sig { params(published: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
48-
# def published=(published); end
47+
# sig { returns(T.nilable(T::Boolean)) }
48+
# def published?; end
4949
#
50-
# sig { returns(T.nilable(T::Boolean)) }
51-
# def enabled; end
50+
# sig { params(published: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
51+
# def published=(published); end
5252
#
53-
# sig { params(enabled: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
54-
# def enabled=(enabled); end
53+
# sig { returns(T.nilable(T::Boolean)) }
54+
# def enabled; end
55+
#
56+
# sig { params(enabled: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
57+
# def enabled=(enabled); end
58+
# end
5559
# end
5660
# ~~~
5761
#: [ConstantType = singleton(::SmartProperties)]

manual/compiler_smartproperties.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,33 @@ this compiler will produce the RBI file `post.rbi` with the following content:
2323
# post.rbi
2424
# typed: true
2525
class Post
26-
sig { returns(T.nilable(::String)) }
27-
def title; end
26+
include SmartPropertiesGeneratedMethods
2827

29-
sig { params(title: T.nilable(::String)).returns(T.nilable(::String)) }
30-
def title=(title); end
28+
module SmartPropertiesGeneratedMethods
29+
sig { returns(T.nilable(::String)) }
30+
def title; end
3131

32-
sig { returns(::String) }
33-
def description; end
32+
sig { params(title: T.nilable(::String)).returns(T.nilable(::String)) }
33+
def title=(title); end
3434

35-
sig { params(description: ::String).returns(::String) }
36-
def description=(description); end
35+
sig { returns(::String) }
36+
def description; end
3737

38-
sig { returns(T.nilable(T::Boolean)) }
39-
def published?; end
38+
sig { params(description: ::String).returns(::String) }
39+
def description=(description); end
4040

41-
sig { params(published: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
42-
def published=(published); end
41+
sig { returns(T.nilable(T::Boolean)) }
42+
def published?; end
4343

44-
sig { returns(T.nilable(T::Boolean)) }
45-
def enabled; end
44+
sig { params(published: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
45+
def published=(published); end
4646

47-
sig { params(enabled: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
48-
def enabled=(enabled); end
47+
sig { returns(T.nilable(T::Boolean)) }
48+
def enabled; end
49+
50+
sig { params(enabled: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
51+
def enabled=(enabled); end
52+
end
4953
end
5054
~~~
5155
: [ConstantType = singleton(::SmartProperties)]

0 commit comments

Comments
 (0)