Skip to content

docs: keep the colon off the first line of an attribute's documentation (#2745) - #2746

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2745-doc-comment-first-line-colon
Nov 3, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2745-doc-comment-first-line-colon

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • docs — documentation only

Description of your pull request and other information

Napoleon reads a colon on the first line of a #: comment, or of a property docstring, as "type: description". The words before the colon render as a Type field and drop out of the prose, usually with no warning. Built at ab7be2fb0, the docs show 105 Type fields. With this change they show 59, all of them real types.

  • Every misread first line now keeps its colon off: " -- ", ". " or a comma, following docs: clear the API docs build's Sphinx warnings (#2743) #2744's two fixes, which are byte-identical here. The two :meth: roles that were split across lines now start on the second line.
  • Deliberate inline types (#: int: ...) and enum members (already restored by conf.py) are unchanged.
  • tests/project/test_doc_comment_first_line_2745_unit.py runs Napoleon's own handler with conf.py's settings over every attribute comment and property docstring. It fails on a type that is really prose.

Merge note: there is a one-line textual conflict with #2736 in the _OrderedMultiDict.__excluded__ comment. Whichever PR lands second rebases.

Closes #2745

@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 Nov 3, 2026
@github-actions github-actions Bot added this to the PyPCAPKit v1.6 milestone Nov 3, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 3, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 013f22b48, from a Sonnet review.

  • Clean-venv builds of non-editable installs show 105 Type fields at ab7be2fb0 and 59 here, every one of them a real type. No prose was lost.
  • About 50 rewordings were sampled across 25 files. Each keeps its meaning and does not reflow neighbouring lines.
  • The guard passes under Sphinx 9.1.0 and 9.2.0. It fails on a revert, and names exactly the attribute when one colon is put back. It is merge-clean with docs: clear the API docs build's Sphinx warnings (#2743) #2744. Project tests, Lint and deploy-pages pass.

Merge with #2736: the _OrderedMultiDict.__excluded__ conflict must keep #2736's longer text and put " -- " after "leave out". With the colon, this guard fails. Non-blocking: the guard calls Sphinx's private _process_docstring.

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

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Coverage: 94.45% (unit tier, Python 3.15, 013f22b48, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 21062 175 2914 156 98.58%
pcapkit/corekit 2861 76 916 37 96.80%
pcapkit/dumpkit 282 3 100 3 98.43%
pcapkit/foundation 3496 26 1214 32 98.77%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 22613 150 5862 123 99.03%
pcapkit/toolkit 961 26 342 8 96.62%
pcapkit/utilities 533 7 144 5 98.23%
pcapkit/vendor 5590 2286 1280 214 55.75%

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

…on (#2745)

Napoleon reads the first line of a #: doc comment, or of a property's
docstring, as Google's inline "type: description" form wherever a colon
outside a role or a literal has text after it. The text before the colon
rendered as a Type field and dropped out of the prose -- "Group address",
"Protocol Type", "What __proto__ is keyed by", "IGMP version this class
reads" -- and the build warned only where that text matched several
classes. Two lines split a role across lines, so the colon of :meth:
itself was taken and the rendered page carried a second Type, "meth".

Each misread line keeps its colon off the first line: " -- ", ". ", or a
comma, as each IGMP version property's alias docstring already reads, and
the two split roles start on the second line. The IGMPv3 Query.checksum
and DTLS reassembler __protocol_type__ lines are byte-identical to #2744's
fix of the same two. Comments napoleon would misread that the docs do not
render yet are reworded too; inline types written on purpose
("int: Frame counter.") and enum members, which conf.py's
restore_enum_member_docstring already restores, are left alone.

tests/project/test_doc_comment_first_line_2745_unit.py runs napoleon's own
autodoc-process-docstring handler, under conf.py's napoleon settings, over
every attribute comment Sphinx's ModuleAnalyzer finds and every property
docstring under pcapkit/, and fails on a type that is prose rather than a
type expression.

Build: 105 rendered Type fields before, 59 after, all real types; warnings
6 before, 4 after, the 4 that #2744 clears (sphinx-autodoc-typehints
3.17.2).
@JarryShaw
JarryShaw force-pushed the fix/2745-doc-comment-first-line-colon branch from 013f22b to 53804e5 Compare November 3, 2026 16:33
@JarryShaw

Copy link
Copy Markdown
Owner Author

Rebased onto main 6ae240d33 after #2736 merged: 013f22b48 → 53804e587 (patch-id 0f9c3a347a93 → 9af10b2cff66).

GOOD TO GO carries over; apart from these two comment lines the diff is identical.

@JarryShaw
JarryShaw merged commit dea098b into main Nov 3, 2026
15 checks passed
@JarryShaw
JarryShaw deleted the fix/2745-doc-comment-first-line-colon branch November 3, 2026 16:34
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 3, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 3, 2026
JarryShaw added a commit that referenced this pull request Nov 3, 2026


- Breaking: a short CALIPSO, SMF_DPD or MPL Opt Data Len raises ProtocolError,
  where 1.5.x raised FieldValueError, and a cut after the type octet reads
  short (#2737), a new entry; AppType.__registries__ is an Info, into the
  #2734 entry (#2735).
- Changed: const packages import their enumerations lazily through
  pcapkit.utilities.lazy.lazy_exports (#2735); the docs extra pins
  sphinx-autodoc-typehints 3.17.4 (#2742), as 1.5.0 recorded its pin.
- Fixed: the dumps keep a field renamed for clashing with an Info builtin
  name (#2736).
- Folded: the GraalPy leg's timeout and shards into the CI-legs entry
  (#2741); the #2735 and #2737 rulings into the conventions entry.
- No entry for the docs-only #2744 and #2746.
- 1.6.0's :func:`bytes` role is :class:`bytes`, so the changelog pages build
  with no nitpicky warning. Old values measured against v1.5.1.
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
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.

docs: a doc comment whose first line has a colon renders its prose as a Type field

1 participant