Repository navigation
docstring_parser: read every style through Lines - #140
Merged
Merged
Conversation
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.
This was referenced Nov 7, 2026
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.
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 callingnormalize_line_endingsandcleandocitself, and Google's rule for a title on the first line becomesLines.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 parityandjust benchchecked it.