Skip to content

Commit 901c4f1

Browse files
harjothkharaclaude
andcommitted
gh-151945: Fix Sphinx reference warnings in http.cookiejar and http.server docs
Resolve the nit-picky reference warnings in Doc/library/http.cookiejar.rst and Doc/library/http.server.rst, and drop both files from Doc/tools/.nitignore so future regressions are caught by CI. Documented targets are qualified with their owning class -- for example Cookie.version, CookiePolicy.rfc2965, the urllib.request.Request methods and attributes, and urllib.response.addinfourl.info. References that have no documented target become inline literals: the removed get_origin_req_host method, and the undocumented http.server members server_name, server_port, list_directory, guess_type and index_pages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f21f338 commit 901c4f1

3 files changed

Lines changed: 42 additions & 31 deletions

File tree

Doc/library/http.cookiejar.rst

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ The following classes are provided:
9898
1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling
9999
is turned off or :attr:`rfc2109_as_netscape` is ``True``, RFC 2109 cookies are
100100
'downgraded' by the :class:`CookieJar` instance to Netscape cookies, by
101-
setting the :attr:`version` attribute of the :class:`Cookie` instance to 0.
101+
setting the :attr:`~Cookie.version` attribute of the :class:`Cookie` instance to 0.
102102
:class:`DefaultCookiePolicy` also provides some parameters to allow some
103103
fine-tuning of policy.
104104

@@ -107,7 +107,7 @@ The following classes are provided:
107107

108108
This class represents Netscape, :rfc:`2109` and :rfc:`2965` cookies. It is not
109109
expected that users of :mod:`!http.cookiejar` construct their own :class:`Cookie`
110-
instances. Instead, if necessary, call :meth:`make_cookies` on a
110+
instances. Instead, if necessary, call :meth:`~CookieJar.make_cookies` on a
111111
:class:`CookieJar` instance.
112112

113113

@@ -154,20 +154,27 @@ contained :class:`Cookie` objects.
154154

155155
Add correct :mailheader:`Cookie` header to *request*.
156156

157-
If policy allows (ie. the :attr:`rfc2965` and :attr:`hide_cookie2` attributes of
157+
If policy allows (ie. the :attr:`~CookiePolicy.rfc2965` and
158+
:attr:`~CookiePolicy.hide_cookie2` attributes of
158159
the :class:`CookieJar`'s :class:`CookiePolicy` instance are true and false
159160
respectively), the :mailheader:`Cookie2` header is also added when appropriate.
160161

161162
The *request* object (usually a :class:`urllib.request.Request` instance)
162-
must support the methods :meth:`get_full_url`, :meth:`has_header`,
163-
:meth:`get_header`, :meth:`header_items`, :meth:`add_unredirected_header`
164-
and the attributes :attr:`host`, :attr:`!type`, :attr:`unverifiable`
165-
and :attr:`origin_req_host` as documented by :mod:`urllib.request`.
163+
must support the methods :meth:`~urllib.request.Request.get_full_url`,
164+
:meth:`~urllib.request.Request.has_header`,
165+
:meth:`~urllib.request.Request.get_header`,
166+
:meth:`~urllib.request.Request.header_items`,
167+
:meth:`~urllib.request.Request.add_unredirected_header`
168+
and the attributes :attr:`~urllib.request.Request.host`, :attr:`!type`,
169+
:attr:`~urllib.request.Request.unverifiable`
170+
and :attr:`~urllib.request.Request.origin_req_host` as documented by
171+
:mod:`urllib.request`.
166172

167173
.. versionchanged:: 3.3
168174

169-
*request* object needs :attr:`origin_req_host` attribute. Dependency on a
170-
deprecated method :meth:`get_origin_req_host` has been removed.
175+
*request* object needs :attr:`~urllib.request.Request.origin_req_host`
176+
attribute. Dependency on a deprecated method ``get_origin_req_host`` has
177+
been removed.
171178

172179

173180
.. method:: CookieJar.extract_cookies(response, request)
@@ -180,20 +187,24 @@ contained :class:`Cookie` objects.
180187
as appropriate (subject to the :meth:`CookiePolicy.set_ok` method's approval).
181188

182189
The *response* object (usually the result of a call to
183-
:meth:`urllib.request.urlopen`, or similar) should support an :meth:`info`
184-
method, which returns an :class:`email.message.Message` instance.
190+
:meth:`urllib.request.urlopen`, or similar) should support an
191+
:meth:`~urllib.response.addinfourl.info` method, which returns an
192+
:class:`email.message.Message` instance.
185193

186194
The *request* object (usually a :class:`urllib.request.Request` instance)
187-
must support the method :meth:`get_full_url` and the attributes
188-
:attr:`host`, :attr:`unverifiable` and :attr:`origin_req_host`,
195+
must support the method :meth:`~urllib.request.Request.get_full_url` and
196+
the attributes :attr:`~urllib.request.Request.host`,
197+
:attr:`~urllib.request.Request.unverifiable`
198+
and :attr:`~urllib.request.Request.origin_req_host`,
189199
as documented by :mod:`urllib.request`. The request is used to set
190200
default values for cookie-attributes as well as for checking that the
191201
cookie is allowed to be set.
192202

193203
.. versionchanged:: 3.3
194204

195-
*request* object needs :attr:`origin_req_host` attribute. Dependency on a
196-
deprecated method :meth:`get_origin_req_host` has been removed.
205+
*request* object needs :attr:`~urllib.request.Request.origin_req_host`
206+
attribute. Dependency on a deprecated method ``get_origin_req_host`` has
207+
been removed.
197208

198209
.. method:: CookieJar.set_policy(policy)
199210

@@ -236,13 +247,13 @@ contained :class:`Cookie` objects.
236247

237248
Discard all session cookies.
238249

239-
Discards all contained cookies that have a true :attr:`discard` attribute
250+
Discards all contained cookies that have a true :attr:`~Cookie.discard` attribute
240251
(usually because they had either no ``max-age`` or ``expires`` cookie-attribute,
241252
or an explicit ``discard`` cookie-attribute). For interactive browsers, the end
242253
of a session usually corresponds to closing the browser window.
243254

244-
Note that the :meth:`save` method won't save session cookies anyway, unless you
245-
ask otherwise by passing a true *ignore_discard* argument.
255+
Note that the :meth:`~FileCookieJar.save` method won't save session cookies
256+
anyway, unless you ask otherwise by passing a true *ignore_discard* argument.
246257

247258
:class:`FileCookieJar` implements the following additional methods:
248259

@@ -255,8 +266,9 @@ contained :class:`Cookie` objects.
255266
method unimplemented.
256267

257268
*filename* is the name of file in which to save cookies. If *filename* is not
258-
specified, :attr:`self.filename` is used (whose default is the value passed to
259-
the constructor, if any); if :attr:`self.filename` is :const:`None`,
269+
specified, :attr:`~FileCookieJar.filename` is used (whose default is the
270+
value passed to the constructor, if any); if
271+
:attr:`~FileCookieJar.filename` is :const:`None`,
260272
:exc:`ValueError` is raised.
261273

262274
*ignore_discard*: save even cookies set to be discarded. *ignore_expires*: save
@@ -463,9 +475,10 @@ blocking some benign cookies).
463475
A domain blocklist and allowlist is provided (both off by default). Only domains
464476
not in the blocklist and present in the allowlist (if the allowlist is active)
465477
participate in cookie setting and returning. Use the *blocked_domains*
466-
constructor argument, and :meth:`blocked_domains` and
467-
:meth:`set_blocked_domains` methods (and the corresponding argument and methods
468-
for *allowed_domains*). If you set an allowlist, you can turn it off again by
478+
constructor argument, and :meth:`~DefaultCookiePolicy.blocked_domains` and
479+
:meth:`~DefaultCookiePolicy.set_blocked_domains` methods (and the corresponding
480+
argument and methods for *allowed_domains*). If you set an allowlist, you can
481+
turn it off again by
469482
setting it to :const:`None`.
470483

471484
Domains in block or allow lists that do not start with a dot must equal the

Doc/library/http.server.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ handler. Code to create and run the server looks like this::
3737
.. class:: HTTPServer(server_address, RequestHandlerClass)
3838

3939
This class builds on the :class:`~socketserver.TCPServer` class by storing
40-
the server address as instance variables named :attr:`server_name` and
41-
:attr:`server_port`. The server is accessible by the handler, typically
42-
through the handler's :attr:`server` instance variable.
40+
the server address as instance variables named ``server_name`` and
41+
``server_port``. The server is accessible by the handler, typically
42+
through the handler's :attr:`~BaseHTTPRequestHandler.server` instance variable.
4343

4444
.. class:: ThreadingHTTPServer(server_address, RequestHandlerClass)
4545

@@ -437,7 +437,7 @@ instantiation, of which this module provides three different variants:
437437
If the request was mapped to a directory, the directory is checked for a
438438
file named ``index.html`` or ``index.htm`` (in that order). If found, the
439439
file's contents are returned; otherwise a directory listing is generated
440-
by calling the :meth:`list_directory` method. This method uses
440+
by calling the ``list_directory`` method. This method uses
441441
:func:`os.listdir` to scan the directory, and returns a ``404`` error
442442
response if the :func:`~os.listdir` fails.
443443

@@ -446,7 +446,7 @@ instantiation, of which this module provides three different variants:
446446
``'File not found'`` error. If there was an ``'If-Modified-Since'``
447447
header in the request, and the file was not modified after this time,
448448
a ``304``, ``'Not Modified'`` response is sent. Otherwise, the content
449-
type is guessed by calling the :meth:`guess_type` method, which in turn
449+
type is guessed by calling the ``guess_type`` method, which in turn
450450
uses the *extensions_map* variable, and the file contents are returned.
451451

452452
A ``'Content-type:'`` header with the guessed content type is output,
@@ -483,7 +483,7 @@ the current directory::
483483

484484
:class:`SimpleHTTPRequestHandler` can also be subclassed to enhance behavior,
485485
such as using different index file names by overriding the class attribute
486-
:attr:`index_pages`.
486+
``index_pages``.
487487

488488

489489
.. _http-server-cli:

Doc/tools/.nitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Doc/library/ast.rst
99
Doc/library/asyncio-extending.rst
1010
Doc/library/email.charset.rst
1111
Doc/library/email.parser.rst
12-
Doc/library/http.cookiejar.rst
13-
Doc/library/http.server.rst
1412
Doc/library/importlib.rst
1513
Doc/library/logging.config.rst
1614
Doc/library/logging.handlers.rst

0 commit comments

Comments
 (0)