Skip to content

Commit 864b797

Browse files
committed
📚 Update Net::IMAP docs, formatting and more...
* Escape some text that shouldn't be linked, e.g. IMAP. * Link some text that should be linked: * removing "+" to let classes link * Remove `Net::IMAP::` prefix from response data class names. The redundant prefix breaks up the reading flow of the text. Examples will still use fully-qualified names, and readers should generally be able to see that the classes/modules are in Net::IMAP, from context. * Add headings and convert text to headings. * Reduce headings inside method docs to h5 (call-seq renders like h4). * Add <tt> or "+" to code or verbatim text. * To match the tweaks to rdoc's darkfish template, convert definition lists to "note" vs "label" style lists for table vs lists. * Add ">>>" with <em> to highlight important "aside" notices. * Add :nodoc: to ResponseErrors.
1 parent c89b2ab commit 864b797

File tree

1 file changed

+69
-52
lines changed

1 file changed

+69
-52
lines changed

lib/net/imap.rb

Lines changed: 69 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323

2424
module Net
2525

26-
#
27-
# Net::IMAP implements Internet Message Access Protocol (IMAP) client
26+
# Net::IMAP implements Internet Message Access Protocol (\IMAP) client
2827
# functionality. The protocol is described in
29-
# [IMAP[https://tools.ietf.org/html/rfc3501]].
28+
# [IMAP4rev1[https://tools.ietf.org/html/rfc3501]].
29+
#--
30+
# TODO: and [IMAP4rev2[https://tools.ietf.org/html/rfc9051]].
31+
#++
3032
#
31-
# == IMAP Overview
33+
# == \IMAP Overview
3234
#
3335
# An \IMAP client connects to a server, and then authenticates
3436
# itself using either #authenticate or #login. Having
@@ -41,12 +43,14 @@ module Net
4143
# within a hierarchy of directories.
4244
#
4345
# To work on the messages within a mailbox, the client must
44-
# first select that mailbox, using either #select or (for
45-
# read-only access) #examine. Once the client has successfully
46-
# selected a mailbox, they enter _selected_ state, and that
46+
# first select that mailbox, using either #select or #examine
47+
# (for read-only access). Once the client has successfully
48+
# selected a mailbox, they enter the "_selected_" state, and that
4749
# mailbox becomes the _current_ mailbox, on which mail-item
4850
# related commands implicitly operate.
4951
#
52+
# === Sequence numbers and UIDs
53+
#
5054
# Messages have two sorts of identifiers: message sequence
5155
# numbers and UIDs.
5256
#
@@ -62,7 +66,7 @@ module Net
6266
# the existing message is deleted. UIDs are required to
6367
# be assigned in ascending (but not necessarily sequential)
6468
# order within a mailbox; this means that if a non-IMAP client
65-
# rearranges the order of mailitems within a mailbox, the
69+
# rearranges the order of mail items within a mailbox, the
6670
# UIDs have to be reassigned. An \IMAP client thus cannot
6771
# rearrange message orders.
6872
#
@@ -108,15 +112,15 @@ module Net
108112
#
109113
# == Errors
110114
#
111-
# An IMAP server can send three different types of responses to indicate
115+
# An \IMAP server can send three different types of responses to indicate
112116
# failure:
113117
#
114118
# NO:: the attempted command could not be successfully completed. For
115119
# instance, the username/password used for logging in are incorrect;
116120
# the selected mailbox does not exist; etc.
117121
#
118122
# BAD:: the request from the client does not follow the server's
119-
# understanding of the IMAP protocol. This includes attempting
123+
# understanding of the \IMAP protocol. This includes attempting
120124
# commands from the wrong client state; for instance, attempting
121125
# to perform a SEARCH command without having SELECTed a current
122126
# mailbox. It can also signal an internal server
@@ -340,10 +344,12 @@ class IMAP < Protocol
340344
include SSL
341345
end
342346

343-
# Returns an initial greeting response from the server.
347+
# Returns the initial greeting the server, an UntaggedResponse.
344348
attr_reader :greeting
345349

346-
# Returns recorded untagged responses. For example:
350+
# Returns recorded untagged responses.
351+
#
352+
# For example:
347353
#
348354
# imap.select("inbox")
349355
# p imap.responses["EXISTS"][-1]
@@ -421,14 +427,17 @@ def disconnected?
421427

422428
# Sends a CAPABILITY command, and returns an array of
423429
# capabilities that the server supports. Each capability
424-
# is a string. See [IMAP] for a list of possible
425-
# capabilities.
426-
#
427-
# Note that the Net::IMAP class does not modify its
428-
# behaviour according to the capabilities of the server;
429-
# it is up to the user of the class to ensure that
430-
# a certain capability is supported by a server before
431-
# using it.
430+
# is a string.
431+
# See the {IANA IMAP capabilities registry}[https://www.iana.org/assignments/imap-capabilities/imap-capabilities.xhtml]
432+
# for a list of possible capabilities and their RFCs.
433+
#
434+
# >>>
435+
# <em>*Note* that the Net::IMAP class does not modify its
436+
# behaviour according to the capabilities of the server;
437+
# it is up to the user of the class to ensure that
438+
# a certain capability is supported by a server before
439+
# using it.</em>
440+
#
432441
def capability
433442
synchronize do
434443
send_command("CAPABILITY")
@@ -492,10 +501,10 @@ def starttls(options = {}, verify = true)
492501
# supports the following mechanisms:
493502
#
494503
# PLAIN:: Login using cleartext user and password. Secure with TLS.
495-
# See Net::IMAP::PlainAuthenticator.
504+
# See PlainAuthenticator.
496505
# CRAM-MD5:: DEPRECATED: Use PLAIN (or DIGEST-MD5) with TLS.
497506
# DIGEST-MD5:: DEPRECATED by RFC6331. Must be secured using TLS.
498-
# See Net::IMAP::DigestMD5Authenticator.
507+
# See DigestMD5Authenticator.
499508
# LOGIN:: DEPRECATED: Use PLAIN.
500509
#
501510
# Most mechanisms require two args: authentication identity (e.g. username)
@@ -518,7 +527,7 @@ def starttls(options = {}, verify = true)
518527
#
519528
# A Net::IMAP::NoResponseError is raised if authentication fails.
520529
#
521-
# See +Net::IMAP::Authenticators+ for more information on plugging in your
530+
# See Net::IMAP::Authenticators for more information on plugging in your
522531
# own authenticator.
523532
def authenticate(auth_type, *args)
524533
authenticator = self.class.authenticator(auth_type, *args)
@@ -555,7 +564,7 @@ def login(user, password)
555564
# A Net::IMAP::NoResponseError is raised if the mailbox does not
556565
# exist or is for some reason non-selectable.
557566
#
558-
# ==== Capabilities
567+
# ===== Capabilities
559568
#
560569
# If [UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]] is supported,
561570
# the server may return an untagged "NO" response with a "UIDNOTSTICKY"
@@ -644,7 +653,7 @@ def unsubscribe(mailbox)
644653
# which mailboxes to match. If +mailbox+ is empty, the root
645654
# name of +refname+ and the hierarchy delimiter are returned.
646655
#
647-
# The return value is an array of +Net::IMAP::MailboxList+. For example:
656+
# The return value is an array of MailboxList. For example:
648657
#
649658
# imap.create("foo/bar")
650659
# imap.create("foo/baz")
@@ -688,9 +697,9 @@ def list(refname, mailbox)
688697
# create the mailbox in.
689698
#
690699
# The user of this method should first check if the server supports the
691-
# NAMESPACE capability. The return value is a +Net::IMAP::Namespaces+
700+
# NAMESPACE #capability. The return value is a Namespaces
692701
# object which has +personal+, +other+, and +shared+ fields, each an array
693-
# of +Net::IMAP::Namespace+ objects. These arrays will be empty when the
702+
# of Namespace objects. These arrays will be empty when the
694703
# server responds with nil.
695704
#
696705
# For example:
@@ -733,7 +742,7 @@ def namespace
733742
# The XLIST command is like the LIST command except that the flags
734743
# returned refer to the function of the folder/mailbox, e.g. :Sent
735744
#
736-
# The return value is an array of +Net::IMAP::MailboxList+. For example:
745+
# The return value is an array of MailboxList objects. For example:
737746
#
738747
# imap.create("foo/bar")
739748
# imap.create("foo/baz")
@@ -751,7 +760,7 @@ def xlist(refname, mailbox)
751760
# Sends the GETQUOTAROOT command along with the specified +mailbox+.
752761
# This command is generally available to both admin and user.
753762
# If this mailbox exists, it returns an array containing objects of type
754-
# Net::IMAP::MailboxQuotaRoot and Net::IMAP::MailboxQuota.
763+
# MailboxQuotaRoot and MailboxQuota.
755764
#
756765
# The QUOTA extension is described in [QUOTA[https://tools.ietf.org/html/rfc2087]]
757766
def getquotaroot(mailbox)
@@ -766,7 +775,7 @@ def getquotaroot(mailbox)
766775

767776
# Sends the GETQUOTA command along with specified +mailbox+.
768777
# If this mailbox exists, then an array containing a
769-
# Net::IMAP::MailboxQuota object is returned. This
778+
# MailboxQuota object is returned. This
770779
# command is generally only available to server admin.
771780
#
772781
# The QUOTA extension is described in [QUOTA[https://tools.ietf.org/html/rfc2087]]
@@ -807,7 +816,7 @@ def setacl(mailbox, user, rights)
807816

808817
# Send the GETACL command along with a specified +mailbox+.
809818
# If this mailbox exists, an array containing objects of
810-
# Net::IMAP::MailboxACLItem will be returned.
819+
# MailboxACLItem will be returned.
811820
#
812821
# The ACL extension is described in [ACL[https://tools.ietf.org/html/rfc4314]]
813822
def getacl(mailbox)
@@ -822,7 +831,7 @@ def getacl(mailbox)
822831
# "subscribed." +refname+ and +mailbox+ are interpreted as
823832
# for #list.
824833
#
825-
# The return value is an array of +Net::IMAP::MailboxList+.
834+
# The return value is an array of MailboxList objects.
826835
def lsub(refname, mailbox)
827836
synchronize do
828837
send_command("LSUB", refname, mailbox)
@@ -858,6 +867,7 @@ def status(mailbox, attr)
858867
# flags initially passed to the new message. The optional
859868
# +date_time+ argument specifies the creation time to assign to the
860869
# new message; it defaults to the current time.
870+
#
861871
# For example:
862872
#
863873
# imap.append("inbox", <<EOF.gsub(/\n/, "\r\n"), [:Seen], Time.now)
@@ -872,7 +882,7 @@ def status(mailbox, attr)
872882
# not exist (it is not created automatically), or if the flags,
873883
# date_time, or message arguments contain errors.
874884
#
875-
# ==== Capabilities
885+
# ===== Capabilities
876886
#
877887
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
878888
# supported, the server's response should include a +APPENDUID+ response
@@ -932,22 +942,24 @@ def expunge
932942

933943
# Similar to #expunge, but takes a set of unique identifiers as
934944
# argument. Sends a UID EXPUNGE command to permanently remove all
935-
# messages that have both the \\Deleted flag set and a UID that is
945+
# messages that have both the <tt>\\Deleted</tt> flag set and a UID that is
936946
# included in +uid_set+.
937947
#
938948
# By using UID EXPUNGE instead of EXPUNGE when resynchronizing with
939949
# the server, the client can ensure that it does not inadvertantly
940-
# remove any messages that have been marked as \\Deleted by other
950+
# remove any messages that have been marked as <tt>\\Deleted</tt> by other
941951
# clients between the time that the client was last connected and
942952
# the time the client resynchronizes.
943953
#
944-
# Note:: Although the command takes a +uid_set+ for its argument, the
954+
# *Note:*
955+
# >>>
956+
# Although the command takes a +uid_set+ for its argument, the
945957
# server still returns regular EXPUNGE responses, which contain
946958
# a <em>sequence number</em>. These will be deleted from
947959
# #responses and this method returns them as an array of
948960
# <em>sequence number</em> integers.
949961
#
950-
# ==== Capability requirement
962+
# ===== Capability requirement
951963
#
952964
# +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] must be
953965
# supported by the server.
@@ -962,12 +974,17 @@ def uid_expunge(uid_set)
962974
# match the given searching criteria, and returns message sequence
963975
# numbers. +keys+ can either be a string holding the entire
964976
# search string, or a single-dimension array of search keywords and
965-
# arguments. The following are some common search criteria;
966-
# see [IMAP] section 6.4.4 for a full list.
977+
# arguments.
978+
#
979+
# ===== Search criteria
980+
#
981+
# The following are some common search criteria;
982+
# see [{IMAP4rev1 §6.4.4}[https://www.rfc-editor.org/rfc/rfc3501.html#section-6.4.4]]
983+
# for a full list:
967984
#
968-
# <message set>:: a set of message sequence numbers. ',' indicates
969-
# an interval, ':' indicates a range. For instance,
970-
# '2,10:12,15' means "2,10,11,12,15".
985+
# <message set>:: a set of message sequence numbers. "<tt>,</tt>" indicates
986+
# an interval, "+:+" indicates a range. For instance,
987+
# "<tt>2,10:12,15</tt>" means "<tt>2,10,11,12,15</tt>".
971988
#
972989
# BEFORE <date>:: messages with an internal date strictly before
973990
# <date>. The date argument has a format similar
@@ -994,10 +1011,11 @@ def uid_expunge(uid_set)
9941011
#
9951012
# TO <string>:: messages with <string> in their TO field.
9961013
#
997-
# For example:
1014+
# ===== For example:
9981015
#
9991016
# p imap.search(["SUBJECT", "hello", "NOT", "NEW"])
10001017
# #=> [1, 6, 7, 8]
1018+
#
10011019
def search(keys, charset = nil)
10021020
return search_internal("SEARCH", keys, charset)
10031021
end
@@ -1020,9 +1038,9 @@ def uid_search(keys, charset = nil)
10201038
# equivalent to 1..5.
10211039
#
10221040
# +attr+ is a list of attributes to fetch; see the documentation
1023-
# for Net::IMAP::FetchData for a list of valid attributes.
1041+
# for FetchData for a list of valid attributes.
10241042
#
1025-
# The return value is an array of Net::IMAP::FetchData or nil
1043+
# The return value is an array of FetchData or nil
10261044
# (instead of an empty array) if there is no matching message.
10271045
#
10281046
# For example:
@@ -1059,7 +1077,7 @@ def uid_fetch(set, attr, mod = nil)
10591077
# with the provided one, '+FLAGS' will add the provided flags,
10601078
# and '-FLAGS' will remove them. +flags+ is a list of flags.
10611079
#
1062-
# The return value is an array of Net::IMAP::FetchData. For example:
1080+
# The return value is an array of FetchData. For example:
10631081
#
10641082
# p imap.store(6..8, "+FLAGS", [:Deleted])
10651083
# #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
@@ -1079,7 +1097,7 @@ def uid_store(set, attr, flags)
10791097
# a number, an array of numbers, or a Range object. The number is
10801098
# a message sequence number.
10811099
#
1082-
# ==== Capabilities
1100+
# ===== Capabilities
10831101
#
10841102
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
10851103
# supported, the server's response should include a +COPYUID+ response code
@@ -1091,7 +1109,7 @@ def copy(set, mailbox)
10911109

10921110
# Similar to #copy, but +set+ contains unique identifiers.
10931111
#
1094-
# ==== Capabilities
1112+
# ===== Capabilities
10951113
#
10961114
# +UIDPLUS+ affects #uid_copy the same way it affects #copy.
10971115
def uid_copy(set, mailbox)
@@ -1103,7 +1121,7 @@ def uid_copy(set, mailbox)
11031121
# a number, an array of numbers, or a Range object. The number is
11041122
# a message sequence number.
11051123
#
1106-
# ==== Capabilities requirements
1124+
# ===== Capabilities requirements
11071125
#
11081126
# +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must be supported by
11091127
# the server.
@@ -1119,7 +1137,7 @@ def move(set, mailbox)
11191137

11201138
# Similar to #move, but +set+ contains unique identifiers.
11211139
#
1122-
# ==== Capabilities requirements
1140+
# ===== Capabilities requirements
11231141
#
11241142
# Same as #move: +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must
11251143
# be supported by the server. +UIDPLUS+ also affects #uid_move the same way
@@ -1171,8 +1189,7 @@ def remove_response_handler(handler)
11711189
end
11721190

11731191
# Similar to #search, but returns message sequence numbers in threaded
1174-
# format, as a Net::IMAP::ThreadMember tree. The supported algorithms
1175-
# are:
1192+
# format, as a ThreadMember tree. The supported algorithms are:
11761193
#
11771194
# ORDEREDSUBJECT:: split into single-level threads according to subject,
11781195
# ordered by date.

0 commit comments

Comments
 (0)