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

Add support for hyphenation to wrapped text #668

Merged
merged 10 commits into from
Oct 15, 2023

Conversation

pepijndevos
Copy link
Contributor

@pepijndevos pepijndevos commented Oct 8, 2023

Description

This PR adds hyphenation to the word wrapping functionality. Example:

image

This needs a poetry add pyphen or similar but these things tend to create conflicts so I'd save that until all the tests and docs and API and bikeshedding is done.

Checklist

  • feature/fix implemented
  • code formatting ok (black and ruff check .)
  • mypy returns no error
  • tests added/updated and pytest succeeds
  • add Pyphen dependency
  • make configurable
  • documentation added/updated
    • command docstring and option/argument help
    • README.md updated (Feature Overview)
    • CHANGELOG.md updated
    • added new command to reference.rst
    • RTD doc updated and building with no error (make clean && make html in docs/)

@abey79 abey79 changed the title hyphenate text Add support for hyphenation to wrapped text Oct 8, 2023
Copy link
Owner

@abey79 abey79 left a comment

Choose a reason for hiding this comment

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

Great contribution, thanks!

You will have to add the dependency to pyproject.toml for the CI to have a chance to succeed.

Also, it would be nice to add the corresponding parameters to the text command in vpype_cli, and update all the docstrings.

vpype/text.py Outdated Show resolved Hide resolved
vpype/text.py Outdated Show resolved Hide resolved
@pepijndevos
Copy link
Contributor Author

Alright, I think that should be most of the relevant changes?

Copy link
Owner

@abey79 abey79 left a comment

Choose a reason for hiding this comment

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

Looks good! Just a small comment on the docs to point at the right format to specify the language.

@@ -53,7 +60,8 @@ def text(

In wrap mode, the text start at (0, 0) and expends left until it reach the specified width.
The `--align` option controls how the text is laid out within the column and behaves as
typically expected.
typically expected. The `--hyphenate` options enables hyphenation using the provided
language code.
Copy link
Owner

Choose a reason for hiding this comment

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

Same here.

vpype/text.py Outdated
@@ -210,6 +227,7 @@ def text_block(
left alignment)
line_spacing: line spacing (default: 1.0)
justify: should the text be justified (default: False)
hyphenate: wrapped text is hyphenated with the given language (default: None)
Copy link
Owner

Choose a reason for hiding this comment

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

It would be great to indicate what format(s) are acceptable for the language, and provide a couple of examples.

@pepijndevos
Copy link
Contributor Author

Something like this? Also caught a leftover print statement

@abey79
Copy link
Owner

abey79 commented Oct 13, 2023

Something like this? Also caught a leftover print statement

That works yes. Ready to merge as soon as CI is happy!

@pepijndevos
Copy link
Contributor Author

pepijndevos commented Oct 13, 2023

darn that little doc addition made ruff unhappy

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (833fcf2) 94.78% compared to head (e90071b) 94.67%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #668      +/-   ##
==========================================
- Coverage   94.78%   94.67%   -0.12%     
==========================================
  Files          62       62              
  Lines        5735     5746      +11     
  Branches     1308     1311       +3     
==========================================
+ Hits         5436     5440       +4     
- Misses        182      188       +6     
- Partials      117      118       +1     
Files Coverage Δ
vpype_cli/text.py 100.00% <100.00%> (ø)
vpype/text.py 87.78% <44.44%> (-4.78%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abey79 abey79 merged commit d399aa5 into abey79:master Oct 15, 2023
12 of 14 checks passed
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

Successfully merging this pull request may close these issues.

2 participants