mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-24 05:17:15 +00:00
Avoid treating newline-separated sections as sub-sections (#15311)
## Summary Closes https://github.com/astral-sh/ruff/issues/15224.
This commit is contained in:
parent
065274d353
commit
e7248ee43e
7 changed files with 121 additions and 58 deletions
|
|
@ -528,6 +528,22 @@ fn is_docstring_section(
|
|||
}
|
||||
}
|
||||
|
||||
// If the section has a preceding empty line, assume it's _not_ a subsection, as in:
|
||||
// ```python
|
||||
// def func(args: tuple[int]):
|
||||
// """Toggle the gizmo.
|
||||
//
|
||||
// Args:
|
||||
// args: The arguments to the function.
|
||||
//
|
||||
// returns:
|
||||
// The return value of the function.
|
||||
// """
|
||||
// ```
|
||||
if previous_line.map_or(false, |line| line.trim().is_empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the section isn't underlined, and isn't title-cased, assume it's a subsection,
|
||||
// as in:
|
||||
// ```python
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue