Skip to content

Commit 1247932

Browse files
authored
Merge pull request rails#50360 from skipkayhil/hm-docs-deprecations
Improve Deprecation API docs and guide [ci-skip]
2 parents a7f1d63 + f93eb16 commit 1247932

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

activesupport/lib/active_support/deprecation/behaviors.rb

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ class Deprecation
5757
# You can create a custom behavior or set any from the +DEFAULT_BEHAVIORS+
5858
# constant. Available behaviors are:
5959
#
60-
# [+raise+] Raise ActiveSupport::DeprecationException.
61-
# [+stderr+] Log all deprecation warnings to <tt>$stderr</tt>.
62-
# [+log+] Log all deprecation warnings to +Rails.logger+.
63-
# [+notify+] Use ActiveSupport::Notifications to notify +deprecation.rails+.
64-
# [+report+] Use ActiveSupport::ErrorReporter to report deprecations.
65-
# [+silence+] Do nothing. On \Rails, set <tt>config.active_support.report_deprecations = false</tt> to disable all behaviors.
60+
# [+:raise+] Raise ActiveSupport::DeprecationException.
61+
# [+:stderr+] Log all deprecation warnings to <tt>$stderr</tt>.
62+
# [+:log+] Log all deprecation warnings to +Rails.logger+.
63+
# [+:notify+] Use ActiveSupport::Notifications to notify +deprecation.rails+.
64+
# [+:report+] Use ActiveSupport::ErrorReporter to report deprecations.
65+
# [+:silence+] Do nothing. On \Rails, set <tt>config.active_support.report_deprecations = false</tt> to disable all behaviors.
6666
#
6767
# Setting behaviors only affects deprecations that happen after boot time.
68-
# For more information you can read the documentation of the +behavior=+ method.
68+
# For more information you can read the documentation of the #behavior= method.
6969
module Behavior
7070
# Whether to print a backtrace along with the warning.
7171
attr_accessor :debug
@@ -85,12 +85,12 @@ def disallowed_behavior
8585
#
8686
# Available behaviors:
8787
#
88-
# [+raise+] Raise ActiveSupport::DeprecationException.
89-
# [+stderr+] Log all deprecation warnings to <tt>$stderr</tt>.
90-
# [+log+] Log all deprecation warnings to +Rails.logger+.
91-
# [+notify+] Use ActiveSupport::Notifications to notify +deprecation.rails+.
92-
# [+report+] Use ActiveSupport::ErrorReporter to report deprecations.
93-
# [+silence+] Do nothing.
88+
# [+:raise+] Raise ActiveSupport::DeprecationException.
89+
# [+:stderr+] Log all deprecation warnings to <tt>$stderr</tt>.
90+
# [+:log+] Log all deprecation warnings to +Rails.logger+.
91+
# [+:notify+] Use ActiveSupport::Notifications to notify +deprecation.rails+.
92+
# [+:report+] Use ActiveSupport::ErrorReporter to report deprecations.
93+
# [+:silence+] Do nothing.
9494
#
9595
# Setting behaviors only affects deprecations that happen after boot time.
9696
# Deprecation warnings raised by gems are not affected by this setting
@@ -104,15 +104,17 @@ def disallowed_behavior
104104
# # custom stuff
105105
# }
106106
#
107-
# If you are using \Rails, you can set <tt>config.active_support.report_deprecations = false</tt> to disable
108-
# all deprecation behaviors. This is similar to the +silence+ option but more performant.
107+
# If you are using \Rails, you can set
108+
# <tt>config.active_support.report_deprecations = false</tt> to disable
109+
# all deprecation behaviors. This is similar to the +:silence+ option but
110+
# more performant.
109111
def behavior=(behavior)
110112
@behavior = Array(behavior).map { |b| DEFAULT_BEHAVIORS[b] || arity_coerce(b) }
111113
end
112114

113115
# Sets the behavior for disallowed deprecations (those configured by
114116
# ActiveSupport::Deprecation#disallowed_warnings=) to the specified
115-
# value. As with +behavior=+, this can be a single value, array, or an
117+
# value. As with #behavior=, this can be a single value, array, or an
116118
# object that responds to +call+.
117119
def disallowed_behavior=(behavior)
118120
@disallowed_behavior = Array(behavior).map { |b| DEFAULT_BEHAVIORS[b] || arity_coerce(b) }

guides/source/configuring.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,15 +2544,25 @@ The default value depends on the `config.load_defaults` target version:
25442544

25452545
#### `config.active_support.deprecation`
25462546

2547-
Configures the behavior of deprecation warnings. The options are `:raise`, `:stderr`, `:log`, `:notify`, and `:silence`.
2547+
Configures the behavior of deprecation warnings. See
2548+
[`Deprecation::Behavior`][deprecation_behavior] for a description of the
2549+
available options.
25482550

2549-
In the default generated `config/environments` files, this is set to `:log` for development and `:stderr` for test, and it is omitted for production in favor of [`config.active_support.report_deprecations`](#config-active-support-report-deprecations).
2551+
In the default generated `config/environments` files, this is set to `:log` for
2552+
development and `:stderr` for test, and it is omitted for production in favor of
2553+
[`config.active_support.report_deprecations`](#config-active-support-report-deprecations).
2554+
2555+
[deprecation_behavior]: https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html#method-i-behavior-3D
25502556

25512557
#### `config.active_support.disallowed_deprecation`
25522558

2553-
Configures the behavior of disallowed deprecation warnings. The options are `:raise`, `:stderr`, `:log`, `:notify`, and `:silence`.
2559+
Configures the behavior of disallowed deprecation warnings. See
2560+
[`Deprecation::Behavior`][deprecation_behavior] for a description of the
2561+
available options.
25542562

2555-
In the default generated `config/environments` files, this is set to `:raise` for both development and test, and it is omitted for production in favor of [`config.active_support.report_deprecations`](#config-active-support-report-deprecations).
2563+
In the default generated `config/environments` files, this is set to `:raise`
2564+
for both development and test, and it is omitted for production in favor of
2565+
[`config.active_support.report_deprecations`](#config-active-support-report-deprecations).
25562566

25572567
#### `config.active_support.disallowed_deprecation_warnings`
25582568

0 commit comments

Comments
 (0)