In a numpy-style Parameters section, an argument whose name matches a
section title keyword (e.g. "argument", "param", "key") was
misinterpreted as the start of a new Google-style Args section. The
argument was then dropped from the parsed docstring and its description
was appended to the previous argument, producing misaligned help text.
Numpy parameter lines have whitespace before the colon ("argument :
int"), while Google section headers do not ("Args:"), so treat such
lines inside a numpy section as parameters rather than section headers.
Fixes google#439
Fixes #439
Problem
With a numpy-style docstring, an argument whose name happens to match a section title keyword (argument, arg, param, parameter, key, ...) breaks help text alignment:
--help previously showed both descriptions under EXECUTABLE and nothing under ARGUMENT:
POSITIONAL ARGUMENTS EXECUTABLE Executable to run Positional argument to the executable ARGUMENTCause
Inside the numpy Parameters section, the line argument : sits at the same indentation as the section header, so _google_section_permitted allows it to start a new section, and _google_section matches argument against the Args section titles. The parser switches to a Google-style Args section, so the argument is never recorded and the following description line is appended to the previous argument.
Fix
Numpy parameter lines have whitespace before the colon (argument : int), while Google section headers do not (Args:). When the parser is inside a numpy-format section, a line whose colon is preceded by whitespace is now treated as a parameter definition rather than a new section header.
With the fix, --help shows:
POSITIONAL ARGUMENTS EXECUTABLE Executable to run ARGUMENT Positional argument to the executableAdded a regression test using the example from the issue. All existing docstring and helptext tests pass.