Allow multiple parameters in lines of long parameter lists #11423
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.
Subject: Enables multiline parameter lists in which each line may contain more than one parameter.
Feature or Bugfix
Feature
Purpose
Following @picnixz' comment and previous discussion in #1514, when one has just a few very long parameter names and others which are very short, rather than breaking on every parameter, they may prefer to have multiple parameters on the same line --- as long as each line stays under a reasonable length.
Detail
Adds a new configuration variable, globally and per domain (for now I just implemented Python's
python_single_param_per_line_in_multiline_signatures
), which, when set to True, enables the behaviour implemented in #11011, that is to have one parameter per line, and when set to False, to rather have multiple parameters per line if they fit the line length given bymaximum_signature_line_length
, as suggested by @picnixz and others.Here's what the following rst:
would compile to with what I have now:
Most of the work is done when adding parameter nodes for a domain's object, I pass a
on_new_line
attribute to the parameter nodes that should be displayed on a new line. Then thanks to what we already have from #11011 it's not too much work to implement it in the writers.There seems to be interest for this feature, so since it's not so hard to implement I thought I'd open this PR for discussion. I'll complement with tests, docs and coverage of other domains if there's agreement to move this forward. (Ah and currently the tests I wrote for #11011 will fail for an extra space after commas.)
Relates
#11011 #1514