Closed Ririshi closed 1 year ago
Hi @Ririshi,
We're glad to hear that you're enjoying Tap! Thank you for the comprehensive issue! We currently do have an option for providing multiline comments in order to avoid long lines. Specifically, you can use triple quotes on the line following an argument to write a comment that will be converted to a help string for that argument. You can see an example in the README here: https://github.com/swansonk14/typed-argument-parser#tap-help
Please feel free to reopen the issue and let us know if there is another use case that is not addressed by this solution.
Best, Jesse and Kyle
I'm using TAP for almost every script I write and something that is bothering me is that I cannot easily place help texts using comments when the line gets long because of a argument name, type name or default value. Specifically, I use Black for formatting, which breaks the default value into multiple lines, and the comment is placed on the last line, behind the parenthesis (
ExampleOne
parser in the code below).I could manually move the comment back to the argument name's line, just behind the opening parenthesis (
ExampleTwo
), but this line is oftentimes quite long already because of the argument and type name. The comment still ends up exceeding the recommended maximum of 88 characters in those cases. Black then reformats it again to look likeExampleThree
. To solve this, I would like TAP to pick up a comment behind the closing parenthesis and use it as its help text. This way, it's compatible with Black formatting.Having the option of placing the comment on the line above the argument (
ExampleFour
) would be nice as well.Finally, some arguments might require some more extensive explanation, requiring multiple comment lines (especially when limiting each line to 88 characters). It would be nice if support was added for this. This would work well if comments were allowed above the argument in question, but it might also work for multi-line comments that start behind a closing parenthesis (if one exists).
There would need to be some kind of order of precedence for comments if multiple are added. For this, I propose the following order:
My reasoning behind this order is that most short comments will fit on the same line. The next option is on the line above, because that leads (imo) to best readability in the code if the comment cannot be placed on the same line as the argument name. The third option works well for developers who place the comment on the same line and then use Black or some other formatting tool which automatically puts the comment behind the closing parenthesis.