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

Implement Document Formatting #1732

Merged
merged 4 commits into from
Sep 7, 2021
Merged

Implement Document Formatting #1732

merged 4 commits into from
Sep 7, 2021

Conversation

aslakhellesoy
Copy link
Contributor

@aslakhellesoy aslakhellesoy commented Sep 7, 2021

Summary

Implement Gherkin Document formatting in language server / vscode extension / monaco plugin.

Details

The actual formatting is done by the pretty function in @cucumber/gherkin-utils

Motivation and Context

People using an editor want to format their documents 😄

How Has This Been Tested?

With unit tests and manual testing of VSCode extension and monaco plugin.

Screenshots (if appropriate):

Before:
Screenshot 2021-09-07 at 12 09 09

After:
Screenshot 2021-09-07 at 12 09 24

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • The change has been ported to Java.
  • The change has been ported to Ruby.
  • The change has been ported to JavaScript.
  • The change has been ported to Go.
  • The change has been ported to .NET.
  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have updated the CHANGELOG accordingly.

Copy link
Contributor

@aurelien-reeves aurelien-reeves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🤩

describe('getGherkinFormattingEdits', () => {
it('returns text edits that prettifies a Gherkin document', () => {
const gherkinSource = `Feature: Hello
Scenario: World
Copy link
Contributor

@aurelien-reeves aurelien-reeves Sep 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using reindent-template-literals (as a dev dependency) to avoid breaking the indentation, as it is done with cucumber-js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gherkinSource is intentionally unindented and the test verifies that it's indented after formatting.

Why do we need to worry about breaking indentation? (Not quite sure what you mean).

Copy link
Contributor

@aurelien-reeves aurelien-reeves Sep 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aslakhellesoy aslakhellesoy merged commit a839120 into main Sep 7, 2021
@aslakhellesoy aslakhellesoy deleted the lsp-document-format branch September 7, 2021 14:32
@laeubi
Copy link

laeubi commented Sep 14, 2021

@aslakhellesoy is there anything that could be used directly under java / cucumber-jvm?

@aurelien-reeves
Copy link
Contributor

@laeubi this is currently work in progress: #1725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants