Skip to content

fix: do not split summary on a period inside an inline literal - #363

Open
Sanjays2402 wants to merge 1 commit into
PyCQA:masterfrom
Sanjays2402:fix/inline-literal-sentence-split
Open

fix: do not split summary on a period inside an inline literal#363
Sanjays2402 wants to merge 1 commit into
PyCQA:masterfrom
Sanjays2402:fix/inline-literal-sentence-split

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #353.

do_split_summary ended the summary at any token ending in ., so a docstring containing an inline literal like ``.. deprecated::`` was split in the middle of the literal, producing invalid reST. It now skips the sentence break while inside an unclosed inline literal (odd number of `` markers), mirroring the existing ABBREVIATIONS false-positive guard.

Regression test fails without the source change and passes with it; the rest of the suite is unchanged (same 10 pre-existing test_do_format_code failures before and after).

do_split_summary treated any token ending in '.' as the end of the
summary sentence, so a docstring containing an inline literal such as
``.. deprecated::`` was split in the middle of the literal, producing
invalid reST.

Track whether the text seen so far is inside an unclosed inline literal
(an odd number of double-backtick markers) and skip the sentence break
in that case, mirroring the existing ABBREVIATIONS false-positive guard.

Adds a regression test covering both a literal-only summary and a
literal followed by a genuine second sentence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False read . in code-block as sentence ending

1 participant