fix(analyse): anchor newline-terminated one-line markers to comment start (#88)#89
fix(analyse): anchor newline-terminated one-line markers to comment start (#88)#89ubmarco wants to merge 1 commit into
Conversation
…tart (#88) The one-line marker scanner located the start sequence with ``str.find``, matching it anywhere in the comment. When the sequence (default ``@``) appeared inside free-form prose followed by a comma, the text was mis-parsed as ``title, id, ...`` and the bogus id (containing spaces/specials) later failed the sphinx-needs id regex with ``InvalidNeedException``. Anchor markers whose ``end_sequence`` is the newline (i.e. they extend to the end of the line) to the start of the comment content: only comment decoration (``//``, ``#``, ``*`` ...) and whitespace may precede the start sequence. An alphanumeric char before it means the sequence is prose and the line is ignored. Explicitly-bounded markers (e.g. ``[[ ... ]]``) are self-delimiting and stay position-independent.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #89 +/- ##
==========================================
+ Coverage 91.40% 91.44% +0.04%
==========================================
Files 34 34
Lines 3012 3027 +15
Branches 322 323 +1
==========================================
+ Hits 2753 2768 +15
Misses 160 160
Partials 99 99 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Correct, well-tested, and merge-ready. One backwards-incompatible behavior change worth a changelog note; the rest are minor. The guard is well-placed — right after Backwards-compat (intended, but please note in the release notes)For newline-terminated styles (the default The drop is silent — Correctness — verified
Minor
No outstanding review comments to address. |
Problem
Fixes #88.
The one-line marker scanner locates the start sequence with
str.find, so itmatches the sequence (default
@) anywhere in a comment. When@appearsinside free-form prose followed by a comma, the text is mis-parsed as
title, id, …and the bogus id (with spaces/specials) later fails thesphinx-needs id regex with
InvalidNeedException:Fix
Anchor markers whose
end_sequenceis the newline (i.e. they run toend-of-line) to the start of the comment content: only comment decoration
(
//,#,*,///,//!, …) and whitespace may precede the start sequence.A word character before it means the sequence is prose, and the line is ignored.
Explicitly-bounded markers (e.g.
[[ … ]]) are self-delimiting, so they stayposition-independent and may still be embedded after prose — this is what keeps
the recommended bracket-style workaround (and the existing
supercharge.cppfixture) working.
Tests
(line-comment, indented, block
*,///,//!) still parse; a bounded[[ … ]]marker embedded after prose still parses.Consistency with ubCode
The same fix lands in ubCode so both implementations recognise one-line markers
identically: useblocks/ubcode#2167.
Workaround (no upgrade required)
Switch the affected project to a self-delimiting bracket style, which does not
collide with
@in prose: