feat: Generic pretty-printer implementation#39
Merged
Conversation
8c17a77 to
53d3cda
Compare
Contributor
|
@vadimkibana are you going to also add a Readme? It will be easier for me to follow the implementation 🙏 |
Collaborator
Author
|
@stratoula Yes! Here it is. |
sddonne
reviewed
Mar 6, 2026
| import { text, group, indent, line, softline, join, layout } from './printer'; | ||
|
|
||
| const doc = group([ | ||
| text('SELECT'), |
Contributor
There was a problem hiding this comment.
Would be better to use ES|QL examples?
stratoula
approved these changes
Mar 6, 2026
Contributor
stratoula
left a comment
There was a problem hiding this comment.
This looks very nice! 🙌
| expect(text('hello')).toBe('hello'); | ||
| }); | ||
|
|
||
| it('returns empty string for empty input', () => { |
| * | ||
| * Like `hardline`, forces enclosing groups to break. | ||
| */ | ||
| export const literalline: Doc = [ |
Contributor
There was a problem hiding this comment.
Suggested change
| export const literalline: Doc = [ | |
| export const literalLine: Doc = [ |
Not sure if this is intended but I see we have this format in general so I guess we want to be consistent (?)
Collaborator
Author
There was a problem hiding this comment.
I'll rename in next PR.
| /** | ||
| * Like `literalline` but does NOT force parent group to break. | ||
| */ | ||
| export const literallineWithoutBreakParent: LineNode = { |
Contributor
There was a problem hiding this comment.
Suggested change
| export const literallineWithoutBreakParent: LineNode = { | |
| export const literalLineWithoutBreakParent: LineNode = { |
same as above
Collaborator
Author
There was a problem hiding this comment.
I'll rename in next PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Partially addresses: elastic/kibana#242923
See README for detailed description of this library.
Below is an example of how the printer works in a nutshell:
Details
Technical details, breaking changes or considerations you have made while working in this PR.
Checklist
BREAKING CHANGE: changesyntax.breaking: true (!)majorfeatminorfixpatchrefactorpatchperfpatchbuildpatchdocspatchchorepatchrevertpatch