pacak / bpaf

Command line parser with applicative interface
337 stars 17 forks source link

`bpaf_derive`: use `trim_start` in `doc_comment` parser? #330

Open bzm3r opened 7 months ago

bzm3r commented 7 months ago

We have at the moment:

https://github.com/pacak/bpaf/blob/49b712770d86052780f485741d7c4e644bf1513d/bpaf_derive/src/utils.rs#L68-L70

Should this just be replaced with a call to trim_start?

(I am happy to implement this, if it makes sense.)

pacak commented 7 months ago

This part preprocesses the comment block changing it from

/// xxx
/// yyyy

giving you back "xxx" and "yyy".

But this preserves spaces past the first one so /// xxx is " xxx". The intention is that a single space is used to format doc comments normally while more spaces are used for more format options - extra single space lets you to force a line break, etc. I'm pretty sure I have this behavior documented somewhere but I can't find it...

I guess we can use strip_prefix to remove that single space and make the behavior clearer in the documentation.... Feel free to do the strip_prefix change, as for the documentation - I have something in work already, it's just needs to be split into smaller chunks, cleaned up and merged... If you want to help here - that would be great.