Skip to content

Commit a5e5cc8

Browse files
committed
docs: retarget or demote cross-references that cannot resolve (#1919, #1920)
- Demote roles naming aenum, pcap, pcapfile and pyshark to literals across hand-written docs and docstrings: their objects.inv has no py: objects (#934). - Demote dpkt, scapy and cryptography targets their inventories lack, such as the top-level dpkt module and scapy.all; link the engine list to project pages. - Retarget warnings.catch_warnings to :class:, dictdumper.Dumper to dictdumper.dumper.Dumper, Dumper._append_dict to the PLIST and JSON writers, and Mapping.items to collections.abc.Mapping. - Demote warnings.filters, abc.ABCMeta.__new__, _declared_keywords and OptionEnumField.post_process, which have no entry anywhere. - Document pcapkit.utilities.compat.final and EnumMeta.registry, and qualify the EnumMeta.registry references. - Add a test rejecting roles into inventory-less packages across docs/ and pcapkit/, and pinning the retired targets and the new entries. Refs #1919 Refs #1920
1 parent 95caa8b commit a5e5cc8

35 files changed

Lines changed: 450 additions & 220 deletions

File tree

‎docs/source/pcapkit/const/tcp.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ which is automatically generated from :class:`pcapkit.vendor.tcp.flags.Flags`.
6969
.. versionchanged:: 1.5.0
7070

7171
A value outside the 16-bit field raises :exc:`ValueError`, where
72-
:mod:`aenum` composed a pseudo-member for any integer.
72+
``aenum`` composed a pseudo-member for any integer.
7373

7474
.. autoclass:: pcapkit.const.tcp.flags.Flags
7575
:members:

‎docs/source/pcapkit/dumpkit/common.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Common Utilities
44
.. module:: pcapkit.dumpkit.common
55

66
:mod:`pcapkit.dumpkit.common` holds the utilities shared by
7-
:mod:`pcapkit.dumpkit`, chiefly customised hooks for :class:`dictdumper.Dumper`
7+
:mod:`pcapkit.dumpkit`, chiefly customised hooks for :class:`dictdumper.dumper.Dumper`
88
classes.
99

1010
.. autofunction:: pcapkit.dumpkit.common.make_dumper

‎docs/source/pcapkit/foundation/engines/3rdparty.rst‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ support, as is used by :class:`pcapkit.foundation.extraction.Extractor`.
1414

1515
.. note::
1616

17-
Constructing this engine imports :mod:`scapy.all`, which populates `Scapy`_'s
17+
Constructing this engine imports ``scapy.all``, which populates `Scapy`_'s
1818
layer registries -- ``conf.l2types`` and the ``bind_layers`` payload table,
1919
both of which exist only as import side effects of the layer modules.
2020
Importing a narrower submodule leaves them empty, and
@@ -26,9 +26,9 @@ support, as is used by :class:`pcapkit.foundation.extraction.Extractor`.
2626
``Ethernet / IP / UDP / Raw``, and such a list would go stale silently as
2727
`Scapy`_ gains layer types.
2828

29-
One side effect: :mod:`scapy.all` loads :mod:`scapy.layers.dcerpc`, which
29+
One side effect: ``scapy.all`` loads :mod:`scapy.layers.dcerpc`, which
3030
reaches `Scapy`_'s TLS layer and there triggers a
31-
``CryptographyDeprecationWarning`` from :mod:`cryptography` about
31+
``CryptographyDeprecationWarning`` from ``cryptography`` about
3232
finite-field Diffie-Hellman. It concerns a key-exchange code path
3333
:mod:`pcapkit` never executes, but it subclasses :exc:`UserWarning` rather
3434
than :exc:`DeprecationWarning`, so Python's default filters show it.
@@ -193,7 +193,7 @@ support, as is used by :class:`pcapkit.foundation.extraction.Extractor`.
193193

194194
.. important::
195195

196-
`pcap-ct`_ installs the same top-level :mod:`pcap` module as `PyPCAP`_. This
196+
`pcap-ct`_ installs the same top-level ``pcap`` module as `PyPCAP`_. This
197197
engine therefore checks which of the two it got and raises
198198
:exc:`~pcapkit.utilities.exceptions.UnsupportedCall` when it is `pcap-ct`_,
199199
naming ``engine='pcap_ct'`` in the message. Running `pcap-ct`_ under the
@@ -308,8 +308,8 @@ support, as is used by :class:`pcapkit.foundation.extraction.Extractor`.
308308
interface rather than 1.3.0.
309309

310310
Every attribute this engine touches -- the ``pcap.pcap(name=..., promisc=...)``
311-
constructor, :meth:`~pcap.pcap.datalink`, ``snaplen``, iteration yielding
312-
``(timestamp, bytes)``, and :meth:`~pcap.pcap.close` -- is present on both and
311+
constructor, ``pcap.pcap.datalink``, ``snaplen``, iteration yielding
312+
``(timestamp, bytes)``, and ``pcap.pcap.close`` -- is present on both and
313313
behaves identically, byte for byte and timestamp for timestamp, on
314314
``pcap-ct`` 1.3.0b3 against ``pypcap`` 1.3.0 -- a statement about those
315315
versions, not a guarantee from upstream. ``PCAP_CT`` is therefore not
@@ -441,7 +441,7 @@ Backend Detection
441441

442442
.. module:: pcapkit.foundation.engines._pcap_backend
443443

444-
Unrelated PyPI distributions install a top-level module named :mod:`pcap` --
444+
Unrelated PyPI distributions install a top-level module named ``pcap`` --
445445
`PyPCAP`_, a Cython binding shipped as a single extension module, and `pcap-ct`_,
446446
a :mod:`ctypes` reimplementation shipped as a package. They therefore collide,
447447
and ``import pcap`` resolves to whichever the import system finds first.

‎docs/source/pcapkit/protocols/index.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ Internal Definitions
230230
:no-members:
231231
:show-inheritance:
232232

233+
.. autoproperty:: registry
234+
233235
.. autoclass:: pcapkit.protocols.schema.schema._EnumRegistry
234236
:no-members:
235237
:show-inheritance:

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,18 @@ following objects and functions:
6666
- Python 3.10
6767
* - :class:`types.UnionType`, or :data:`None` below it
6868
- Python 3.10
69+
70+
.. function:: final(f)
71+
72+
:func:`typing.final` from Python 3.11 on, and ``typing_extensions.final``
73+
below it. Both record ``__final__ = True`` on the decorated object at
74+
runtime, which :class:`~pcapkit.corekit.infoclass.Info` and
75+
:class:`~pcapkit.protocols.schema.schema.Schema` read to refuse a class
76+
marked ``@final`` without :func:`~pcapkit.corekit.infoclass.info_final` or
77+
:func:`~pcapkit.protocols.schema.schema.schema_final`. Plain
78+
:func:`typing.final` records nothing below 3.11 (gh-90500).
79+
80+
.. versionchanged:: 1.5.0
81+
82+
Taken from ``typing_extensions`` below Python 3.11 rather than 3.8, so
83+
that ``__final__`` is recorded on every supported version (:issue:`778`).

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ channel**:
2323
``pcapkit`` logger sees every complaint whatever the warning filters say;
2424
2. the standard :mod:`warnings` machinery, via :func:`warnings.warn`, subject to
2525
the filters -- so :func:`warnings.filterwarnings`,
26-
:func:`warnings.catch_warnings`, :mod:`pytest`'s ``filterwarnings``,
26+
:class:`warnings.catch_warnings`, :mod:`pytest`'s ``filterwarnings``,
2727
:option:`-W` and :envvar:`PYTHONWARNINGS` govern :mod:`pcapkit` warnings
2828
exactly as they govern any other library's (with one wrinkle in naming a
2929
category on the command line, noted below).
@@ -91,7 +91,7 @@ configured separately, through the :mod:`logging` module::
9191
the first snippet above restores the 1.4.x quiet. In 1.4.x, constructing a
9292
:class:`~pcapkit.utilities.warnings.BaseWarning` installed an ``ignore``
9393
filter for its own class, so a caller could not re-enable them. The filter
94-
went at the *front* of the process-global :data:`warnings.filters`, so it
94+
went at the *front* of the process-global ``warnings.filters``, so it
9595
also overrode the host application's own configuration for those categories
9696
and made unrelated warnings re-fire (:issue:`364`).
9797

‎pcapkit/corekit/enum.py‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ class EnumLookup:
119119
on top; a closed enumeration inherits this one directly and so is never
120120
handed a ``register`` it would have to refuse.
121121
122-
This is a plain mix-in rather than an :class:`~aenum.Enum` subclass, because
122+
This is a plain mix-in rather than an ``aenum.Enum`` subclass, because
123123
an enumeration that already has members cannot be subclassed. Mixed in
124124
*before* the member type -- ``class Foo(EnumRegistry, IntFlag)``, or
125125
``class Bar(EnumLookup, IntEnum)`` -- it contributes methods only, so
126-
:mod:`aenum` still resolves the member data type from the enumeration base:
127-
``int`` for :class:`~aenum.IntEnum` and :class:`~aenum.IntFlag`, ``str`` for
128-
:class:`~aenum.StrEnum`. That is what lets one base serve each of them, where a
126+
``aenum`` still resolves the member data type from the enumeration base:
127+
``int`` for ``aenum.IntEnum`` and ``aenum.IntFlag``, ``str`` for
128+
``aenum.StrEnum``. That is what lets one base serve each of them, where a
129129
generated template fragment would have needed a separate rendering per
130130
member type.
131131
@@ -134,20 +134,20 @@ class EnumLookup:
134134
``class Foo(EnumRegistry, IntFlag)`` resolves as ``Foo -> EnumRegistry ->
135135
EnumLookup -> IntFlag -> int -> ...``, so ``_member_type_`` still comes from
136136
the enumeration base and not from anything in this module. Had this tier
137-
subclassed :class:`~aenum.Enum` in order to "be an enum", it would have
137+
subclassed ``aenum.Enum`` in order to "be an enum", it would have
138138
become the member type itself and broken every one of these shapes at once.
139139
140140
The methods deliberately touch only ``_member_map_``, ``_member_names_`` and
141-
``_value2member_map_``, which both :mod:`enum` and :mod:`aenum` maintain, so
142-
nothing on this tier depends on :mod:`aenum` internals at all -- the
143-
:func:`~aenum.extend_enum` call in this module belongs to
141+
``_value2member_map_``, which both :mod:`enum` and ``aenum`` maintain, so
142+
nothing on this tier depends on ``aenum`` internals at all -- the
143+
``aenum.extend_enum`` call in this module belongs to
144144
:class:`EnumRegistry`, which is the tier that mutates.
145145
146146
"""
147147

148148
if TYPE_CHECKING:
149149
#: The enumeration machinery's own lookup tables and member data type,
150-
#: declared here because they are contributed by the :class:`~aenum.Enum`
150+
#: declared here because they are contributed by the ``aenum.Enum``
151151
#: base this mix-in is combined with rather than by the mix-in itself.
152152
_member_map_: 'dict[str, Self]'
153153
_member_names_: 'list[str]'
@@ -303,7 +303,7 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'Self':
303303
:class:`~pcapkit.const.pcapng.tls_key_label.TLSKeyLabel`) mints on
304304
any path, so no live witness exists in this tree.
305305
:class:`~pcapkit.const.mh.cga_type.CGAType`, which still mints directly
306-
via :func:`~aenum.extend_enum`, is :class:`int`-valued, so
306+
via ``aenum.extend_enum``, is :class:`int`-valued, so
307307
a ``str`` name could not reach its mint branch even if this restriction
308308
did not exist; it is not an exception to it, just not reachable by it.
309309
This is about a future ``str``-valued registry (or a present one whose
@@ -390,7 +390,7 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'Self':
390390
typically :exc:`~pcapkit.utilities.exceptions.EnumValueError` from a
391391
subclass's :meth:`_validate_value` -- is re-raised as it stands rather
392392
than wrapped, so the subclass's own message survives and no second
393-
error is constructed. Only :mod:`aenum`'s and :mod:`enum`'s own "no
393+
error is constructed. Only ``aenum``'s and :mod:`enum`'s own "no
394394
member carries this value" is converted, into a quiet
395395
:exc:`~pcapkit.utilities.exceptions.EnumValueError`. This is the same
396396
discrimination :meth:`EnumField.post_process
@@ -520,8 +520,8 @@ def register(cls, value: 'Any', name: 'str') -> 'Self':
520520
Contrast :meth:`get` and ``_missing_``, which resolve without naming anything.
521521
522522
Refuses a ``value`` that already has a member. Without this guard,
523-
:func:`~aenum.extend_enum` does not mint anything for an already-taken
524-
value -- :mod:`aenum` treats that as a request to *alias* the existing
523+
``aenum.extend_enum`` does not mint anything for an already-taken
524+
value -- ``aenum`` treats that as a request to *alias* the existing
525525
member under the caller's ``name`` instead, silently: the call returns
526526
the *existing* member, ``name`` becomes reachable in ``__members__``
527527
pointing at it, and ``_member_names_`` does not grow. That is
@@ -565,7 +565,7 @@ def register(cls, value: 'Any', name: 'str') -> 'Self':
565565
:meth:`~EnumLookup._validate_value` rejects ``value``. The base
566566
implementation of that hook accepts everything, so this cannot
567567
arise on a registry that does not override it.
568-
ValueError: If ``name`` is already taken. :mod:`aenum` reports that
568+
ValueError: If ``name`` is already taken. ``aenum`` reports that
569569
as :exc:`TypeError`; it is translated so that the ways one call
570570
can fail are one exception type.
571571
@@ -583,7 +583,7 @@ def register(cls, value: 'Any', name: 'str') -> 'Self':
583583

584584
@classmethod
585585
def _extend(cls, value: 'Any', name: 'str') -> 'Self':
586-
"""The raw :func:`~aenum.extend_enum` call, shared by :meth:`register`
586+
"""The raw ``aenum.extend_enum`` call, shared by :meth:`register`
587587
and :meth:`register_alias`.
588588
589589
Neither public method calls the other: :meth:`register` refuses an
@@ -603,7 +603,7 @@ def _extend(cls, value: 'Any', name: 'str') -> 'Self':
603603
The member now reachable under ``name``, new or existing.
604604
605605
Raises:
606-
ValueError: If ``name`` is already taken. :mod:`aenum` reports that
606+
ValueError: If ``name`` is already taken. ``aenum`` reports that
607607
as :exc:`TypeError`; it is translated so that the ways one call
608608
can fail are one exception type.
609609
@@ -642,7 +642,7 @@ def register_alias(cls, value: 'Any', name: 'str') -> 'Self':
642642
:meth:`register_alias` test ``value``'s membership for opposite
643643
outcomes, so neither can be the other's implementation.
644644
``AppType``'s override differs: it mints a real member through
645-
:func:`~aenum.extend_enum`, so its iteration grows too.
645+
``aenum.extend_enum``, so its iteration grows too.
646646
647647
Args:
648648
value: Value of the existing member to alias.
@@ -674,7 +674,7 @@ def register_aliases(cls, value: 'Any', *names: 'str') -> 'tuple[Self, ...]':
674674
675675
Raises:
676676
ValueError: As :meth:`register_alias`. Names before the failing one
677-
stay registered -- :func:`~aenum.extend_enum` has no transaction
677+
stay registered -- ``aenum.extend_enum`` has no transaction
678678
to roll back, and undoing it by hand would mean reaching further
679679
into enumeration internals than anything else here does.
680680
@@ -691,7 +691,7 @@ def _unregistered_member(cls, value: 'Any', name: 'str') -> 'Self':
691691
that does.
692692
693693
The member is constructed through ``cls._member_type_``, which
694-
:mod:`aenum` sets from the enumeration base, so this serves ``int``- and
694+
``aenum`` sets from the enumeration base, so this serves ``int``- and
695695
``str``-valued registries alike without either having to say which it
696696
is.
697697

‎pcapkit/corekit/fields/numbers.py‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ def post_process(self, value: 'int | bytes', packet: 'dict[str, Any]') -> 'Stdli
693693
Notes:
694694
The registry is consulted through its constructor, which raises for
695695
a value no member and no ``_missing_`` rule accounts for. That raise
696-
is :mod:`aenum`'s own bare :exc:`ValueError`: not one of
696+
is ``aenum``'s own bare :exc:`ValueError`: not one of
697697
:mod:`pcapkit.utilities.exceptions`, so a caller cannot tell it from
698698
a bug of its own, and not an :exc:`EOFError`, so
699699
:meth:`Extractor.record_frames
@@ -719,19 +719,19 @@ def post_process(self, value: 'int | bytes', packet: 'dict[str, Any]') -> 'Stdli
719719
``<unassigned>`` never takes -- and one an :class:`int`-keyed
720720
dispatch registry looks up by value like any declared member. It is
721721
built per value rather than grafted onto
722-
the registry with :func:`aenum.extend_enum`, for two reasons: a
722+
the registry with ``aenum.extend_enum``, for two reasons: a
723723
capture carrying many distinct unassigned codes would otherwise grow
724724
a process-global registry without bound, which is the growth
725725
:meth:`ProtocolBase._lookup_registry
726726
<pcapkit.protocols.protocol.ProtocolBase._lookup_registry>` exists
727727
to avoid; and a stdlib :class:`enum.IntEnum` registry is then
728-
handled exactly like an :class:`aenum.IntEnum` one.
728+
handled exactly like an ``aenum.IntEnum`` one.
729729
730730
Only a *foreign* rejection is absorbed. A registry rejecting a value
731731
with one of :mod:`pcapkit.utilities.exceptions` has made a
732732
deliberate decision that this layer -- which sees only that the value
733733
arrived in a field of some width -- is in no position to overrule, so
734-
an in-library error propagates unchanged and it is only :mod:`aenum`'s
734+
an in-library error propagates unchanged and it is only ``aenum``'s
735735
and :mod:`enum`'s "no member has this value" that becomes a
736736
pseudo-member. That is what keeps the fallback from being an
737737
unconditional ``except ValueError: pass``.
@@ -761,7 +761,7 @@ def post_process(self, value: 'int | bytes', packet: 'dict[str, Any]') -> 'Stdli
761761
.. versionchanged:: 1.5.0
762762
763763
A value the registry has no member for resolves to a nameless
764-
pseudo-member, where :mod:`aenum`'s bare :exc:`ValueError` escaped
764+
pseudo-member, where ``aenum``'s bare :exc:`ValueError` escaped
765765
(:issue:`701`).
766766
767767
"""
@@ -798,7 +798,7 @@ def _pseudo_member(self, value: 'int') -> 'StdlibEnum | AenumEnum':
798798
799799
Returns:
800800
A single-member, throwaway :class:`enum.IntEnum` instance, built
801-
fresh per call rather than :func:`~aenum.extend_enum`-ed onto
801+
fresh per call rather than ``aenum.extend_enum``-ed onto
802802
``self._namespace``, per this method's own docstring above.
803803
804804
"""
@@ -828,15 +828,14 @@ def _unregistered_member(namespace: 'Type[StdlibEnum] | Type[AenumEnum]',
828828
``cls.__members_ns__[...] = ...`` line every registry in this package
829829
uses to record a member it mints. No entry is added to
830830
``_member_map_`` or ``_value2member_map_`` either, since those are
831-
only ever touched by the metaclass machinery :func:`aenum.extend_enum`
831+
only ever touched by the metaclass machinery ``aenum.extend_enum``
832832
drives, which this bypasses completely.
833833
834834
Note:
835835
Building a member this way, rather than as some other type
836836
altogether, is why :meth:`PortEnumField.post_process` and
837-
:meth:`OptionEnumField.post_process
838-
<pcapkit.protocols.schema.misc.pcapng.OptionEnumField.post_process>`
839-
need this rather than :meth:`_pseudo_member`:
837+
``OptionEnumField.post_process`` (in
838+
:mod:`pcapkit.protocols.schema.misc.pcapng`) need this rather than :meth:`_pseudo_member`:
840839
the result answers ``isinstance(result, AppType)`` truthfully,
841840
which :meth:`PortEnumField.pre_process` tests before reading
842841
``.port`` off it, and ``Transport._make_port`` in
@@ -1036,7 +1035,7 @@ class PortEnumField(EnumField):
10361035
10371036
Important:
10381037
This class is specifically designed for :class:`~pcapkit.const.reg.apptype.apptype.AppType`
1039-
as it is actually a :class:`~aenum.StrEnum` class.
1038+
as it is actually an ``aenum.StrEnum`` class.
10401039
10411040
.. versionadded:: 1.5.0
10421041

‎pcapkit/corekit/infoclass.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,8 @@ def items(self, multi: 'bool' = False) -> 'ItemsView[str, VT] | Iterator[tuple[s
588588
Args:
589589
multi: If set to :obj:`True`, an iterator with a pair for each value
590590
of each key, as :meth:`to_dict` writes them. Otherwise a view of
591-
the pairs of the first value of each key, as
592-
:meth:`Mapping.items <collections.abc.Mapping.items>` returns.
591+
the pairs of the first value of each key, as the ``items``
592+
method of :class:`collections.abc.Mapping` returns.
593593
594594
"""
595595
if not multi:

‎pcapkit/corekit/io.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ def __getattr__(self, name: 'str') -> 'Any':
857857
class NamedStream:
858858
"""Read-only proxy that gives a stream the ``name`` attribute.
859859
860-
:func:`pcapfile.savefile.load_savefile` dereferences ``input_file.name``
860+
``pcapfile.savefile.load_savefile`` dereferences ``input_file.name``
861861
unconditionally, on the way into its trace helper. That is fine for the
862862
:class:`~io.BufferedReader` :class:`~pcapkit.foundation.extraction.Extractor`
863863
normally holds, but not for the :class:`~pcapkit.corekit.io.SeekableReader`

0 commit comments

Comments
 (0)