Skip to content

docs: cross-reference the warning classes in Warns sections (#2094) - #2096

Merged
JarryShaw merged 1 commit into
mainfrom
docs/2094-warns-xrefs
Oct 23, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
docs/2094-warns-xrefs

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fixes

Description of your pull request and other information

Closes #2094. In napoleon (Sphinx 9.1.0), Warns: went through _format_fields and came out as :Warns: **Name** -- desc: bold, with no role, and with a ~ printed literally. Raises: instead becomes :raises Name:, which the Python domain links.

  • Fix: docs/source/conf.py's setup replaces GoogleDocstring._parse_warns_section, which the NumPy style inherits. Each name becomes :exc:`.Name`, which gets the same suffix search as Raises. A ~ prefix still shortens the title, and builtins resolve exactly through intersphinx. Comma lists are split; roles, literals and name (type) are left alone. No docstring changes.
  • Build: under the pinned docs env (from docs/requirements.txt, as in deploy-pages.yml), there are 0 warnings before and after. Of the 62 warning names in Warns sections, all are now links where all were plain text before.
  • Test: test_docs_warns_xrefs_2094_unit runs napoleon in both styles with the build's settings. It resolves each Warns name and its :raises: counterpart through the Python domain and checks they land on the same target. With conf.py reverted to main, 12 of its 15 tests fail. It needs Sphinx and the pinned sphinx-autodoc-typehints, and skips without them, like the other docs tests.

@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) 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 23, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 23, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 786712130 (Sonnet review).

  • Hook: the override keeps napoleon's own _consume_fields() and _format_fields(translate('Warns'), …), so labels, bullets and descriptions are unchanged. It rewrites only entries that have a name and no type. It is a plain class-attribute assignment, so running setup twice changes nothing, and it takes effect before any docstring is parsed.
  • Corpus: every Warns: name is bare or dotted, and each is defined only in pcapkit/utilities/warnings.py, so no suffix match is ambiguous. The leading dot sets the same refspecific that :raises: does.
  • Test: under a throwaway venv built from docs/requirements.txt it gives 9 passed with 6 subtests. With main's conf.py swapped in, 12 of 15 checks fail.
  • Correction to the review: it found no CI job that runs this test unskipped. That was wrong. Unit Tests' Project tests job installs .[…,docs,…] (Sphinx plus sphinx-autodoc-typehints==3.17.2) and runs the tests/project pins. On main that job reports only 5 skips, so the docs tests run there. That job installs Sphinx 9.2.0 rather than docs/requirements.txt's 9.1.0, and this PR's Project tests result will show whether the hook holds on 9.2.0.

@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 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.54% (unit tier, Python 3.15, 786712130, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19599 880 2618 866 92.12%
pcapkit/corekit 2565 71 812 37 96.56%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 2930 23 1022 25 98.79%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17414 219 4574 185 98.14%
pcapkit/toolkit 869 36 298 10 95.20%
pcapkit/utilities 473 7 136 5 98.03%
pcapkit/vendor 4432 1988 1018 167 51.87%

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

@JarryShaw
JarryShaw merged commit 0eb3d68 into main Oct 23, 2026
65 checks passed
@JarryShaw
JarryShaw deleted the docs/2094-warns-xrefs branch October 23, 2026 19:52
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 23, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 23, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issues reporting a defect (set by the bug report template; a default, not an assessment) docs Pull requests that change documentation only (docs: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

docs: Warns sections render warning classes without cross-reference links

1 participant