Skip to content

Commit 05d64a0

Browse files
committed
📚 Update rdoc for Config and related updates
1 parent 5f12016 commit 05d64a0

File tree

5 files changed

+68
-33
lines changed

5 files changed

+68
-33
lines changed

lib/net/imap.rb

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,8 @@ class << self
767767

768768
# The client configuration. See Net::IMAP::Config.
769769
#
770-
# By default, config inherits from the global Net::IMAP.config.
770+
# By default, the client's local configuration inherits from the global
771+
# Net::IMAP.config.
771772
attr_reader :config
772773

773774
# Seconds to wait until a connection is opened.
@@ -818,18 +819,20 @@ def idle_response_timeout; config.idle_response_timeout end
818819
# SSLContext[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html].
819820
#
820821
# [config]
821-
# A Net::IMAP::Config object to base the client #config on. By default
822-
# the global Net::IMAP.config is used. Note that this sets the _parent_
823-
# config object for inheritance. Every Net::IMAP client has its own
824-
# unique #config for overrides.
822+
# A Net::IMAP::Config object to use as the basis for #config. By default,
823+
# the global Net::IMAP.config is used.
825824
#
826-
# Any other keyword arguments will be forwarded to Config.new, to create the
827-
# client's #config. For example:
825+
# >>>
826+
# *NOTE:* +config+ does not set #config directly---it sets the _parent_
827+
# config for inheritance. Every client creates its own unique #config.
828828
#
829-
# [open_timeout]
830-
# Seconds to wait until a connection is opened
831-
# [idle_response_timeout]
832-
# Seconds to wait until an IDLE response is received
829+
# All other keyword arguments are forwarded to Net::IMAP::Config.new, to
830+
# initialize the client's #config. For example:
831+
#
832+
# [{open_timeout}[rdoc-ref:Config#open_timeout]]
833+
# Seconds to wait until a connection is opened
834+
# [{idle_response_timeout}[rdoc-ref:Config#idle_response_timeout]]
835+
# Seconds to wait until an IDLE response is received
833836
#
834837
# See DeprecatedClientOptions.new for deprecated arguments.
835838
#
@@ -1221,7 +1224,8 @@ def starttls(**options)
12211224
# +mechanism+ is the name of the \SASL authentication mechanism to be used.
12221225
#
12231226
# +sasl_ir+ allows or disallows sending an "initial response" (see the
1224-
# +SASL-IR+ capability, below).
1227+
# +SASL-IR+ capability, below). Defaults to the #config value for
1228+
# {sasl_ir}[rdoc-ref:Config#sasl_ir], which defaults to +true+.
12251229
#
12261230
# All other arguments are forwarded to the registered SASL authenticator for
12271231
# the requested mechanism. <em>The documentation for each individual
@@ -2421,7 +2425,8 @@ def enable(*capabilities)
24212425
#
24222426
# Returns the server's response to indicate the IDLE state has ended.
24232427
# Returns +nil+ if the server does not respond to #idle_done within
2424-
# idle_response_timeout seconds.
2428+
# {config.idle_response_timeout}[rdoc-ref:Config#idle_response_timeout]
2429+
# seconds.
24252430
#
24262431
# Related: #idle_done, #noop, #check
24272432
#
@@ -2460,8 +2465,9 @@ def idle(timeout = nil, &response_handler)
24602465

24612466
# Leaves IDLE, allowing #idle to return.
24622467
#
2463-
# If the server does not respond within idle_response_timeout, #idle will
2464-
# return +nil+.
2468+
# If the server does not respond within
2469+
# {config.idle_response_timeout}[rdoc-ref:Config#idle_response_timeout]
2470+
# seconds, #idle will return +nil+.
24652471
#
24662472
# Related: #idle
24672473
def idle_done

lib/net/imap/config.rb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Config
6363
# The default config, which is hardcoded and frozen.
6464
def self.default; @default end
6565

66-
# The global config object.
66+
# The global config object. Also available from Net::IMAP.config.
6767
def self.global; @global end
6868

6969
def self.[](config) # :nodoc: unfinished API
@@ -93,20 +93,27 @@ def self.[](config) # :nodoc: unfinished API
9393
# Seconds to wait until a connection is opened.
9494
#
9595
# If the IMAP object cannot open a connection within this time,
96-
# it raises a Net::OpenTimeout exception. See Net::IMAP.new.
96+
# it raises a Net::OpenTimeout exception.
97+
#
98+
# See Net::IMAP.new.
9799
#
98100
# The default value is +30+ seconds.
99101
attr_accessor :open_timeout, type: Integer
100102

101103
# Seconds to wait until an IDLE response is received, after
102-
# the client asks to leave the IDLE state. See Net::IMAP#idle_done.
104+
# the client asks to leave the IDLE state.
105+
#
106+
# See Net::IMAP#idle and Net::IMAP#idle_done.
103107
#
104108
# The default value is +5+ seconds.
105109
attr_accessor :idle_response_timeout, type: Integer
106110

107111
# :markup: markdown
108112
#
109-
# Whether to use the +SASL-IR+ extension with IMAP#authenticate.
113+
# Whether to use the +SASL-IR+ extension when the server and \SASL
114+
# mechanism both support it.
115+
#
116+
# See Net::IMAP#authenticate.
110117
#
111118
# | Starting with version | The default value is |
112119
# |-----------------------|------------------------------------------|
@@ -120,11 +127,11 @@ def self.[](config) # :nodoc: unfinished API
120127
# block. Valid options are `:warn`, `:raise`, or
121128
# `:silence_deprecation_warning`.
122129
#
123-
# | Starting with version | The default value is |
124-
# |-----------------------|--------------------------------|
125-
# | v0.4.13 | +:silence_deprecation_warning+ |
126-
# | v0.5 | +:warn+ |
127-
# | _eventually_ | +:raise+ |
130+
# | Starting with version | The default value is |
131+
# |-------------------------|--------------------------------|
132+
# | v0.4.13 | +:silence_deprecation_warning+ |
133+
# | v0.5 <em>(planned)</em> | +:warn+ |
134+
# | _eventually_ | +:raise+ |
128135
attr_accessor :responses_without_block, type: [
129136
:silence_deprecation_warning, :warn, :raise,
130137
]

lib/net/imap/config/attr_accessors.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
module Net
66
class IMAP
77
class Config
8-
9-
# Config values are stored in a struct rather than ivars to simplify:
10-
# * ensuring that all config objects share a single object shape
11-
# * querying only locally configured values, e.g for inspection.
8+
# >>>
9+
# *NOTE:* This module is an internal implementation detail, with no
10+
# guarantee of backward compatibility.
11+
#
12+
# +attr_accessor+ values are stored in a struct rather than ivars, making
13+
# it simpler to ensure that all config objects share a single object
14+
# shape. This also simplifies iteration over all defined attributes.
1215
module AttrAccessors
1316
module Macros # :nodoc: internal API
1417
def attr_accessor(name) AttrAccessors.attr_accessor(name) end

lib/net/imap/config/attr_inheritance.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,25 @@
33
module Net
44
class IMAP
55
class Config
6-
# Inheritance forms a singly-linked-list, so lookup will be O(n) on the
7-
# number of ancestors. Without customization, ancestor trees will only be
8-
# three or four deep:
9-
# client -> [versioned ->] global -> default
6+
# >>>
7+
# *NOTE:* The public methods on this module are part of the stable
8+
# public API of Net::IMAP::Config. But the module itself is an internal
9+
# implementation detail, with no guarantee of backward compatibility.
10+
#
11+
# +attr_accessor+ methods will delegate to their #parent when the local
12+
# value does not contain an override. Inheritance forms a singly linked
13+
# list, so lookup will be <tt>O(n)</tt> on the number of ancestors. In
14+
# practice, the ancestor chain is not expected to be long. Without
15+
# customization, it is only three deep:
16+
# >>>
17+
# IMAP#config → Config.global → Config.default
18+
#
19+
# When creating a client with the +config+ keyword, for example to use
20+
# the appropriate defaults for an application or a library while still
21+
# relying on global for configuration of +debug+ or +logger+, most likely
22+
# the ancestor chain is still only four deep:
23+
# >>>
24+
# IMAP#config → alternate defaults → Config.global → Config.default
1025
module AttrInheritance
1126
INHERITED = Module.new.freeze
1227
private_constant :INHERITED

lib/net/imap/config/attr_type_coercion.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
module Net
44
class IMAP
55
class Config
6-
# Adds a +type+ keyword parameter to +attr_accessor+, which enforces
6+
# >>>
7+
# *NOTE:* This module is an internal implementation detail, with no
8+
# guarantee of backward compatibility.
9+
#
10+
# Adds a +type+ keyword parameter to +attr_accessor+, to enforce that
711
# config attributes have valid types, for example: boolean, numeric,
812
# enumeration, non-nullable, etc.
913
module AttrTypeCoercion

0 commit comments

Comments
 (0)