Skip to content

Add json formatting#181

Open
alecsammon wants to merge 3 commits intoantham:masterfrom
alecsammon:format_json
Open

Add json formatting#181
alecsammon wants to merge 3 commits intoantham:masterfrom
alecsammon:format_json

Conversation

@alecsammon
Copy link
Contributor

This may be out of scope for this project - happy for this to be rejected!!

This will automatically format json in doc strings using json.Indent

I have run

  • go test ./...
  • golangci-lint run

I agree to the Code of Conduct

Thanks!

@antham
Copy link
Owner

antham commented Feb 13, 2026

Hi,
Thanks for the PR, this feature is already supported with the @ tag.

@alecsammon
Copy link
Contributor Author

Thanks.

I guess I was thinking a few things

  1. Gherkin does allow for docstring annotations:
    https://cucumber.io/docs/gherkin/reference/#doc-strings

It's possible to annotate the DocString with the type of content it contains. You specify the content type after the triple quote, as follows:
I'm not sure I'm would want to add tool specific comments throughout my feature files - when there is a recommended way of defining the language.

  1. By having this natively in the CLI you don't need additional tools - such as jq. This also doesn't require any dependencies.

Maybe could do a few things to make this more acceptable.

  1. Split the code out a little to keep it a little more readable
  2. Only enable it via a config flag - so it doesn't break backwards compatiability

@antham
Copy link
Owner

antham commented Mar 10, 2026

The idea was to support every format not only JSON, I don't really want to do something only for that, especially keeping both @ thing and this annotation at the same time seems.
It seems better to be able to support any possible docstring and remove the @ mechanism thing and it would be a breaking.

@alecsammon
Copy link
Contributor Author

Ok - that would make sense.

So to confirm.

  1. Remove my "custom" JSON formatting
  2. Update the @ notation to instead support """<language>
  3. Update the package to v4

to format JSON you would continue to use .jq (or any external tool), by defining this in the config

@alecsammon
Copy link
Contributor Author

I've opened a draft PR here: #185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants