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

Support loading gcode_macro templates from files #578

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kageurufu
Copy link
Member

@kageurufu kageurufu commented Feb 17, 2025

Currently, writing a python macro is somewhat painful, requiring preficing each line with a single ! to make preserve indentation. This also heavily limits editor support.

This PR adds support for !!include path/to/macro.py (and technically !!include macro.notpy resolves as jinja2 gcode templates).

For python macros, I've also added type stubs in klippy/macro.pyi and added TYPE_CHECKING to the environment. This allows for basic typing support in macro definitions. In the future I would love to be able to generate a bespoke type stub including Printer objects, but thats long term.

if TYPE_CHECKING:
  from klippy.macro import *

Checklist

  • pr title makes sense
  • squashed to 1 commit
  • added a test case if possible
  • if new feature, added to the readme
  • ci is happy and green

@kageurufu kageurufu requested a review from a team as a code owner February 17, 2025 19:02
Currently, writing a python macro is somewhat painful, requiring preficing
each line with a single `!` to make preserve indentation. This also heavily
limits editor support.

This PR adds support for `!!include path/to/macro.py` (and technically
`!!include macro.notpy` resolves as jinja2 gcode templates).

For python macros, I've also added type stubs in `klippy/macro.pyi` and
added `TYPE_CHECKING` to the environment. This allows for basic typing
support in macro definitions. In the future I would love to be able to
generate a bespoke type stub including Printer objects, but thats long
term.

```
if TYPE_CHECKING:
  from klippy.macro import *
```
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.

1 participant