zed icon indicating copy to clipboard operation
zed copied to clipboard

Examples that have no input

Open philrz opened this issue 1 year ago • 0 comments

tl;dr

At the moment, it seems mdtest-spq can't support examples that have no input.

Details

Here's an example of where this would be useful:

https://github.com/brimdata/super/blob/8e86ac0ff4c9da6c278eb0ec9a8efba9f888c9d5/docs/commands/super.md?plain=1#L644-L650

Currently rendered as:

Image

When I was converting examples in #5489, in other cases where there was direct SELECT or yield of static values, I often morphed them into having explicit inputs, such as a null input that would work in this case, or a non-null value referenced as this in the query in other cases. However, this kind of direct SELECT/yield is indeed a convenience for the user so it seems like it would be nice to be able to show in the docs. Furthermore, this specific example seems like one where its original purpose was to show exactly that, so morphing it to have an echo'ed input seems like it would be inappropriate.

At the moment if I try to turn it into an mdtest-spq by just leaving the input portion blank, it doesn't render the result.

```mdtest-spq
# spq
SELECT VALUE 'hello, world'
# input
# expected output
"hello, world"
```

Image

Ideas

mdtest-spq already supports an empty output portion and this renders fine. See for instance:

https://github.com/brimdata/super/blob/8e86ac0ff4c9da6c278eb0ec9a8efba9f888c9d5/docs/language/functions/grep.md?plain=1#L48-L55

Image

So maybe supporting empty input wouldn't be too hard?

If we come up with a way, it'd be ideal if the Playground rendering side can pick up on the empty input as a special case so that way when it creates the command line for the "CLI" tab it can leave out the leading echo .. | portion entirely.

philrz avatar Feb 06 '25 17:02 philrz