-
Notifications
You must be signed in to change notification settings - Fork 4
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
php-diff-82 #86
php-diff-82 #86
Conversation
* Add missing documentation. * Fixes and reformatting.
* Reduction of cyclomatic complexity.
* Add option `ignoreLines` to control the ability to ignore blank or empty lines. * Add styles of ignored lines to example css. * Add generator for ignored lines to HTML SideBySide renderer. * Add `options` property to the Sequence Mather. * Refactor option `ignoreNewLines` of the Sequence Matcher. * Add flags to define the level of ignoring blank lines. * Add tag `ignored` to the opCodes. * Add method stripLines to Similarity. * Add default option `ignoreLines` to Diff. * Add tests for testing option `ignoreLines` of the Sequence Matcher. * Reformat code.
Do we trigger a deprecation notice when a sub renderer doesn't have the new This while updating the included sub renderers of course. It's meant for users custom renderers. |
We could check if the interface is implemented or use https://github.com/Roave/you-are-using-it-wrong or use https://github.com/Roave/Dont |
I'm not familiar with those, but I was thinking something simple like: if (!method_exists($subRenderer, 'generateLinesIgnore')) {
trigger_error(
'The use of a subRenderer without method generateLinesIgnore() is deprecated!',
E_USER_DEPRECATED |
Either another abstract class that implements SubRendererInterface AND OR public function __construct()
{
if(!class_implements('SubRendererInterface')){
// throw new error; // set your error here..
}
} |
Instead of defining constants with the same name and values at different namespaces, they're now defined at an interface which can be shared among classes by implementing this interface.
If a used sub renderer, which extends the main renderer, a deprecation notice will be thrown when the sub renderer is missing method `generateLinesIgnore`.
Currently the line is commented out, because the method is not required until the deprecation period for missing this method is over.
For calculating the similarity ratio when empty/blank lines are ignored, these lines have to be stripped from the sequences beforehand. The stripped lines are restored after calculation so the class can also be used as sequenceMatcher.
All the renderers but Cli renderers should now respect the |
Please check the output of all renderers carefully with option |
@vendeeglobe Do you mind testing this PR also? |
I'm not sure if this changes anything in the output. I added some empty lines. I tried all 3 options with the same result. |
That's because you added the new lines to a block of lines which is added to version 2 of which the first line isn't blank. 06-01-2021: |
Sorry for the delay. It works now. I can't tell you why, but it didn't work until I deleted the repo and cloned it refresh. --- edit now there only left those comments lib/jblond/Diff/Renderer/MainRenderer.php, line 100 |
* Add missing documentation. * Fixes and reformatting.
* Reduction of cyclomatic complexity.
* Add option `ignoreLines` to control the ability to ignore blank or empty lines. * Add styles of ignored lines to example css. * Add generator for ignored lines to HTML SideBySide renderer. * Add `options` property to the Sequence Mather. * Refactor option `ignoreNewLines` of the Sequence Matcher. * Add flags to define the level of ignoring blank lines. * Add tag `ignored` to the opCodes. * Add method stripLines to Similarity. * Add default option `ignoreLines` to Diff. * Add tests for testing option `ignoreLines` of the Sequence Matcher. * Reformat code.
Instead of defining constants with the same name and values at different namespaces, they're now defined at an interface which can be shared among classes by implementing this interface.
If a used sub renderer, which extends the main renderer, a deprecation notice will be thrown when the sub renderer is missing method `generateLinesIgnore`.
Currently the line is commented out, because the method is not required until the deprecation period for missing this method is over.
For calculating the similarity ratio when empty/blank lines are ignored, these lines have to be stripped from the sequences beforehand. The stripped lines are restored after calculation so the class can also be used as sequenceMatcher.
Yes... There's still a cleanup to do once the code it's functionality is approved. |
# Conflicts: # example/dark-theme.css # example/styles.css # lib/jblond/Diff/Renderer/Html/Merged.php
Ok... I kind of lost track 😅. Not being allowed to merge remote branch into local (no-ff), I rebased the local branch on the remote. All we had left to do was code cleanup when review was approved? |
Yes, you only wanted to clean up and we are done. |
@DigiLive This looks good, There is only a small merge conflict. |
Proof of concept - Ignore blank lines.
Adds option
IgnoreLines
which accepts 3 levels:0 (or any other value): Don't ignore blank lines.
1: Ignore empty lines.
2: Ignore blank lines. (Contains no or only whitespace characters).
Please note the script spawns errors.
At this moment, ignoring lines is only implemented for the HTML SideBySide renderer.
Once this feature operates as expected, it can be extended to the other renderers.