Repository navigation
✨ sphinx-codelinks: a reference marker can name its own field, and markers match whole words - #2499
Merged
Merged
Conversation
…n the line, and a marker matches a whole word
…s entries are a string or a { marker, field } table
…record; build tests for a field per marker
…er is found, and coming from Doxygen
…arker matching extracted (env_version 4)
…f a marker's boundary and for every match's columns
…rn URLs on in the Doxygen recipe, and say exactly which lines extract as before
…after a marker and before the first match
…k links, and leave the link type intact
…at the word characters follow the running Python's Unicode tables
Documentation build overview
10 files changed ·
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2499 +/- ##
==========================================
+ Coverage 95.00% 95.03% +0.03%
==========================================
Files 158 158
Lines 30357 30471 +114
==========================================
+ Hits 28840 28959 +119
+ Misses 1517 1512 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
packages/sphinx-codelinks: a need-ID reference marker can name the field its references go to.An entry of
analyse.need_id_refs.markersis a string, as before (its references go to the project'sref_url_field),or a table
{ marker = "\\satisfies", field = "impl_url" }(a dict inconf.py).So one source tree fills
impl_urlandtest_urlon the requirements it references;field = ""attaches a marker's references nowhere (codelinks analysestill lists them).Configuration checks, one helper for
ref_url_fieldand every table field, applied where the field can be written(URL generation on, and the field used:
ref_url_fieldwhile a plain-string marker exists, or a non-empty table field):not a URL field, not a need link type, and not the back links of one (
verifies_back).A marker listed twice, in any form, is refused.
Two behaviour changes follow, both in the changelog:
a
ref_url_fieldnaming a link type was accepted and is now an error;a field named after a declared link type's back links used to switch that link type off with warnings only, and is now an error that leaves the link type intact.
One check is relaxed: a
ref_url_fieldequal to a URL field in a project that writes no reference (no plain marker, or URLs off) now loads.Marker matching. With a field per marker, the old matching misattributed, so it is fixed:
\satisfies REQ_1 \verifies REQ_2gave\satisfiesthe idsREQ_1,\verifies,REQ_2, so REQ_2 landed in both fields;_matches only where no letter, digit or_follows: with marker\verifies,\verifiesall REQ_2gave a reference toall;_; the same rule decides the existing reference-line test (nothing alphanumeric before the line's first match).A line extracts as before when exactly one configured marker occurs in its text, once, and that marker does not end in a letter, digit or
_that a letter, digit or_directly follows.Every existing extraction snapshot is unchanged; ten cases are added to the shared corpus
tests/data/extraction/need_refs.yaml.env_versiongoes from 3 to 4, so the first build after upgrading re-reads every document rather than keep references the old rule extracted.Docs: the table form and the field checks in
components/configuration.rst; "How a marker is found" and a short "Coming from Doxygen" recipe (markers for\satisfies/\verifies, URL generation on,start_sequence = "@@"so a Doxygen@param a, bline is not a one-line need, and what the recipe does not do) incomponents/analyse.rst; the changelog under Unreleased.Why
Teams moving from Doxygen write
\satisfiesand\verifieson documented entities.They want "where is REQ_1 implemented" and "where is it tested" as two fields on the requirement, and a filter for the requirements no test verifies (
type == "req" and not test_url).Today every marker of a project writes the one
ref_url_field, so the only route was two projects over the same tree.The shared extraction corpus keeps another implementation of the same rules in agreement.
Tests
tests/test_need_id_refs_matching.py: every clause of the matching rule (the boundary with_, ASCII and non-ASCII digits and letters, a circled letter or combining mark that is not one, punctuation; the longest marker in either configuration order; no overlap; ids ending at the next match;*/removed from the last segment only; the same marker twice; the reference-line test), and that a one-occurrence line extracts as the old rule did.need_refs-two_markers_one_line,-same_marker_twice,-marker_word_boundary,-longest_marker_wins,-longest_marker_wins_at_one_position,-two_markers_block_comment_end,-marker_ends_in_punctuation,-other_alphabetic_after_marker,-second_match_after_multibyte,-digit_after_marker).tests/test_need_id_refs_marker_fields.py: string, table and mixed forms; malformed tables;field = ""; duplicates in three forms; a field equal to the URL fields, naming a link type, or naming a link type's back links (withref_url_fieldtoo); where the checks apply (URLs off, tables only, local URLs only); field registration.tests/test_need_id_refs_marker_fields_build.py: Sphinx builds fillingimpl_urlandtest_urlfrom one tree beside a plain marker going toref_url_field;field = ""making no record; theconf.pydict form; an incremental build moving a reference fromimpl_urltotest_url; a declaredverifieslink staying intact next to averifies_backfield; an environment pickled atenv_version3 being discarded.field = ""attaching, the duplicate check off, the link-type check off, ids to the end of the line, no word boundary, the first marker winning over the longest, one match per marker, byte columns for a second match, the checks applied unconditionally, digits not word characters, the back-link refusal off: each turns at least one test red.Checklist
uv run poe test-<package>) and they pass.uv run poe test-codelinks -n 4: 2133 passed, 3 skipped (permission checks that do not apply as root).components/configuration.rstandcomponents/analyse.rst;uv run poe docs-codelinkssucceeds.docs/changelog.rsthas an entry under Unreleased. A ✨ entry for the field per marker and a 🐛 entry for the matching, each naming its behaviour changes.uv run poe lintanduv run poe typecheckpass. Both exit 0.