docs(sphinx): add opt-in issue, pr and discussion roles and convert the conventions pages - #998
Conversation
…the conventions pages Closes nothing yet; the first tranche of #989. A bare ``#NNN`` renders as literal text, so every tracker citation in the built documentation is unclickable. The roles are deliberately opt-in per site rather than an automatic ``#NNN`` rule, because no digit-keyed pattern separates a citation from a packet-diagram label. ``#\d{3}`` already misses 17 two-digit citations that are real, and ``#\d+`` would catch the 45 one-digit RFC diagram labels in pcapkit/protocols/internet/hip.py and pcapkit/protocols/transport/sctp.py (``DH GROUP ID #1``, ``Gap Ack Block #1``), which reference nothing. A role nobody writes cannot corrupt them. ``:issue:`` and ``:pr:`` both caption ``#%s``, so converting a bare citation or an explicit link changes the markup and not the rendered text. Six sites were inline literals and are the exception: ``#934``, ``#949`` and ``#911`` in documentation.rst and ``#759``, ``#805`` and ``#775`` in process.rst rendered as monospace and now render as links in body font. They are separate roles because the issue-versus-pull-request distinction is itself a documented convention and one role would flatten it in the source. ``:discussion:`` exists because the repository has five GitHub Discussions -- 105, 106, 127, 251 and 274 -- for which the issues API returns 404, so ``:issue:`` would render a dead link. Scope, measured rather than taken from the issue: 895 bare citations sit on the surface Sphinx actually renders, which is docs/**/*.rst plus pcapkit/ docstrings and ``#:`` comments. All 1,580 autodoc directives target pcapkit.* and there is no literalinclude, so tests/, util/ and examples/ never reach a page and their citations cannot fail to resolve. 420 of the 895 are actionable; the other 475 are under docs/source/changelog, which #657 owns and util/changelog_md.py generates. This tranche converts 78 sites across the seven conventions pages -- 45 explicit links collapsed, 6 inline literals, 27 bare. All 33 distinct numbers were resolved in one GraphQL issueOrPullRequest call and every one is an issue, so :issue: is correct at each site; the collapsed links asserted label == URL number, so every rendered URL is byte-identical to before. Two tests pinned the bare ``#NNN`` source form and this change reddens both. test_conventions_doc_claims.py's floor now counts explicit links and role citations together, keeping the pairwise label-versus-URL comparison over whatever explicit links remain. test_sentinel_exports_unit.py accepts the citation in either markup form. Both were checked against the old page, where the pre-change assertions fail, so neither is vacuous. Verified: Sphinx 9.1.0 builds with exit code 0, the documented root printed and confirmed inside the worktree, 78 rendered /issues/NNN anchors matching the 78 conversions, and no warning naming any conventions page. tests/project/ gives 258 passed, 1 skipped, 859 subtests; the page-reading corekit tests give 61 passed, 129 subtests. All exit codes read from the process. The conf.py comment also had three inaccuracies of its own, which a change about citation accuracy should not ship: it named two files for the 45 one-digit diagram labels where they live in three (internet/hip.py 36, transport/sctp.py 7, schema/internet/hip.py 2); it said ``#\d{3}`` misses four-digit numbers "now arriving" when there are none yet, and omitted the 17 two-digit ones it does miss; and it claimed rendering was unchanged without the inline-literal exception. The Sphinx build is unchanged against main: 61 warnings and 2 errors on both, no warning or error naming any conventions page, and no warning kind new to the branch. Both errors are pre-existing, in pcapkit/corekit/infoclass.py and pcapkit/protocols/schema/schema.py docstrings, neither of which this change touches.
5b99328 to
0681926
Compare
|
GOOD TO GO at The description claimed rendering was unchanged, and that was false for six sites. The On the build, the reviewer was right and my own check was the wrong instrument. I grepped the log for "conventions" and got 14 hits; all 14 are Re-verified at the new head: Sphinx exit 0 with the documented root confirmed inside the worktree, 78 rendered Two nits I am deliberately not acting on. The floor's pairwise label-versus-URL comparison now runs over an empty list, since no explicit links remain — so half that test is inert. The floor itself still catches regressions (reverting all 78 roles gives 0, reverting 38 gives 40, both failing), and raising its strictness from Label stays |
|
Delta round: GOOD TO GO at The build is identical to One wording nit I am deliberately leaving, with the measurement on the record. The comment says I am keeping it because the sentence is doing a different job from what the narrowing would imply. The point of that paragraph is that a digit-keyed pattern is the wrong instrument in both directions — Label is now |
|
Ready to merge at One commit on Unpublished decisions are yours, and I have not merged. What is queued behind this, and why it is queued rather than in flight: the remaining 387 |
…irst use Adds two entries alongside the three added in #998, so that the citations these pages already carry as bare URLs have a role to convert to when that sweep reaches them. - `:wikipedia:` expands `https://en.wikipedia.org/wiki/%s`. 28 of the 34 distinct Wikipedia and Wikimedia URLs cited today are that shape, over 23 distinct articles -- `IPv6_packet` appears four times, differing only by fragment. Three cited URLs the template cannot express must stay hardcoded: a `/w/index.php?...&oldid=...` permalink, a `foundation.wikimedia.org` policy page in `pcapkit/vendor/default.py`, and an `http://` ARP link that a role would silently upgrade to `https`. - `:iana:` expands `https://www.iana.org/assignments/%s`, the argument being the path after `/assignments/`. All 179 distinct IANA URLs are that shape across 21 registries, so both a registry index and a specific table resolve through one role. A two-`%s` IANA template would be wrong: over the 108 distinct fragment-stripped paths, the file stem equals the registry name in only 20 -- the rest are per-table `.csv` files the vendor crawlers read -- and Python's `%` takes one argument, so the second placeholder raises at role-expansion time rather than degrading. Both captions are `%s`, not `#%s`, because the argument is a slug or path rather than a number; prose should use the explicit-title form, since a bare caption renders the raw path as visible text. Neither role is cited yet, by design, per the ruling on #989. Verified: both roles render to the expected hrefs with the fragment and both IANA shapes intact; docs build exit 0 with 61 warnings / 2 errors, unchanged from the baseline, and 0 unknown-role errors; `tests/project` 258 passed, 1 skipped, 859 subtests.
…irst use Adds two entries alongside the three added in #998, so that the citations these pages already carry as bare URLs have a role to convert to when that sweep reaches them. - `:wikipedia:` expands `https://en.wikipedia.org/wiki/%s`. 28 of the 31 distinct `wikipedia.org`/`wikimedia.org` URLs cited today are that shape, over 23 distinct articles -- `IPv6_packet` appears four times, differing only by fragment. The other three must stay hardcoded: a `/w/index.php?...&oldid=...` permalink, a `foundation.wikimedia.org` policy page in `pcapkit/vendor/default.py`, and an `http://` ARP link that a role would silently upgrade to `https`. - `:iana:` expands `https://www.iana.org/assignments/%s`, the argument being the path after `/assignments/`. All 179 distinct IANA URLs are that shape across 21 registries, so both a registry index and a specific table resolve through one role. A two-`%s` IANA template would be wrong: over the 108 distinct fragment-stripped paths, the file stem equals the registry name in only 20 -- the rest are per-table `.csv` files the vendor crawlers read -- and Python's `%` takes one argument, so the second placeholder raises at role-expansion time rather than degrading. Both captions are `%s`, not `#%s`, because the argument is a slug or path rather than a number; prose should use the explicit-title form, since a bare caption renders the raw path as visible text. Neither role is cited yet, by design, per the ruling on #989. Verified: both roles render to the expected hrefs with the fragment and both IANA shapes intact; docs build exit 0 with 61 warnings / 2 errors, unchanged from the baseline, and 0 unknown-role errors; `tests/project` 258 passed, 1 skipped, 859 subtests.
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changedocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingchore— anything elseFirst tranche of #989.
Description of your pull request and other information
A bare
#NNNrenders as literal text, so every tracker citation in the built documentation is unclickable. This addssphinx.ext.extlinkswith:issue:,:pr:and:discussion:roles, and converts the seven conventions pages.The roles are opt-in per site, not an automatic
#NNNrule, because no digit-keyed pattern separates a citation from a packet-diagram label.#\d{3}already misses 17 two-digit citations that are real, and#\d+would catch the 45 one-digit RFC diagram labels inpcapkit/protocols/internet/hip.pyandpcapkit/protocols/transport/sctp.py—DH GROUP ID #1,Gap Ack Block #1— which reference nothing. A role nobody writes cannot corrupt them.:issue:and:pr:both caption#%s, so converting a bare citation or an explicit link changes the markup and not the rendered text. Six sites were inline literals and are the exception —#934,#949and#911indocumentation.rst,#759,#805and#775inprocess.rst— which rendered as monospace and now render as links in body font. They are separate roles because the issue-versus-pull-request distinction is itself a documented convention and one role would flatten it in the source.:discussion:exists because the repository has five GitHub Discussions — 105, 106, 127, 251 and 274 — for which the issues API returns 404, so:issue:on one would render a dead link.Scope, measured rather than taken from the issue. 895 bare citations sit on the surface Sphinx actually renders:
docs/**/*.rstpluspcapkit/docstrings and#:comments. All 1,580 autodoc directives targetpcapkit.*and there is noliteralinclude, sotests/,util/andexamples/never reach a page and their citations cannot fail to resolve — which is why the issue's earlier figure of ~1,858 overstated the rendered surface about 4.4×, 1,563 of it beingtests/. 420 of the 895 are actionable; the other 475 are underdocs/source/changelog, which #657 owns andutil/changelog_md.pygenerates.This tranche converts 78 sites — 45 explicit links collapsed, 6 inline literals, 27 bare. All 33 distinct numbers resolved in one GraphQL
issueOrPullRequestcall and every one is an issue, so:issue:is correct at each site; the collapsed links asserted label == URL number, so every rendered URL is byte-identical to before.Two tests pinned the bare
#NNNsource form and this change reddens both.test_conventions_doc_claims.py's floor now counts explicit links and role citations together, keeping the pairwise label-versus-URL comparison over whatever explicit links remain.test_sentinel_exports_unit.pyaccepts the citation in either markup form. Neither is vacuous: run the pre-change assertions against the new pages and they fail.Verified — Sphinx 9.1.0 exits 0 with the documented root confirmed inside the worktree, 78 rendered
/issues/NNNanchors matching the 78 conversions, no warning naming any conventions page;tests/project/gives 258 passed, 1 skipped, 859 subtests; the page-reading corekit tests give 61 passed, 129 subtests. All exit codes read from the process.Left for the follow-up: 387
pcapkit/sites across 69 files, the 475 changelog sites (which contain the only two bare Discussion citations, #106 and #251 — a blind:issue:pass there would create dead links), and the:iana:role, which turns out never to have been committed.