rails-annotate-solargraph 0.2.0 → 0.2.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f1d0f284eac106e51e1abc19eec0d7b8790aab9ee188e1cabea5defb04417da
|
4
|
+
data.tar.gz: 392519ce6da6313e8a3308dee6f54b66629ee108120b8abcb94e1d838dc86470
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e25ae122d969be4f5d4081638592e3db7d6ab46adf60cdaf82057953441576d842bc2db79af664371637e332b25c5fee091fe930e53ffd88f97d78a04533c9
|
7
|
+
data.tar.gz: 43d0752100b231426877a84665ba8030d5121b8f0d7b07549f2312c7e30cb7f1c0f9c9807b99bc085394fd369cb81a95ec63c15366e92a9eb96116fdb91b8fee
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.3] - 2022-04-16
|
4
|
+
|
5
|
+
- A nicer fix for the previous problem
|
6
|
+
|
7
|
+
## [0.2.2] - 2022-04-16
|
8
|
+
|
9
|
+
- Inexistent class loading error has been resolved
|
10
|
+
|
11
|
+
## [0.2.1] - 2022-04-16
|
12
|
+
|
13
|
+
- Rakefile template refactoring and bug fix
|
14
|
+
|
3
15
|
## [0.2.0] - 2022-04-16
|
4
16
|
|
5
17
|
- Associations get fully documented
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
include ::Rails::Annotate::Solargraph::TerminalColors
|
4
|
-
|
5
3
|
if ::Rails.env.development?
|
6
4
|
namespace :annotate do
|
7
5
|
namespace :solargraph do
|
8
6
|
desc "Add YARD comments documenting the models' schemas"
|
9
7
|
task generate: :environment do
|
10
|
-
|
8
|
+
::Rails::Annotate::Solargraph.generate
|
11
9
|
end
|
12
10
|
|
13
11
|
desc "Remove YARD comments documenting the models' schemas"
|
14
12
|
task remove: :environment do
|
15
|
-
|
13
|
+
::Rails::Annotate::Solargraph.remove
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
@@ -25,8 +23,4 @@ if ::Rails.env.development?
|
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
28
|
-
|
29
|
-
def system!(val)
|
30
|
-
system(val) || abort(error_string("Command `#{val}` failed"))
|
31
|
-
end
|
32
26
|
end
|
@@ -147,17 +147,25 @@ module Rails
|
|
147
147
|
# @param reflection [ActiveRecord::Reflection::AbstractReflection]
|
148
148
|
# @return [void]
|
149
149
|
def document_relation(doc_string, attr_name, reflection)
|
150
|
+
reflection_class = begin
|
151
|
+
reflection.klass
|
152
|
+
rescue ::NameError
|
153
|
+
Object
|
154
|
+
end
|
155
|
+
|
156
|
+
associated_table_name = reflection_class.try(:table_name) || '<unknown>'
|
157
|
+
foreign_key = reflection.try(:foreign_key) || '<unknown>'
|
150
158
|
db_description = \
|
151
159
|
case reflection
|
152
160
|
when ::ActiveRecord::Reflection::BelongsToReflection
|
153
|
-
type_docstring =
|
154
|
-
"`belongs_to` relation with `#{
|
161
|
+
type_docstring = reflection_class
|
162
|
+
"`belongs_to` relation with `#{reflection_class}`. Database column `#{@klass.table_name}.#{foreign_key}`."
|
155
163
|
when ::ActiveRecord::Reflection::HasOneReflection
|
156
|
-
type_docstring =
|
157
|
-
"`has_one` relation with `#{
|
164
|
+
type_docstring = reflection_class
|
165
|
+
"`has_one` relation with `#{reflection_class}`. Database column `#{associated_table_name}.#{foreign_key}`."
|
158
166
|
when ::ActiveRecord::Reflection::HasManyReflection
|
159
|
-
type_docstring = "Array<#{
|
160
|
-
"`has_many` relation with `#{
|
167
|
+
type_docstring = "Array<#{reflection_class}>"
|
168
|
+
"`has_many` relation with `#{reflection_class}`. Database column `#{associated_table_name}.#{foreign_key}`."
|
161
169
|
end
|
162
170
|
|
163
171
|
doc_string << <<~DOC
|