pacak / bpaf

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

Extra space in argument's rendered markdown #363

Open Boshen opened 3 months ago

Boshen commented 3 months ago

Rendered example:

image

Concrete example from test case codeblock_ticks_help:

https://github.com/pacak/bpaf/blob/a479b6b21e772f536f2961bc56d3e4fe93612d72/tests/markdown.rs#L245

After an hour of debugging I found it's inserting the space here https://github.com/pacak/bpaf/blob/a479b6b21e772f536f2961bc56d3e4fe93612d72/src/meta_help.rs#L510

but removing it will break everything else.

And I wasn't able to hack it in the markdown renderer, the input

https://github.com/pacak/bpaf/blob/a479b6b21e772f536f2961bc56d3e4fe93612d72/src/buffer/html.rs#L326

came in as

[src/buffer/html.rs:327:21] input = "    --verbose"

so the split below

https://github.com/pacak/bpaf/blob/a479b6b21e772f536f2961bc56d3e4fe93612d72/src/buffer/html.rs#L334

produces

[src/buffer/html.rs:335:31] chunk = Raw(
    " ",
    1,
)
[src/buffer/html.rs:335:31] chunk = Raw(
    " ",
    1,
)
[src/buffer/html.rs:335:31] chunk = Raw(
    " ",
    1,
)
[src/buffer/html.rs:335:31] chunk = Raw(
    " ",
    1,
)
[src/buffer/html.rs:335:31] chunk = Raw(
    "--verbose",
    9,
)

and I don't know what to do next, hence this issue 😅

pacak commented 3 months ago

Hmm... I'll see what I can do. I'm not really 100% happy with how markdown rendered either.

Boshen commented 3 months ago

Hmm... I'll see what I can do. I'm not really 100% happy with how markdown rendered either.

Side note: for other data sources I ended up parsing to another data structure and render some markdowns ... e.g. json schema to markdown: https://github.com/oxc-project/oxc/blob/main/tasks/website/src/linter/json_schema.rs

Maybe it's better to construct a data structure instead of collecting to html and then render from the html, the user could can use the data structure instead.

But this is a lot of rework 😅

Boshen commented 3 months ago

Thanks for the quick response!

While we are at it, my weirdly added doc comment https://github.com/oxc-project/oxc/blob/3671b5c4d0a56a2edd005bbd8710036ee61376d2/crates/oxc_cli/src/command/lint.rs#L79 produced something that looks like a missing newline

**Allowing / Denying Multiple Lints**###  For example `-D correctness -A no-debugger` or `-A all -D no-debugger`. ㅤ

Notice there is no newline before ###.