Repository navigation
Python: fix(core): ensure proper section spacing and argument grouping in build_layered_docstring - #8691
Conversation
…ld_layered_docstring Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
|
Thank you for proposing this change. I am closing this PR for now because it has no linked issue, and I could not find an issue covering this specific problem. Our contribution guidelines ask contributors to create or reuse an issue and discuss the approach before nontrivial changes (with an exception for trivial changes). The repository PR template asks for Motivation & Context, Description & Review Guide, a Related Issue linked with a closing keyword such as |
When inspecting docstrings generated by build_layered_docstring, I noticed two formatting inconsistencies with section separation:
First, when appending extra keyword arguments to an existing Keyword Args section, the new lines were inserted after the section trailing blank line instead of before it. This created an extra blank line in the middle of the Keyword Args list while removing the blank line before the subsequent section like Returns.
Second, when injecting a new Keyword Args section into a docstring that already had an Args section, an extra blank line was inserted preceding the Keyword Args header, producing multiple consecutive blank lines.
This PR updates build_layered_docstring so that new keyword arguments are appended directly to the end of the existing list before any trailing blank line, and newly created sections maintain standard single blank line separation from neighboring sections, matching the pattern in insert_docstring_block. I also updated test_docstrings.py with adjacency and spacing assertions.