Skip to content

Commit 6bf8e2c

Browse files
authored
YARD documentation improvements (#179)
- Add proper YARD type annotations to all public API methods - Change Fixnum → Integer (Fixnum is deprecated in modern Ruby) - s/prescedence/precedence - Add [void] return type annotations where appropriate - Fix documentation for update_trigger (was "trigger to drop", should be "trigger to update") - Improve consistency of documentation format across adapters, configuration, and statements
1 parent 06c44ef commit 6bf8e2c

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ changelog, see the [commits] for each version via the version links.
1919
- Ensure multi-schema dumping in Rails 8.1.0 does not dump the same objects for
2020
all schemas (#177)
2121
- Drop Rails 7.1 due to EOL (#176)
22+
- YARD documentation improvements (#179)
2223

2324
## [0.9.0]
2425

lib/fx/adapters/postgres.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def triggers
6565
# This is typically called in a migration via
6666
# {Fx::Statements::Function#create_function}.
6767
#
68-
# @param sql_definition The SQL schema for the function.
68+
# @param sql_definition [String] The SQL schema for the function.
6969
#
7070
# @return [void]
7171
def create_function(sql_definition)
@@ -77,7 +77,7 @@ def create_function(sql_definition)
7777
# This is typically called in a migration via
7878
# {Fx::Statements::Trigger#create_trigger}.
7979
#
80-
# @param sql_definition The SQL schema for the trigger.
80+
# @param sql_definition [String] The SQL schema for the trigger.
8181
#
8282
# @return [void]
8383
def create_trigger(sql_definition)
@@ -89,8 +89,8 @@ def create_trigger(sql_definition)
8989
# This is typically called in a migration via
9090
# {Fx::Statements::Function#update_function}.
9191
#
92-
# @param name The name of the function.
93-
# @param sql_definition The SQL schema for the function.
92+
# @param name [String, Symbol] The name of the function.
93+
# @param sql_definition [String] The SQL schema for the function.
9494
#
9595
# @return [void]
9696
def update_function(name, sql_definition)
@@ -106,9 +106,9 @@ def update_function(name, sql_definition)
106106
# This is typically called in a migration via
107107
# {Fx::Statements::Function#update_trigger}.
108108
#
109-
# @param name The name of the trigger.
110-
# @param on The associated table for the trigger to drop
111-
# @param sql_definition The SQL schema for the function.
109+
# @param name [String, Symbol] The name of the trigger.
110+
# @param on [String, Symbol] The associated table for the trigger to update
111+
# @param sql_definition [String] The SQL schema for the trigger.
112112
#
113113
# @return [void]
114114
def update_trigger(name, on:, sql_definition:)
@@ -121,7 +121,7 @@ def update_trigger(name, on:, sql_definition:)
121121
# This is typically called in a migration via
122122
# {Fx::Statements::Function#drop_function}.
123123
#
124-
# @param name The name of the function to drop
124+
# @param name [String, Symbol] The name of the function to drop
125125
#
126126
# @return [void]
127127
def drop_function(name)
@@ -137,8 +137,8 @@ def drop_function(name)
137137
# This is typically called in a migration via
138138
# {Fx::Statements::Trigger#drop_trigger}.
139139
#
140-
# @param name The name of the trigger to drop
141-
# @param on The associated table for the trigger to drop
140+
# @param name [String, Symbol] The name of the trigger to drop
141+
# @param on [String, Symbol] The associated table for the trigger to drop
142142
#
143143
# @return [void]
144144
def drop_trigger(name, on:)

lib/fx/configuration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ class Configuration
44
# The F(x) database adapter instance to use when executing SQL.
55
#
66
# Defaults to an instance of {Fx::Adapters::Postgres}
7-
# @return Fx adapter
7+
# @return [Fx::Adapters::Postgres] Fx adapter
88
attr_accessor :database
99

1010
# Prioritizes the order in the schema.rb of functions before other
1111
# statements in order to make directly schema load work when using functions
1212
# in statements below, i.e.: default column values.
1313
#
1414
# Defaults to false
15-
# @return Boolean
15+
# @return [Boolean] Boolean
1616
attr_accessor :dump_functions_at_beginning_of_schema
1717

1818
def initialize

lib/fx/statements.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ module Statements
44
# Create a new database function.
55
#
66
# @param name [String, Symbol] The name of the database function.
7-
# @param version [Fixnum] The version number of the function, used to
7+
# @param version [Integer] The version number of the function, used to
88
# find the definition file in `db/functions`. This defaults to `1` if
99
# not provided.
1010
# @param sql_definition [String] The SQL query for the function schema.
1111
# If both `sql_definition` and `version` are provided,
12-
# `sql_definition` takes prescedence.
13-
# @return The database response from executing the create statement.
12+
# `sql_definition` takes precedence.
13+
# @return [void] The database response from executing the create statement.
1414
#
1515
# @example Create from `db/functions/uppercase_users_name_v02.sql`
1616
# create_function(:uppercase_users_name, version: 2)
@@ -45,10 +45,10 @@ def create_function(name, options = {})
4545
# Drop a database function by name.
4646
#
4747
# @param name [String, Symbol] The name of the database function.
48-
# @param revert_to_version [Fixnum] Used to reverse the `drop_function`
48+
# @param revert_to_version [Integer] Used to reverse the `drop_function`
4949
# command on `rake db:rollback`. The provided version will be passed as
5050
# the `version` argument to {#create_function}.
51-
# @return The database response from executing the drop statement.
51+
# @return [void] The database response from executing the drop statement.
5252
#
5353
# @example Drop a function, rolling back to version 2 on rollback
5454
# drop_function(:uppercase_users_name, revert_to_version: 2)
@@ -60,13 +60,13 @@ def drop_function(name, options = {})
6060
# Update a database function.
6161
#
6262
# @param name [String, Symbol] The name of the database function.
63-
# @param version [Fixnum] The version number of the function, used to
63+
# @param version [Integer] The version number of the function, used to
6464
# find the definition file in `db/functions`. This defaults to `1` if
6565
# not provided.
6666
# @param sql_definition [String] The SQL query for the function schema.
6767
# If both `sql_definition` and `version` are provided,
68-
# `sql_definition` takes prescedence.
69-
# @return The database response from executing the create statement.
68+
# `sql_definition` takes precedence.
69+
# @return [void] The database response from executing the create statement.
7070
#
7171
# @example Update function to a given version
7272
# update_function(
@@ -106,13 +106,13 @@ def update_function(name, options = {})
106106
# Create a new database trigger.
107107
#
108108
# @param name [String, Symbol] The name of the database trigger.
109-
# @param version [Fixnum] The version number of the trigger, used to
109+
# @param version [Integer] The version number of the trigger, used to
110110
# find the definition file in `db/triggers`. This defaults to `1` if
111111
# not provided.
112112
# @param sql_definition [String] The SQL query for the function. An error
113113
# will be raised if `sql_definition` and `version` are both set,
114114
# as they are mutually exclusive.
115-
# @return The database response from executing the create statement.
115+
# @return [void] The database response from executing the create statement.
116116
#
117117
# @example Create trigger from `db/triggers/uppercase_users_name_v01.sql`
118118
# create_trigger(:uppercase_users_name, version: 1)
@@ -152,10 +152,10 @@ def create_trigger(name, options = {})
152152
# @param name [String, Symbol] The name of the database trigger.
153153
# @param on [String, Symbol] The name of the table the database trigger
154154
# is associated with.
155-
# @param revert_to_version [Fixnum] Used to reverse the `drop_trigger`
155+
# @param revert_to_version [Integer] Used to reverse the `drop_trigger`
156156
# command on `rake db:rollback`. The provided version will be passed as
157157
# the `version` argument to {#create_trigger}.
158-
# @return The database response from executing the drop statement.
158+
# @return [void] The database response from executing the drop statement.
159159
#
160160
# @example Drop a trigger, rolling back to version 3 on rollback
161161
# drop_trigger(:log_inserts, on: :users, revert_to_version: 3)
@@ -171,15 +171,15 @@ def drop_trigger(name, options = {})
171171
# and `version` parameter.
172172
#
173173
# @param name [String, Symbol] The name of the database trigger.
174-
# @param version [Fixnum] The version number of the trigger.
174+
# @param version [Integer] The version number of the trigger.
175175
# @param on [String, Symbol] The name of the table the database trigger
176176
# is associated with.
177177
# @param sql_definition [String] The SQL query for the function. An error
178178
# will be raised if `sql_definition` and `version` are both set,
179179
# as they are mutually exclusive.
180-
# @param revert_to_version [Fixnum] The version number to rollback to on
180+
# @param revert_to_version [Integer] The version number to rollback to on
181181
# `rake db rollback`
182-
# @return The database response from executing the create statement.
182+
# @return [void] The database response from executing the create statement.
183183
#
184184
# @example Update trigger to a given version
185185
# update_trigger(

0 commit comments

Comments
 (0)