Skip to content

Commit 0f10ce4

Browse files
authored
Update readme and other tweaks (#33)
Among other things, I wiped my virtual environment, reinstalled everything from scratch, and was surprised that the tree-sitter implementation had changed. So, I've also updated some test data to get the tests to pass again. * tweaks to the readme * tweak to touchpad zooming: do things in the order you'd expect * upgrade code_tokenize, needs to update tests to match * the test shouldn't hang when it fails * update images in integration tests for new version of tree-sitter * all tests pass again * add java support
1 parent a7aa337 commit 0f10ce4

10 files changed

+32
-36
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mouse is on, and the bottom snippit is for the column. In large images, as you
2626
zoom out, multiple tokens will be combined into single pixels in the image, and
2727
multiple tokens will be highlighted in these snippets.
2828

29-
## Prerequisites
29+
## Installation
3030
You'll need [Tcl/Tk bindings](https://docs.python.org/3/library/tkinter.html)
3131
for Python. This might require installing something outside of your virtual
3232
environment: you'll know it's set up right if you can run `python3 -m tkinter`
@@ -35,7 +35,8 @@ and get a little interactive window to pop up.
3535
- On Mac: `brew install python-tk`
3636
- On Ubuntu: `sudo apt-get install python3-pil.imagetk`
3737

38-
After that, just `pip3 install -r requirements.txt`, and you should be good!
38+
After that, just clone the repo, run `pip3 install -r requirements.txt`, and
39+
you should be good!
3940

4041
If you get errors about not doing this in a virtual environment, try
4142
`python3 -m venv venv`, then `source venv/bin/activate`, and _then_
@@ -46,7 +47,7 @@ either file an issue telling us to update the documentation with what you did,
4647
or update it yourself and send us a pull request!).
4748

4849
## Options
49-
The short version: run `visual_diff.py --help` for info.
50+
The short version: run `./visual_diff.py --help` for info.
5051

5152
The program can recognize a handful of languages from the file extension (e.g.,
5253
`.py` or `.go`). If you want to use a language that is not automatically

generate_report_test.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def test_file_against_self(self):
1212
pointsprite_info, pointsprite_info, 100))
1313
expected = [
1414
"Found duplicated code between examples/pointsprite.py and examples/pointsprite.py:",
15-
" 706 tokens on lines 28-121 and lines 121-295",
16-
" 126 tokens on lines 90-105 and lines 104-121",
17-
" 126 tokens on lines 90-105 and lines 280-295",
18-
" 126 tokens on lines 104-121 and lines 266-281",
19-
" 126 tokens on lines 266-281 and lines 280-295",
15+
" 672 tokens on lines 28-119 and lines 121-295",
16+
" 116 tokens on lines 92-104 and lines 105-119",
17+
" 116 tokens on lines 92-104 and lines 281-295",
18+
" 116 tokens on lines 105-119 and lines 268-280",
19+
" 116 tokens on lines 268-280 and lines 281-295",
2020
]
2121
self.assertEqual(expected, actual)
2222

@@ -27,11 +27,12 @@ def test_file_pair(self):
2727
[nmea_info, rtk_info], 100))
2828
expected = [
2929
"Found duplicated code between examples/gpsnmea.go and examples/gpsrtk.go:",
30-
" 413 tokens on lines 69-131 and lines 85-152",
30+
" 451 tokens on lines 69-131 and lines 85-152",
3131
"Found duplicated code between examples/gpsrtk.go and examples/gpsrtk.go:",
32-
" 120 tokens on lines 278-316 and lines 312-352",
33-
" 116 tokens on lines 352-363 and lines 487-498",
34-
" 142 tokens on lines 395-423 and lines 446-472",
32+
" 100 tokens on lines 96-124 and lines 106-127",
33+
" 128 tokens on lines 278-316 and lines 312-352",
34+
" 118 tokens on lines 352-363 and lines 487-498",
35+
" 157 tokens on lines 389-423 and lines 444-472",
3536
" 362 tokens on lines 559-618 and lines 567-626",
3637
" 305 tokens on lines 559-610 and lines 575-626",
3738
" 251 tokens on lines 559-602 and lines 583-626",

integration_test.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ def generate_image(filename_a, filename_b):
2525

2626
def assertImagesMatch(self, expected_filename, actual_image):
2727
expected_image = PIL.Image.open(f"test_images/{expected_filename}")
28-
self.assertEqual(list(actual_image.getdata()),
29-
list(expected_image.getdata()))
28+
# This used to be a `self.assertEqual`, but when it fails, formatting
29+
# the error message takes forever.
30+
self.assertTrue(list(actual_image.getdata()) ==
31+
list(expected_image.getdata()))
3032

3133
@parameterized.expand((("cpp_example.hpp",),
3234
("index.js",),

requirements.txt

+12-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
1-
certifi==2024.8.30
2-
charset-normalizer==3.4.0
3-
code_ast==0.1.0
4-
code_tokenize==0.2.0
5-
contourpy==1.3.0
6-
cycler==0.12.1
1+
certifi==2024.12.14
2+
charset-normalizer==3.4.1
3+
code_ast==0.1.1
4+
code_tokenize==0.2.1
75
darkdetect==0.8.0
8-
fonttools==4.54.1
9-
gitdb==4.0.11
10-
GitPython==3.1.43
6+
gitdb==4.0.12
7+
GitPython==3.1.44
118
idna==3.10
12-
kiwisolver==1.4.7
13-
matplotlib==3.9.2
149
mypy==1.14.1
1510
mypy-extensions==1.0.0
16-
numpy==2.1.2
17-
packaging==24.1
11+
numpy==2.2.2
1812
parameterized==0.9.0
19-
pillow==11.0.0
20-
pyparsing==3.2.0
21-
python-dateutil==2.9.0.post0
13+
pillow==11.1.0
2214
requests==2.32.3
23-
ruff==0.8.4
24-
setuptools==75.2.0
25-
six==1.16.0
26-
smmap==5.0.1
15+
ruff==0.9.3
16+
setuptools==75.8.0
17+
smmap==5.0.2
2718
tree-sitter==0.21.3
2819
typing_extensions==4.12.2
29-
urllib3==2.2.3
20+
urllib3==2.3.0

test_images/gps.png

7.63 KB
Loading
-1.85 KB
Loading

test_images/pointsprite.png

-7.13 KB
Loading

test_images/server.png

329 Bytes
Loading

utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def guess_language(filename: str) -> str:
4646
"hpp": "cpp",
4747
"go": "go",
4848
"hs": "haskell",
49+
"java": "java",
4950
"js": "javascript",
5051
"py": "python",
5152
"rs": "rust",

zoom_map.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def _zoom_touchpad(self, event: tk.Event) -> None:
107107
self._zoom_touchpad_amount += delta_x + delta_y
108108
if abs(self._zoom_touchpad_amount) > 20:
109109
sign = 1 if self._zoom_touchpad_amount > 0 else -1
110-
self._zoom_touchpad_amount = 0
111110
self._zoom(-sign, event)
111+
self._zoom_touchpad_amount = 0
112112

113113
def _zoom(self, amount: int, event: tk.Event) -> None:
114114
if not self._pyramid.zoom(amount):

0 commit comments

Comments
 (0)