Skip to content

Commit b8aaff1

Browse files
authored
docs: retarget Protocol/ProtocolBase cross-references to match the #1103 display rule (#2422)
Applying the #1103 ruling to the member references #2420 left behind: a `ProtocolBase.<member>` cross-reference now reads `Protocol.<member>`, for one consistent public vocabulary, and links there too. Both halves move, because on the rendered page that is where the documentation is. `protocol.rst` documents the members with nested `autoproperty`/`automethod` directives under `.. autoclass:: ...Protocol`, so `Protocol.<member>` carries the signature and the docstring; the `ProtocolBase` block is `:no-members:` plus grouped `:no-index-entry:` stubs whose body only links back to the `Protocol.*` entries, and the general index lists `Protocol.*` alone. Measured on the pinned docs toolchain (`Sphinx==9.2.0`). * 46 sites in `pcapkit/` and `docs/source/`. 37 move display *and* target to `Protocol.<member>`; the other 9 already targeted `Protocol` and only needed the display text. The explicit target is the fully-qualified spelling the house style asks for -- the form 124 existing references already use. * `from_data` is consistent again: `internet.py` and `application.py` pointed at `ProtocolBase.from_data` where `link.py` and `transport.py` pointed at `Protocol.from_data` for the same kind of reference. All four now read alike. * `__init_subclass__` keeps `ProtocolBase` (6 sites), since `Protocol` overrides it and naming `Protocol` would name a different method. So do `schema.py` and `protocol-layer-placement.rst`, whose adjacent prose would otherwise contradict itself, and `register`'s `Raises:` clause, which names the class the guard's `issubclass` tests (#2316/#1016). * `changelog/1.5.0.rst` keeps its five `ProtocolBase.<member>` references. Each names the class a *built-in* protocol inherits the member from -- the built-ins derive from `ProtocolBase`, not `Protocol` -- and `CHANGELOG.md` is generated from that file by `util/changelog_md.py`, where a role flattens to a code span with no link, so moving them would rewrite release-note prose rather than an href. * `tests/` and `examples/` are untouched (28 sites): their docstrings are not part of the Sphinx render. Hrefs only. A role-canonicalisation guard reports no role and no display-text change beyond the above, and an AST-structure guard (`ast.dump` with docstrings stripped) is identical for every touched `.py` file.
1 parent 53f1e57 commit b8aaff1

29 files changed

Lines changed: 75 additions & 70 deletions

File tree

‎docs/source/ext.rst‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ The following code snippet shows how to create a new protocol class:
241241
silently wrong field. The accepted set is read from :func:`inspect.signature` -- the union of every
242242
keyword-taking parameter of ``make``, ``read``, ``pack``, ``unpack``,
243243
``__post_init__`` and ``__init__`` anywhere in the class's MRO -- which is
244-
wider than ``make`` alone because :meth:`ProtocolBase.__post_init__
245-
<pcapkit.protocols.protocol.ProtocolBase.__post_init__>` hands the same
244+
wider than ``make`` alone because :meth:`Protocol.__post_init__
245+
<pcapkit.protocols.protocol.Protocol.__post_init__>` hands the same
246246
``**kwargs`` to the construction and to the parse, so a keyword only ``read``
247247
declares still travels through ``make``.
248248

249249
Shapes a signature cannot express are declared on the class instead, via
250-
:attr:`ProtocolBase.__keywords__
251-
<pcapkit.protocols.protocol.ProtocolBase.__keywords__>`:
250+
:attr:`Protocol.__keywords__
251+
<pcapkit.protocols.protocol.Protocol.__keywords__>`:
252252

253253
.. code-block:: python
254254
@@ -271,8 +271,8 @@ The following code snippet shows how to create a new protocol class:
271271
subclass of a dispatcher is checked normally. Prefer a declared parameter to
272272
either: it is also what documents the keyword to your callers.
273273

274-
Parsing is unaffected. :meth:`ProtocolBase.from_data
275-
<pcapkit.protocols.protocol.ProtocolBase.from_data>` checks the keywords its
274+
Parsing is unaffected. :meth:`Protocol.from_data
275+
<pcapkit.protocols.protocol.Protocol.from_data>` checks the keywords its
276276
caller passes just as strictly, raising
277277
:exc:`~pcapkit.utilities.exceptions.UnsupportedCall`, but only warns with
278278
:exc:`~pcapkit.utilities.warnings.UnknownFieldWarning` for a key that comes
@@ -281,8 +281,8 @@ The following code snippet shows how to create a new protocol class:
281281

282282
.. warning::
283283

284-
The check lives in :meth:`ProtocolBase.__init__
285-
<pcapkit.protocols.protocol.ProtocolBase.__init__>`, where every producer's
284+
The check lives in :meth:`Protocol.__init__
285+
<pcapkit.protocols.protocol.Protocol.__init__>`, where every producer's
286286
keywords converge, so it covers ``SomeProtocol(...)`` and the ``pack`` it
287287
leads to -- but **not** a direct ``SomeProtocol.make(...)`` call, which still
288288
discards an undeclared keyword in silence. ``object.__new__(cls).make(...)``

‎docs/source/pcapkit/protocols/internet/ipv6_ext.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ This class is reached in these ways:
141141
``IPv6-Route``, ``IPv6-Opts``, ``MH``, ``HIP``, ``IPv6-Frag`` and ``AH`` all
142142
have dedicated classes. When one of *those* raises,
143143
:func:`~pcapkit.corekit.decorators.beholder`
144-
(:meth:`ProtocolBase._import_next_layer <pcapkit.protocols.protocol.ProtocolBase._import_next_layer>`)
144+
(:meth:`Protocol._import_next_layer <pcapkit.protocols.protocol.Protocol._import_next_layer>`)
145145
would substitute plain :class:`~pcapkit.protocols.misc.raw.Raw`, which loses
146146
``next`` and crashes the walk as in path 1.
147147
:meth:`IPv6._import_next_layer <pcapkit.protocols.internet.ipv6.IPv6._import_next_layer>` catches

‎docs/source/pcapkit/utilities/chardet.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Character Set Detection
77
turning the bytes of a text field into a :obj:`str`. It is shared by
88
:meth:`StringField.post_process
99
<pcapkit.corekit.fields.strings.StringField.post_process>` and
10-
:meth:`ProtocolBase.decode <pcapkit.protocols.protocol.Protocol.decode>`,
10+
:meth:`Protocol.decode <pcapkit.protocols.protocol.Protocol.decode>`,
1111
which is why it lives here rather than beside either of them.
1212

1313
.. autofunction:: pcapkit.utilities.chardet.detect

‎pcapkit/corekit/decorators.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656

5757
#: contextvars.ContextVar[bool]: Whether a call :func:`beholder` wraps is under
5858
#: way, so that an :exc:`Exception` raised inside it ends with the layer that
59-
#: raised replaced; see :meth:`ProtocolBase._parse_next_layer
60-
#: <pcapkit.protocols.protocol.ProtocolBase._parse_next_layer>` (:issue:`2308`).
59+
#: raised replaced; see :meth:`Protocol._parse_next_layer
60+
#: <pcapkit.protocols.protocol.Protocol._parse_next_layer>` (:issue:`2308`).
6161
_beholding = contextvars.ContextVar('_beholding', default=False)
6262

6363

@@ -116,8 +116,8 @@ def beholder(
116116
:class:`~pcapkit.protocols.misc.null.NoPayload`, if the error is an
117117
end-of-file :exc:`~pcapkit.utilities.exceptions.StructError`.
118118
119-
When :meth:`ProtocolBase._parse_next_layer
120-
<pcapkit.protocols.protocol.ProtocolBase._parse_next_layer>` held the
119+
When :meth:`Protocol._parse_next_layer
120+
<pcapkit.protocols.protocol.Protocol._parse_next_layer>` held the
121121
warnings of the layer that raised, they are dropped with it: they describe a
122122
layer the result does not have, and the replacement's ``error`` reports the
123123
failure (:issue:`2308`).

‎pcapkit/corekit/fields/numbers.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ def post_process(self, value: 'int | bytes', packet: 'dict[str, Any]') -> 'Stdli
730730
the registry with ``aenum.extend_enum``, for two reasons: a
731731
capture carrying many distinct unassigned codes would otherwise grow
732732
a process-global registry without bound, which is the growth
733-
:meth:`ProtocolBase._lookup_registry
734-
<pcapkit.protocols.protocol.ProtocolBase._lookup_registry>` exists
733+
:meth:`Protocol._lookup_registry
734+
<pcapkit.protocols.protocol.Protocol._lookup_registry>` exists
735735
to avoid; and a stdlib :class:`enum.IntEnum` registry is then
736736
handled exactly like an ``aenum.IntEnum`` one.
737737

‎pcapkit/corekit/module.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def klass(self) -> 'Type[_T]':
6060
The module is read from :data:`sys.modules` first, and
6161
:func:`importlib.import_module` is entered only when it is not
6262
loaded yet. That matters because this property is on a *per-frame*
63-
dispatch path: :meth:`ProtocolBase._lookup_next_layer
64-
<pcapkit.protocols.protocol.ProtocolBase._lookup_next_layer>`
63+
dispatch path: :meth:`Protocol._lookup_next_layer
64+
<pcapkit.protocols.protocol.Protocol._lookup_next_layer>`
6565
deliberately writes no resolved class back, so every next layer
6666
lookup resolves its descriptor again -- the one registered for the
6767
code, or the fallback for :class:`~pcapkit.protocols.misc.raw.Raw`

‎pcapkit/corekit/sentinels.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ def __bool__(self) -> 'Literal[False]':
571571
#: own ``__keywords__`` out of its :attr:`~object.__dict__`, where
572572
#: :obj:`None` is itself a meaningful value -- the opt-out that says the
573573
#: class cannot enumerate its keywords, cf.
574-
#: :attr:`ProtocolBase.__keywords__
575-
#: <pcapkit.protocols.protocol.ProtocolBase.__keywords__>`. Never leaves
574+
#: :attr:`Protocol.__keywords__
575+
#: <pcapkit.protocols.protocol.Protocol.__keywords__>`. Never leaves
576576
#: :mod:`pcapkit.protocols.protocol`, which imports it from here for exactly
577577
#: that one read. Private by documentation rather than by a
578578
#: leading underscore -- see :class:`AbsentType`'s own docstring.

‎pcapkit/foundation/engines/dpkt.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ def read_frame(self) -> 'DPKTPacket':
551551
try:
552552
packet = protocol(pkt) # type: DPKTPacket
553553
except Exception as exc: # pylint: disable=broad-except
554-
# NOTE: Caught broadly, as :meth:`ProtocolBase.analyze
555-
# <pcapkit.protocols.protocol.ProtocolBase.analyze>` does: dpkt raises
554+
# NOTE: Caught broadly, as :meth:`Protocol.analyze
555+
# <pcapkit.protocols.protocol.Protocol.analyze>` does: dpkt raises
556556
# more than its own ``UnpackError`` while parsing -- dpkt 1.9.8 reads
557557
# ``frag_off`` from whatever header follows an IPv6 Fragment header,
558558
# so a Fragment header followed by ESP or Destination Options raises

‎pcapkit/protocols/application/application.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def from_data(cls, data: '_PT | dict[str, Any]', **kwargs: 'Any') -> 'Self':
121121
122122
Args:
123123
data: Protocol data.
124-
**kwargs: Construction keywords, as for :meth:`ProtocolBase.from_data
125-
<pcapkit.protocols.protocol.ProtocolBase.from_data>`.
124+
**kwargs: Construction keywords, as for :meth:`Protocol.from_data
125+
<pcapkit.protocols.protocol.Protocol.from_data>`.
126126
127127
Returns:
128128
Protocol instance, cut back to what was captured when the header

‎pcapkit/protocols/application/http.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ def from_data(cls, data: '_PT | dict[str, Any]', **kwargs: 'Any') -> 'Self':
404404
into the versioned data model its keys belong to -- ``receipt``
405405
is HTTP/1.*'s and ``sid`` HTTP/2's -- since this class's own data
406406
model carries no version.
407-
**kwargs: As :meth:`ProtocolBase.from_data
408-
<pcapkit.protocols.protocol.ProtocolBase.from_data>`.
407+
**kwargs: As :meth:`Protocol.from_data
408+
<pcapkit.protocols.protocol.Protocol.from_data>`.
409409
410410
Returns:
411411
Protocol instance.

0 commit comments

Comments
 (0)