Skip to content

docs(conf): resolve decorated overload aliases and qualify colliding third-party classes (#1917, #1918, #1920) - #1929

Merged
JarryShaw merged 1 commit into
mainfrom
docs/1917-conf-typehints
Oct 19, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
docs/1917-conf-typehints

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

#1917. autodoc_preserve_defaults writes __signature__ onto the @seekset wrapper, so sphinx-autodoc-typehints evaluated _read_packet's overloads in corekit.decorators. A new autodoc-before-process-signature hook, sign_wrapped_function, moves the signature to the wrapped function when it matches. The return type that rendered as → Data_Packet now reads → Packet and links.

#1918. format_class qualifies a third-party class when another class bound by the pcapkit modules shares its bare name, giving scapy.packet.Packet | dpkt.dpkt.Packet | pyshark.packet.packet.Packet. dictdumper's Dumper is qualified too, since dumpkit.common.Dumper shares its name.

#1920, formatter part. Packages without an inventory get a qualified literal instead of an unresolved role. The hand-written roles are in #1928.

The pinned docs build (Sphinx 9.1.0, typehints 3.15.0) has 0 warnings. Each new test fails with its fix reverted. They need the pinned typehints, so they skip under an older one.

Closes #1917
Closes #1918
Refs #1920

…third-party classes (#1917, #1918, #1920)

- Move the signature autodoc_preserve_defaults stores on a functools.wraps
  wrapper onto the wrapped function, so sphinx-autodoc-typehints reads the
  _read_packet overloads in their own module and Data_Packet renders as the
  Packet class (#1917).
- Record the classes each pcapkit module binds during the module walk, and
  qualify a third-party class whose bare name another recorded class shares,
  so the Extractor frame types read scapy.packet.Packet | dpkt.dpkt.Packet |
  pyshark.packet.packet.Packet (#1918).
- Name a class from a package with no usable inventory by a literal instead
  of an unresolvable role, keeping aenum's exported name (#1920).
- Add a tests/project unit test per issue, update the #1858 formatter test,
  and name the new gated classes in tests/_dependency_gates.py.

Closes #1917
Closes #1918
Refs #1920
@JarryShaw JarryShaw added docs Pull requests that change documentation only (docs: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 19, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at fe40b0382. A Sonnet cross-review traced the #1917 cause in the installed sources. Sphinx 9.1.0 _preserve_defaults.py:140-147 sets __signature__ on the wrapper, and sphinx-autodoc-typehints 3.15.0 _objects.py:39-42 stops unwrapping there. Priority 700 runs after both default-value handlers. format_class is order-independent, and it never qualifies pcapkit's own classes. Every newly qualified Dumper is dictdumper's. Restoring conf.py from main breaks the new tests, and the four docs-test modules pass under the pinned venv. Like the other HAS_SPHINX tests, these run only where the docs dependencies are installed, because no CI job runs tests with them.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 19, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Coverage: 90.07% (unit tier, Python 3.15, fe40b0382, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 2 20 2 96.77%
pcapkit/const 19595 881 2618 867 92.11%
pcapkit/corekit 2504 70 792 36 96.54%
pcapkit/dumpkit 276 3 100 3 98.40%
pcapkit/foundation 2916 164 1016 34 93.59%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17411 224 4580 189 98.10%
pcapkit/toolkit 872 177 298 8 77.18%
pcapkit/utilities 522 2 158 4 99.12%
pcapkit/vendor 4431 2341 1018 156 43.64%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit db45e24 into main Oct 19, 2026
90 of 92 checks passed
@JarryShaw
JarryShaw deleted the docs/1917-conf-typehints branch October 19, 2026 14:59
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 19, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 19, 2026
JarryShaw added a commit that referenced this pull request Oct 19, 2026
- Restate the test's docstrings as what each check asserts, and rename
  test_no_dead_target_comes_back to test_no_dead_target_appears.
- Demote the pcapkit.vendor.__main__.run cite in vendor/default.py to a
  literal beside the documented module; the CLI module documents no functions.
- Scan pcapkit/vendor/ apart from the two templates still carrying aenum
  roles, and pin pcapkit.vendor.__main__.run as a dead target.
- Scan docs/source/conf.py too: its class formatter now writes literals for
  packages outside intersphinx_mapping (#1929), and its source has no such role.

Closes #1919
Refs #1920
JarryShaw added a commit that referenced this pull request Oct 19, 2026
…1920) (#1928)

* 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

* docs: state the #1919 test's checks without timed context (#1919)

- Restate the test's docstrings as what each check asserts, and rename
  test_no_dead_target_comes_back to test_no_dead_target_appears.
- Demote the pcapkit.vendor.__main__.run cite in vendor/default.py to a
  literal beside the documented module; the CLI module documents no functions.
- Scan pcapkit/vendor/ apart from the two templates still carrying aenum
  roles, and pin pcapkit.vendor.__main__.run as a dead target.
- Scan docs/source/conf.py too: its class formatter now writes literals for
  packages outside intersphinx_mapping (#1929), and its source has no such role.

Closes #1919
Refs #1920
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Pull requests that change documentation only (docs: subject prefix)

Projects

Status: Done

1 participant