Closed nddipiazza closed 3 months ago
I've moved this to the common repo where gherkin is maintained.
There is a pretty
method implemented in javascript. Would that fit your needs?
There is also https://github.com/cucumber/common/pull/1555 which work in enhancing that pretty
method.
I had originally opened this ticket in the cucumber-jvm project. it's there that I really need this. this was moved to the generic cucumber project which loses that fact.
I considered the fact that you opened it in cucumber-jvm first. Maybe the javascript version for gherkin-utils would had fit your needs
Did you consider the possibility to use cucumber-jvm to get the messages in the form of ndjson to use those as an input in javascript implementation of gherkin and then get the gherkinDocument to use with gherkin-utils?
@nddipiazza what are you trying to achieve. You've described a solution, but not your problem. What are you trying to achieve by pretty formatting gherkin files?
@mpkorstanje I have a java program that processes gherkin files. A portion of my java program needs to be able to, given a gherkin string, source format that gherkin. Most importantly so that the Test Data table is formatted pretty. Can this be done simply?
Is there a reason it has to be done in Java?
We currently don't have any such function in Java. We do have a function that does it in Javascript. If it absolutely has to be Java then I guess you could port it. The structure isn't too different.
https://github.com/cucumber/common/blob/main/gherkin-utils/javascript/src/pretty.ts
Yeah unfortunately in my case java is a requirement because my app server is java and there is no js engine available.
I think that could be nice to port gherkin-utils to other languages. That's why I've added the "Help wanted" badge :)
I could take a stab at it. there's not much code there. But i'm super weak with ts. So it'll take me a while
Would be helpfull for IDEs as well!
Short reminder: if anyone would need any kind of help, feel free to join our community slack. You'll find plenty of developers ready to help.
If for any reason you would not or can not join slack, we will find other way to provide any kind of help. It can be as part of this issue, or a pull-request, or something else? Are you using some tools which you would keep using? We can certainly join you there. Really, feel free to ask! We're here to help :smiley:
We now have a pretty(GherkinDocument) -> string
function implemented in TypeScript.
For implementations in other languages, please make a gherkin-utils/[language]
implementation based on the same design (using a walkGherkinDocument
function).
@aslakhellesoy here you go - https://github.com/cucumber/common/pull/1725 Is there someone who can help me put it in the CircleCI and cover producing a release artifact etc?
Great stuff @nddipiazza - let's continue the discussion in cucumber/common#1725
FYI we're making good progress with this, but there are still a few areas I think we should improve on before we can say this is done - see cucumber/common#2024 for some Gherkin we'd want to finalise the prety-printing for before saying this is "ready"
This is something that isn't solved by my own library https://gitlab.com/jamietanna/gherkin-formatter/ so this isn't me holding things up - I'd love for us to solve it in here :+1:
@mpkorstanje, wonder can this be closed? The Java implementation now satisfies the original request, if not mistaken.
Seems good enough to me.
I find myself wishing there was a simple SDK with the ability to pretty print (format) gherkin files.
Like how intellij cucumber plugin formats them is exactly what I want.
Is there some way to add a simple static method for this?
GherkinFormatter.prettyPrint(gherkinString)
I think there is a way to do this with the library, but it's not as simple.