Skip to content

docs(foundation): document the engine members on EngineBase, not Engine (#1024) - #1027

Merged
JarryShaw merged 1 commit into
mainfrom
docs/1024-enginebase-docs-shape
Oct 5, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
docs/1024-enginebase-docs-shape

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

  • Searched for similar pull requests
  • Followed the coding style (make pylint, make mypy, make isort)
  • make test passes, and a test case covers the change — not ticked honestly. This is documentation shape, so no test case covers it; the proof is a nitpicky Sphinx build, below. tests/project (268 passed, 864 subtests) and tests/foundation (265 passed, 418 subtests) both pass. The full suite was not run: it needs ~29 GB here and gets OOM-killed.
  • Added a changelog entry under docs/source/changelog/ and regenerated CHANGELOG.md

What is the purpose of your pull request?

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • chore — anything else

Description of your pull request and other information

Closes #1024. #1023 narrowed Extractor.engine's return type to EngineBase, but that class was documented under Internal Definitions with :no-members:, so a public property declared a type whose own page exposed no API.

This takes the issue's option 1: the member stubs move onto EngineBase, and Engine keeps only __init_subclass__ — the single member #1023 measured it adds. Option 2, exporting EngineBase in __all__, is deliberately not here; the issue binds that to #1016 as a real API decision.

Also folded in: the verbless sentence at pcapkit/foundation/engines/pcap.py:98-101, and the four _exeng docstring cross-references in extraction.py repointed from Engine.* to EngineBase.* — legal only because option 1 removes the :no-members: obstacle that previously blocked it.

Measured with sphinx -b html -n, because conf.py does not set nitpicky and the default build is silent about unresolved references. Unresolved references go from 1239 on main to 1237 here. Two are genuinely fixed: docs/source/index.rst:151 and :355 reference EngineBase.unsupported_reason, unresolvable on main precisely because of :no-members:. The one apparent new entry is the identical pre-existing annotation warning relocated from engine.rst:39 to :45 by the directive move, same target text.

One real regression was caught this way and fixed in the same commit: engine.py:268 carried a bare :attr:engine_name``, which resolved against Engine before and missed once the attribute moved. It is now qualified explicitly.

@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 5, 2026
…ne (#1024)

`Extractor.engine` is declared `EngineBase[_P]` since #1023, but `EngineBase`
was documented `:no-members:` under Internal Definitions while `Engine`
carried every member stub, so the type a reader followed exposed no API.

* `engine.rst`: the member stubs move to `EngineBase`, where they are
  defined; `Engine` documents only `__init_subclass__` and keeps the
  customisation `seealso`. `EngineBase` is not added to `__all__` -- that is
  left to #1016.
* Cross-references to `Engine.run`, `read_frame`, `close` and
  `unsupported_reason` (`pep.rst`, `engines/index.rst`, four `_exeng`
  docstrings in `extraction.py`) now point at `EngineBase`, where they resolve.
* `Engine.__init_subclass__`: qualify the bare `__engine_name__` reference,
  which stopped resolving once the attribute moved to `EngineBase`.
* `PCAP.run`: repair the verbless "will also be save the current `PCAP`
  engine instance", as #1023 did in `extraction.py`.
* Changelog entry added; the entry-count pin in `process.rst` is 157.

Also corrected `docs/source/contributing/pep.rst`, which said subclassing an
engine registers it automatically. Registration has been opt-in since #514:
`__init_subclass__` registers only when the `engine` class keyword is given,
and defaults to skipping. Measured -- a subclass without the keyword adds
nothing to `Extractor.__engine__`; with it, the name appears.
Nitpicky Sphinx build: 1239 unresolved references on fa3e861, 1237 here.
The two `EngineBase.unsupported_reason` references in `docs/source/index.rst`
newly resolve; no new miss. tests/project passes.
@JarryShaw
JarryShaw force-pushed the docs/1024-enginebase-docs-shape branch from 8ae0d5e to 983fb92 Compare October 5, 2026 07:48
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on 8ae0d5eed: NEEDS CHANGES (ran on Opus; the change was authored on Sonnet). Both defects were mine rather than the author's, and both are fixed in 983fb92a0, now pushed.

1. A new C0301 broke the make pylint box this body ticks. The qualified reference at pcapkit/foundation/engines/engine.py:268 was 134 chars against --max-line-length=120 (Makefile:166, with format enabled and line-too-long not disabled). I verified it with the repo's exact flags rather than taking the report:

tree pylint on engine.py rating
fa3e861f5 3 messages (2x W0223, 1x W1113) 9.46/10
8ae0d5eed 4 — adds C0301: Line too long (134/120) 9.29/10
983fb92a0 back to the same 3 9.46/10

My own fault twice over: I dictated that exact one-line replacement, and my first re-measurement passed the flag string unquoted, which zsh hands over as a single argument, so pylint silently used its default 100-char limit and flagged a pre-existing 107-char line. Re-ran with an array before concluding anything.

2. The commit message's Sphinx count was wrong and self-contradictory. It read 1238, where 1239 − 2 fixed − 0 new = 1237. The body was always right. I supplied the 1238: it was my interim figure on the previous revision, measured before the :268 qualification itself removed one more miss.

Also folded in, after measuring it. docs/source/contributing/pep.rst said subclassing an engine registers it automatically. False since #514 — a subclass without the engine class keyword adds nothing to Extractor.__engine__; with it, the name appears. That sentence is one this change already edits.

Deliberately not folded in. engine.py:269-270 references EngineMeta.name, which does not resolve because engine.rst documents EngineMeta with :no-members:. EngineMeta.name is a genuine property distinct from EngineBase.name, so the reference is correct and only its autodoc coverage is missing; fixing it means documenting the metaclass's members, which is scope creep. Filing separately.

Re-measured on 983fb92a0: nitpicky references 1239 → 1237, zero new misses by target, two fixed. tests/project 268 passed, 1 skipped, 864 subtests. Resetting review: since the head moved.

@JarryShaw JarryShaw added review: pending No verdict for the current head - never reviewed, or the head moved since the last one review: running A cross-review is in flight against the current head - no verdict yet and removed review: running A cross-review is in flight against the current head - no verdict yet review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 5, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on 983fb92a0: GOOD TO GO (ran on Opus; authored on Sonnet). Both earlier defects are fixed and independently re-derived.

First, correcting my own previous comment. I wrote that the new C0301 "broke the make pylint box". That overstates it, and the review caught me: the gate was not clean to begin with. pcapkit/foundation/extraction.py already emits three C0301 on main — measured with the repo's exact flags at fa3e861f5:

extraction.py:461:0: C0301: Line too long (123/120)
extraction.py:811:0: C0301: Line too long (123/120)
extraction.py:1047:0: C0301: Line too long (123/120)

So the defect was adding a fourth to a noisy baseline, not turning a green gate red. It was still real and is gone: engine.py is back to exactly its three pre-existing messages and 9.46/10, at parity with base.

Re-verified on 983fb92a0:

check result
pylint on engine.py 3 messages, 9.46/10 — identical to fa3e861f5
pylint on extraction.py 3 C0301, identical base vs head
nitpicky references 1239 base → 1237 head, zero new misses, 2 fixed
the wrapped :attr: role renders as one xref, not split literal text; anchor present
pep.rst claim re-measured independently: no engine= keyword adds nothing to Extractor.__engine__; with it the name appears
tests/project 268 passed, 1 skipped, 864 subtests

Two method notes worth recording, since both nearly produced false results. The relocation trap has a second layer: normalising only the file line number still leaves docstring-relative offsets, so abc.ABCMeta.__new__ at :32→:34 (my two-line wrap) showed as a spurious new-plus-fixed pair until every :<digits>: field was blanked. And the comparison must use a fresh output directory, because an incremental Sphinx build only re-emits warnings for changed files and would fake a clean result.

On EngineMeta.name, which I am still filing rather than fixing here: the review agrees the reference is not mis-aimed — EngineMeta.name and EngineBase.name are two distinct properties and the class-level one is right inside __init_subclass__. It offers a third option I had not considered, for the issue rather than this pull request: repointing to EngineBase.name, which already resolves and whose own note covers exactly what the sentence is about. That is a one-target change rather than scope expansion, so it belongs in the filed issue as the likely fix.

@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 5, 2026
@JarryShaw
JarryShaw merged commit aa5f012 into main Oct 5, 2026
73 checks passed
@JarryShaw
JarryShaw deleted the docs/1024-enginebase-docs-shape branch October 5, 2026 10:50
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 5, 2026
JarryShaw added a commit that referenced this pull request Oct 5, 2026
`process.rst:104` pinned 157 entries while the file holds 158, so
`tests/project` was failing on `main`.

* #1020 and #1027 each measured 157 against a 156-entry base, which was
  correct for each branch alone. Merging both added two entries and left the
  pin behind -- the parallel-branch collision the page's own "measure, never
  increment" rule exists to prevent, landing for the first time.

Measured rather than incremented: `grep -cE '^\* '
docs/source/changelog/1.5.0.rst` gives 158.

tests/project: 268 passed, 1 skipped, 864 subtests passed. The failing test
was test_the_page_pins_its_own_measured_numbers.
@JarryShaw JarryShaw added this to the 1.5 milestone Oct 6, 2026
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

Development

Successfully merging this pull request may close these issues.

EngineBase is excluded from __all__ and documented :no-members:, so a public return type will expose no API

1 participant