Skip to content

docstring_parser: read every style through Lines - #140

Merged
rr- merged 1 commit into
mainfrom
rework/2-lines
Nov 6, 2026
Merged

rr- merged 1 commit into
mainfrom
rework/2-lines

Conversation

@rr-

@rr- rr- commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Add _lines.Lines, which normalises line endings and dedents a docstring once and gives line numbers for offsets into it. Every parser starts from it instead of calling normalize_line_endings and cleandoc itself, and Google's rule for a title on the first line becomes Lines.with_lead().

The rules that were copied into each parser move to _text: splitting the short from the long description (four copies), adding loose text to the long description (two) and _clean_str (two).

No output changes (just parity), and speed is within noise.

Follows #139, whose just parity and just bench checked it.

@rr- rr- self-assigned this Nov 6, 2026
Add `_lines.Lines`, which normalises line endings and dedents a
docstring once, and gives line numbers and indents for offsets into the
dedented text. Every parser now starts from it instead of calling
`normalize_line_endings` and `cleandoc` itself, and Google's rule for a
title on the first line becomes `Lines.with_lead()`.

Move the rules that were copied into each parser to `_text`: splitting
the short from the long description (four copies), adding loose text to
the long description (two) and `_clean_str` (two). `common` keeps
`cleandoc` and `normalize_line_endings` importable.

No output changes: `just parity` finds no difference on 29,061
docstrings, and `just bench` is within noise.
@rr-
rr- merged commit 89a64d5 into main Nov 6, 2026
26 checks passed
@rr-
rr- deleted the rework/2-lines branch November 6, 2026 13:15
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.

1 participant