-
Notifications
You must be signed in to change notification settings - Fork 0
Deviate from ruby/pretty_print and enrich the API #57
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4ce4648
wadler: accept indent kwarg use by default in nest and group
stackmystack fc325ce
wadler: accept base_indent kwarg
stackmystack f5ec8f2
wadler: use delim kwarg instead of positional args
stackmystack b2fa1d5
bin: repl: change ascii art
stackmystack 7d3b32f
wadler: introduce consistent and inconsistent calls
stackmystack 2dae1e7
wadler: remove unnecessary args for group_close
stackmystack 361f4a3
wadler: make all printing methods return self
stackmystack d3e0ef3
wdaler: add do method to avoid breaking call chains
stackmystack 2a8ffe8
wadler: normalize group_open and accept a symbol break_type
stackmystack 51c1532
wadler: add {#separate}
stackmystack 272da62
wadler: rename ctor param space to space_gen
stackmystack 695244c
wadler: add {#space} to generate a literal space
stackmystack 1629d5b
wadler: add {#surround} as a glorified group
stackmystack 470a060
wadler: add {#lines} and {#concat} as wrappers for {#surround}
stackmystack ca62905
wadler: add some helpers based on surround
stackmystack 8af37ae
wadler: allow {#separate}'s indent param to be an Integer
Amine-Mike 4f911d7
test: refactor surround and separate tests
Amine-Mike 42bc83c
wadler: always add parent group before starting print
Amine-Mike 30cf122
fix: wadler groups aliases
Amine-Mike a10bec7
doc: fix examples results
Amine-Mike 9a48652
examples: make compliant to new api
Amine-Mike be00905
ci: run examples to check if they break
Amine-Mike 60a44e3
examples: add entries for surround and separate
Amine-Mike File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ | |
| title 'With eager printing:' | ||
| puts printer_with_config.output | ||
| # abc defghi | ||
| # jkl | ||
| # jkl | ||
|
|
||
| puts '' | ||
|
|
||
|
|
||
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
Empty file.
Empty file.
Empty file.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,10 @@ | |
| # The maximum width can be specified using the `width` parameter. | ||
| width = 5 | ||
|
|
||
| printer_width_default = Oppen::Wadler.new | ||
| printer_width_narrow = Oppen::Wadler.new(width: width) | ||
| printer_width_default = Oppen::Wadler.new(indent: 2) | ||
| printer_width_narrow = Oppen::Wadler.new(indent: 2, width: width) | ||
|
Comment on lines
+8
to
+9
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
| test_block = ->(printer) { | ||
| printer.group(2) { | ||
| printer.group { | ||
| printer.text 'Hello, World!' | ||
| printer.breakable | ||
| printer.text 'How are you doing?' | ||
|
|
||
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
Empty file.
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
Empty file.
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative '../helper' | ||
|
|
||
| # You might want to also take a look at the `lines` and `concat` methods. | ||
|
|
||
| printer = Oppen::Wadler.new(width: 10) | ||
|
|
||
| printer.separate((1..10).map(&:to_s), ',', break_type: :inconsistent, indent: 2) { |i| | ||
| printer.text i | ||
| } | ||
|
|
||
| puts printer.output | ||
| # 1, 2, 3, | ||
| # 4, 5, 6, | ||
| # 7, 8, 9, | ||
| # 10 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative '../helper' | ||
|
|
||
| # You might want to also take a look at the `parens`, `parens_break_both`, `angles`, ... methods. | ||
|
|
||
| printer = Oppen::Wadler.new(width: 10) | ||
|
|
||
| printer.surround('<<', '>>', indent: 2, lft_force_break: true, rgt_force_break: true) { | ||
| printer.text '42' | ||
| } | ||
|
|
||
| puts printer.output | ||
| # << | ||
| # 42 | ||
| # >> |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.