Skip to content

Commit f6cf182

Browse files
committed
📚 Update IMAP#search docs again
Now that rdoc 6.8 renders properly on small screens, the IMAP#search docs needed to be updated. Nested unordered lists indent too deeply for small screens. Also, the search rdoc reads better when the details of argument translation are moved from the main text into its own subsection. Also, the search key reference has been reorganized around key type. Also, the heading levels were all adjusted to `h4` and `h5`. This assumes that the method heading is an `h3` heading. Unfortunately, the method headings use a `<div>`, but they _should_ be `h3` headings. 😉
1 parent 89d6c04 commit f6cf182

File tree

1 file changed

+144
-125
lines changed

1 file changed

+144
-125
lines changed

lib/net/imap.rb

Lines changed: 144 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,28 +1940,8 @@ def uid_expunge(uid_set)
19401940
#
19411941
# +criteria+ is one or more search keys and their arguments, which may be
19421942
# provided as an array or a string.
1943-
# See {"Search criteria"}[rdoc-ref:#search@Search+criteria], below.
1944-
#
1945-
# * When +criteria+ is an array, each member is a +SEARCH+ command argument:
1946-
# * Any SequenceSet sends SequenceSet#valid_string.
1947-
# These types are converted to SequenceSet for validation and encoding:
1948-
# * +Set+
1949-
# * +Range+
1950-
# * <tt>-1</tt> and +:*+ -- both translate to <tt>*</tt>
1951-
# * responds to +#to_sequence_set+
1952-
# * +Array+, when each element is one of the above types, a positive
1953-
# +Integer+, a sequence-set formatted +String+, or a deeply nested
1954-
# +Array+ of these same types.
1955-
# * Any +String+ is sent verbatim when it is a valid \IMAP atom,
1956-
# and encoded as an \IMAP quoted or literal string otherwise.
1957-
# * Any other nested +Array+ is encoded as a parenthesized list, to group
1958-
# multiple search keys (e.g., for use with +OR+ and +NOT+).
1959-
# * Any other +Integer+ (besides <tt>-1</tt>) will be sent as +#to_s+.
1960-
# * +Date+ objects will be encoded as an \IMAP date (see ::encode_date).
1961-
#
1962-
# * When +criteria+ is a string, it will be sent directly to the server
1963-
# <em>without any validation or encoding</em>. *WARNING:* This is
1964-
# vulnerable to injection attacks when external inputs are used.
1943+
# See {"Argument translation"}[rdoc-ref:#search@Argument+translation]
1944+
# and {"Search criteria"}[rdoc-ref:#search@Search+criteria], below.
19651945
#
19661946
# +charset+ is the name of the {registered character
19671947
# set}[https://www.iana.org/assignments/character-sets/character-sets.xhtml]
@@ -1972,7 +1952,7 @@ def uid_expunge(uid_set)
19721952
#
19731953
# Related: #uid_search
19741954
#
1975-
# ===== For example:
1955+
# ==== For example:
19761956
#
19771957
# p imap.search(["SUBJECT", "hello", "NOT", "SEEN"])
19781958
# #=> [1, 6, 7, 8]
@@ -1988,7 +1968,45 @@ def uid_expunge(uid_set)
19881968
# # criteria string contains charset arg
19891969
# imap.search("CHARSET UTF-8 OR UNSEEN (FLAGGED SUBJECT foo)")
19901970
#
1991-
# ===== Search keys
1971+
# ==== Argument translation
1972+
#
1973+
# [When +criteria+ is an Array]
1974+
# Each member is a +SEARCH+ command argument:
1975+
# [SequenceSet]
1976+
# Encoded as an \IMAP +sequence-set+ with SequenceSet#valid_string.
1977+
# [Set, Range, <tt>-1</tt>, +:*+, responds to +#to_sequence_set+]
1978+
# Converted to SequenceSet for validation and encoding.
1979+
# [nested sequence-set +Array+]
1980+
# When every element in a nested array is one of the above types, a
1981+
# positive +Integer+, a sequence-set formatted +String+, or a deeply
1982+
# nested +Array+ of these same types, the array will be converted to
1983+
# SequenceSet for validation and encoding.
1984+
# [Any other nested +Array+]
1985+
# Otherwise, a nested array is encoded as a parenthesized list, to
1986+
# combine multiple search keys (e.g., for use with +OR+ and +NOT+).
1987+
# [+String+]
1988+
# Sent verbatim when it is a valid \IMAP +atom+, and encoded as an \IMAP
1989+
# +quoted+ or +literal+ string otherwise. Every standard search key
1990+
# name is a valid \IMAP +atom+ and every standard search key string
1991+
# argument is an +astring+ which may be encoded as +atom+, +quoted+, or
1992+
# +literal+.
1993+
#
1994+
# *Note:* <tt>*</tt> is not a valid \IMAP +atom+ character. Any string
1995+
# containing <tt>*</tt> will be encoded as a +quoted+ string, _not_ a
1996+
# +sequence-set+.
1997+
# [+Integer+ (except for <tt>-1</tt>)]
1998+
# Encoded using +#to_s+.
1999+
# [+Date+]
2000+
# Encoded as an \IMAP date (see ::encode_date).
2001+
#
2002+
# [When +criteria+ is a String]
2003+
# +criteria+ will be sent directly to the server <em>without any
2004+
# validation or encoding</em>.
2005+
#
2006+
# <em>*WARNING:* This is vulnerable to injection attacks when external
2007+
# inputs are used.</em>
2008+
#
2009+
# ==== Search keys
19922010
#
19932011
# For full definitions of the standard search +criteria+,
19942012
# see [{IMAP4rev1 §6.4.4}[https://www.rfc-editor.org/rfc/rfc3501.html#section-6.4.4]],
@@ -2003,145 +2021,161 @@ def uid_expunge(uid_set)
20032021
# arguments. The number and type of arguments is specific to each search
20042022
# key.
20052023
#
2006-
# +ALL+::
2007-
# Matches every message in the mailbox.
2024+
# ===== Search keys that match all messages
20082025
#
2009-
# (_search-key_ _search-key_...)::
2010-
# Combines one or more _search-key_ arguments to match
2011-
# messages which match all contained search keys. Useful for +OR+, +NOT+,
2012-
# and other search keys with _search-key_ arguments.
2026+
# [+ALL+]
2027+
# The default initial key. Matches every message in the mailbox.
20132028
#
2014-
# _Note:_ this search key has no label.
2029+
# [+SAVEDATESUPPORTED+]
2030+
# Matches every message in the mailbox when the mailbox supports the save
2031+
# date attribute. Otherwise, it matches no messages.
20152032
#
2016-
# +OR+ _search-key_ _search-key_::
2017-
# Matches messages which match either _search-key_ argument.
2033+
# <em>Requires +SAVEDATE+ capability</em>.
2034+
# {[RFC8514]}[https://www.rfc-editor.org/rfc/rfc8514.html#section-4.3]
20182035
#
2019-
# +NOT+ _search-key_::
2020-
# Matches messages which do not match _search-key_.
2036+
# ===== Sequence set search keys
20212037
#
2022-
# _sequence-set_::
2038+
# [_sequence-set_]
20232039
# Matches messages with message sequence numbers in _sequence-set_.
20242040
#
20252041
# _Note:_ this search key has no label.
20262042
#
20272043
# <em>+UIDONLY+ must *not* be enabled.</em>
20282044
# {[RFC9586]}[https://www.rfc-editor.org/rfc/rfc9586.html]
20292045
#
2030-
# +UID+ _sequence-set_::
2046+
# [+UID+ _sequence-set_]
20312047
# Matches messages with a UID in _sequence-set_.
20322048
#
2033-
# +ANSWERED+::
2034-
# +UNANSWERED+::
2049+
# ===== Compound search keys
2050+
#
2051+
# [(_search-key_ _search-key_...)]
2052+
# Combines one or more _search-key_ arguments to match
2053+
# messages which match all contained search keys. Useful for +OR+, +NOT+,
2054+
# and other search keys with _search-key_ arguments.
2055+
#
2056+
# _Note:_ this search key has no label.
2057+
#
2058+
# [+OR+ _search-key_ _search-key_]
2059+
# Matches messages which match either _search-key_ argument.
2060+
#
2061+
# [+NOT+ _search-key_]
2062+
# Matches messages which do not match _search-key_.
2063+
#
2064+
# [+FUZZY+ _search-key_]
2065+
# Uses fuzzy matching for the specified search key.
2066+
#
2067+
# <em>Requires <tt>SEARCH=FUZZY</tt> capability.</em>
2068+
# {[RFC6203]}[https://www.rfc-editor.org/rfc/rfc6203.html#section-6].
2069+
#
2070+
# ===== Flags search keys
2071+
#
2072+
# [+ANSWERED+, +UNANSWERED+]
20352073
# Matches messages with or without the <tt>\\Answered</tt> flag.
2036-
# +DELETED+::
2037-
# +UNDELETED+::
2074+
# [+DELETED+, +UNDELETED+]
20382075
# Matches messages with or without the <tt>\\Deleted</tt> flag.
2039-
# +DRAFT+::
2040-
# +UNDRAFT+::
2076+
# [+DRAFT+, +UNDRAFT+]
20412077
# Matches messages with or without the <tt>\\Draft</tt> flag.
2042-
# +FLAGGED+::
2043-
# +UNFLAGGED+::
2078+
# [+FLAGGED+, +UNFLAGGED+]
20442079
# Matches messages with or without the <tt>\\Flagged</tt> flag.
2045-
# +SEEN+::
2046-
# +UNSEEN+::
2080+
# [+SEEN+, +UNSEEN+]
20472081
# Matches messages with or without the <tt>\\Seen</tt> flag.
2048-
#
2049-
# +KEYWORD+ _keyword_::
2050-
# +UNKEYWORD+ _keyword_::
2082+
# [+KEYWORD+ _keyword_, +UNKEYWORD+ _keyword_]
20512083
# Matches messages with or without the specified _keyword_.
20522084
#
2053-
# +BCC+ _substring_::
2054-
# Matches when _substring_ is in the envelope's BCC field.
2055-
# +CC+ _substring_::
2056-
# Matches when _substring_ is in the envelope's CC field.
2057-
# +FROM+ _substring_::
2058-
# Matches when _substring_ is in the envelope's FROM field.
2059-
# +SUBJECT+ _substring_::
2060-
# Matches when _substring_ is in the envelope's SUBJECT field.
2061-
# +TO+ _substring_::
2062-
# Matches when _substring_ is in the envelope's TO field.
2063-
#
2064-
# +HEADER+ _field_ _substring_::
2085+
# [+RECENT+, +UNRECENT+]
2086+
# Matches messages with or without the <tt>\\Recent</tt> flag.
2087+
#
2088+
# *NOTE:* The <tt>\\Recent</tt> flag has been removed from +IMAP4rev2+.
2089+
# [+NEW+]
2090+
# Equivalent to <tt>(RECENT UNSEEN)</tt>.
2091+
#
2092+
# *NOTE:* The <tt>\\Recent</tt> flag has been removed from +IMAP4rev2+.
2093+
#
2094+
# ===== Header field substring search keys
2095+
#
2096+
# [+BCC+ _substring_]
2097+
# Matches when _substring_ is in the envelope's +BCC+ field.
2098+
# [+CC+ _substring_]
2099+
# Matches when _substring_ is in the envelope's +CC+ field.
2100+
# [+FROM+ _substring_]
2101+
# Matches when _substring_ is in the envelope's +FROM+ field.
2102+
# [+SUBJECT+ _substring_]
2103+
# Matches when _substring_ is in the envelope's +SUBJECT+ field.
2104+
# [+TO+ _substring_]
2105+
# Matches when _substring_ is in the envelope's +TO+ field.
2106+
#
2107+
# [+HEADER+ _field_ _substring_]
20652108
# Matches when _substring_ is in the specified header _field_.
20662109
#
2067-
# +BODY+ _string_::
2110+
# ===== Body text search keys
2111+
# [+BODY+ _string_]
20682112
# Matches when _string_ is in the body of the message.
20692113
# Does not match on header fields.
20702114
#
20712115
# The server _may_ use flexible matching, rather than simple substring
20722116
# matches. For example, this may use stemming or match only full words.
20732117
#
2074-
# +TEXT+ _string_::
2118+
# [+TEXT+ _string_]
20752119
# Matches when _string_ is in the header or body of the message.
20762120
#
20772121
# The server _may_ use flexible matching, rather than simple substring
20782122
# matches. For example, this may use stemming or match only full words.
20792123
#
2080-
# +BEFORE+ _date_::
2081-
# +ON+ _date_::
2082-
# +SINCE+ _date_::
2083-
# Matches when the +INTERNALDATE+ is earlier than, on, or later than
2084-
# _date_.
2124+
# ===== Date/Time search keys
20852125
#
2086-
# +SENTBEFORE+ _date_::
2087-
# +SENTON+ _date_::
2088-
# +SENTSINCE+ _date_::
2126+
# [+SENTBEFORE+ _date_]
2127+
# [+SENTON+ _date_]
2128+
# [+SENTSINCE+ _date_]
20892129
# Matches when the +Date+ header is earlier than, on, or later than _date_.
20902130
#
2091-
# +SMALLER+ _bytes_::
2092-
# +LARGER+ _bytes_::
2093-
# Matches when +RFC822.SIZE+ is smaller/larger than _bytes_.
2094-
#
2095-
# ====== Removed from +IMAP4rev2+
2096-
#
2097-
# The <tt>\\Recent</tt> flag has been removed from +IMAP4rev2+. So these
2098-
# search keys require the +IMAP4rev1+ capability.
2131+
# [+BEFORE+ _date_]
2132+
# [+ON+ _date_]
2133+
# [+SINCE+ _date_]
2134+
# Matches when the +INTERNALDATE+ is earlier than, on, or later than
2135+
# _date_.
20992136
#
2100-
# +RECENT+::
2101-
# +UNRECENT+::
2102-
# Matches messages with or without the <tt>\\Recent</tt> flag.
2137+
# [+OLDER+ _interval_]
2138+
# [+YOUNGER+ _interval_]
2139+
# Matches when the +INTERNALDATE+ is more/less than _interval_ seconds ago.
21032140
#
2104-
# +NEW+::
2105-
# Equivalent to <tt>(RECENT UNSEEN)</tt>.
2141+
# <em>Requires +WITHIN+ capability</em>.
2142+
# {[RFC5032]}[https://www.rfc-editor.org/rfc/rfc5032.html]
21062143
#
2107-
# ====== Extension search keys
2144+
# [+SAVEDBEFORE+ _date_]
2145+
# [+SAVEDON+ _date_]
2146+
# [+SAVEDSINCE+ _date_]
2147+
# Matches when the save date is earlier than, on, or later than _date_.
21082148
#
2109-
# The search keys described below are defined by standard \IMAP extensions.
2149+
# <em>Requires +SAVEDATE+ capability.</em>
2150+
# {[RFC8514]}[https://www.rfc-editor.org/rfc/rfc8514.html#section-4.3]
21102151
#
2111-
# +OLDER+ _interval_::
2112-
# +YOUNGER+ _interval_::
2113-
# Matches when +INTERNALDATE+ is more/less than _interval_ seconds ago.
2152+
# ===== Other message attribute search keys
21142153
#
2115-
# <em>Requires the +WITHIN+ capability</em>.
2116-
# {[RFC5032]}[https://www.rfc-editor.org/rfc/rfc5032.html]
2154+
# [+SMALLER+ _bytes_]
2155+
# [+LARGER+ _bytes_]
2156+
# Matches when +RFC822.SIZE+ is smaller or larger than _bytes_.
21172157
#
2118-
# +ANNOTATION+ _entry_ _attr_ _value_::
2158+
# [+ANNOTATION+ _entry_ _attr_ _value_]
21192159
# Matches messages that have annotations with entries matching _entry_,
21202160
# attributes matching _attr_, and _value_ in the attribute's values.
21212161
#
2122-
# <em>Requires the +ANNOTATE-EXPERIMENT-1+ capability</em>.
2162+
# <em>Requires +ANNOTATE-EXPERIMENT-1+ capability</em>.
21232163
# {[RFC5257]}[https://www.rfc-editor.org/rfc/rfc5257.html].
21242164
#
2125-
# +FILTER+ _filter_::
2165+
# [+FILTER+ _filter_]
21262166
# References a _filter_ that is stored on the server and matches all
21272167
# messages which would be matched by that filter's search criteria.
21282168
#
2129-
# <em>Requires the +FILTERS+ capability</em>.
2169+
# <em>Requires +FILTERS+ capability</em>.
21302170
# {[RFC5466]}[https://www.rfc-editor.org/rfc/rfc5466.html#section-3.1]
21312171
#
2132-
# +FUZZY+ _search-key_::
2133-
# Uses fuzzy matching for the specified search key.
2134-
#
2135-
# <em>Requires the <tt>SEARCH=FUZZY</tt> capability.</em>
2136-
# {[RFC6203]}[https://www.rfc-editor.org/rfc/rfc6203.html#section-6].
2137-
#
2138-
# +MODSEQ+ _modseq_::
2172+
# [+MODSEQ+ _modseq_]
21392173
# Matches when +MODSEQ+ is greater than or equal to _modseq_.
21402174
#
2141-
# <em>Requires the +CONDSTORE+ capability</em>.
2175+
# <em>Requires +CONDSTORE+ capability</em>.
21422176
# {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1.5].
21432177
#
2144-
# +MODSEQ+ _entry_ _entry-type_ _modseq_::
2178+
# [+MODSEQ+ _entry_ _entry-type_ _modseq_]
21452179
# Matches when a specific metadata _entry_ has been updated since
21462180
# _modseq_.
21472181
#
@@ -2150,33 +2184,18 @@ def uid_expunge(uid_set)
21502184
# <tt>\\</tt> prefix. _entry-type_ can be one of <tt>"shared"</tt>,
21512185
# <tt>"priv"</tt> (private), or <tt>"all"</tt>.
21522186
#
2153-
# <em>Requires the +CONDSTORE+ capability</em>.
2187+
# <em>Requires +CONDSTORE+ capability</em>.
21542188
# {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1.5].
21552189
#
2156-
# +EMAILID+ _objectid_::
2157-
# +THREADID+ _objectid_::
2190+
# [+EMAILID+ _objectid_]
2191+
# [+THREADID+ _objectid_]
21582192
# Matches when +EMAILID+/+THREADID+ is equal to _objectid_
21592193
# (substring matches are not supported).
21602194
#
2161-
# <em>Requires the +OBJECTID+ capability</em>.
2195+
# <em>Requires +OBJECTID+ capability</em>.
21622196
# {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html#section-6]
21632197
#
2164-
# +SAVEDATESUPPORTED+::
2165-
# Matches every message in the mailbox when the mailbox supports the save
2166-
# date attribute. Otherwise, it matches no messages.
2167-
#
2168-
# <em>Requires the +SAVEDATE+ capability</em>.
2169-
# {[RFC8514]}[https://www.rfc-editor.org/rfc/rfc8514.html#section-4.3]
2170-
#
2171-
# +SAVEDBEFORE+ _date_::
2172-
# +SAVEDON+ _date_::
2173-
# +SAVEDSINCE+ _date_::
2174-
# Matches when the save date is earlier than, on, or later than _date_.
2175-
#
2176-
# <em>Requires the +SAVEDATE+ capability.</em>
2177-
# {[RFC8514]}[https://www.rfc-editor.org/rfc/rfc8514.html#section-4.3]
2178-
#
2179-
# ===== Capabilities
2198+
# ==== Capabilities
21802199
#
21812200
# If CONDSTORE[https://www.rfc-editor.org/rfc/rfc7162.html] is supported
21822201
# and enabled for the selected mailbox, a non-empty SearchResult will

0 commit comments

Comments
 (0)