Skip to content

Enable SVG output#69

Merged
fabi1cazenave merged 8 commits intoOneDeadKey:masterfrom
etienne-monier:feat/svg-output
Jan 23, 2024
Merged

Enable SVG output#69
fabi1cazenave merged 8 commits intoOneDeadKey:masterfrom
etienne-monier:feat/svg-output

Conversation

@etienne-monier
Copy link
Copy Markdown
Contributor

This MR adds SVG rending as a new file output. This is generated as any other file type.

To test it, simply run (e.g. for ergol.toml file)

python -m kalamine.cli --out ergol.svg layouts/ergol.toml

To test all rending classes, add dk, altgr, mixed classes to main svg tag to display resp. 1st deadkey, altgr and a mixed view layer.

Copy link
Copy Markdown
Collaborator

@fabi1cazenave fabi1cazenave left a comment

Choose a reason for hiding this comment

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

Thanks for this great work ! It works, it’s well written and it conforms perfectly to the existing (and debatable) logic. I love it. :-)

import click
from lxml import etree
from lxml.builder import E

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

these imports might be unused

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right. My linter agrees :)

"black",
"isort"
]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I’m nowhere near a Python expert, but ain’t there some kind of tool.dev-depencies magic we could use here instead ? Where tool != poetry or anything that would pull more dependencies than Kalamine itself ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without using additional dependency manager tool, that's it. You define optional deps.
With an external tool, well, poetry.

By the way, I modified the Makefile as you directly called kalamine which was installed in my python. As I can't understand if you use virtualenvs for tests, I simply used python -m kalamine.cli not to cath the installed kalamine executable. That could be the subject of another PR, but again, I need to uderstand what kind of system-wide tests you could do (By the way, the tests are broken :s).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The tests work… if you call them with a make test, because they expect the layouts to be built. I know it’s not how it’s supposed to work — if you can think of a better way and include that in the CI, your help would be very welcome.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. I understand. Tests import again my system-wide kalamine.


if TYPE_CHECKING:
from .layout import KeyboardLayout

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh I’d love to have type checking everywhere. <3

Does that affect the minimum python version we support (= 3.6 at the moment) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No risk!
Annotations were introduced in Python 3.0 (cf. PEP3107, Python-Version: 3.0)

By the way, using pathlib would deeply increase path operation reading. I'll make a small PR later for that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

And I simply added one or two annotations I had to identify to implement the PR. This is great for developers.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agreed. I love type annotations and I’ve just found out about pathlib very recently (it’s just used in a couple files). Your PRs would help a lot.

f"svg:g/svg:text[@class='level{level_num}']", namespaces=ns
):
if char not in deadkeys:
# Not a deadkey
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nitpick, we can safely drop this comment :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right 🤣

@fabi1cazenave fabi1cazenave changed the title Enable SVG production Enable SVG output Jan 23, 2024
@fabi1cazenave fabi1cazenave merged commit 9af59fc into OneDeadKey:master Jan 23, 2024
@fabi1cazenave
Copy link
Copy Markdown
Collaborator

Fixes #54.

This was referenced Jan 23, 2024
@etienne-monier etienne-monier deleted the feat/svg-output branch January 23, 2024 15:35
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