Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to print a GherkinDocument to text with pretty format #118

Closed
Milk-Tang opened this issue Jun 9, 2023 · 4 comments
Closed

How to print a GherkinDocument to text with pretty format #118

Milk-Tang opened this issue Jun 9, 2023 · 4 comments

Comments

@Milk-Tang
Copy link

Since I have a GherkinDocument, I wonder how to write it into a file with a pretty format?

@jenisys
Copy link
Contributor

jenisys commented Jun 12, 2023

Do you mean:

  • With syntax coloring ?
  • With uniform formatting, like indented with 2 spaces (or: 4 spaces) ?

REGARDING: Syntax coloring / highlighting

  • Use gherkin as language/syntax-marker, like:
# — FILE: features/example.feature
Feature: Example 1
  Scenario: S1
    Given a step passes
    When another step passes

@Milk-Tang
Copy link
Author

Do you mean:

  • With syntax coloring ?
  • With uniform formatting, like indented with 2 spaces (or: 4 spaces) ?

REGARDING: Syntax coloring / highlighting

  • Use gherkin as language/syntax-marker, like:
# — FILE: features/example.feature
Feature: Example 1
  Scenario: S1
    Given a step passes
    When another step passes

Thank you for your reply, but it seems that your intention is to use the formatting of the editor when writing a '.feature' file?
But my question is:

gherkinDocument, err := gherkin.ParseGherkinDocument(reader)
There I got a instance of GherkinDocument by method gherkin.ParseGherkinDocument,
and if I create a GherkinDocument instance by myself but not ParseGherkinDocument,
how can I write it to a ".feature" file in my code?
And here the struct of GherkinDocument :

type GherkinDocument struct {
	Uri      string     `json:"uri,omitempty"`
	Feature  *Feature   `json:"feature,omitempty"`
	Comments []*Comment `json:"comments"`
}

@jenisys
Copy link
Contributor

jenisys commented Jun 14, 2023

@Milk-Tang
Copy link
Author

thanks

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

No branches or pull requests

2 participants