FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

REF: Spin off tree -> code compilation into a separate module by adriangb · Pull Request #136 · danielgtaylor/python-betterproto · GitHub

REF: Spin off tree -> code compilation into a separate module - #136

Merged
nat-n merged 3 commits into
danielgtaylor:masterfrom
adriangb:split-off-compiler
Aug 9, 2020
Merged

REF: Spin off tree -> code compilation into a separate module#136
nat-n merged 3 commits into
danielgtaylor:masterfrom
adriangb:split-off-compiler

Conversation

adriangb commented Aug 4, 2020

Copy link
Copy Markdown
Contributor

This small edit splits off the actual code generation based on the models.py classes into its own module. The hope is that it would be possible to swap out the new compiler.py for another module that implements the outputfile_compiler function with the same signature, thus allowing for generation of arbitrary code based on the models.py tree structure.

@@ -70,16 +69,6 @@ def generate_code(
) -> None:
plugin_options = request.parameter.split(",") if request.parameter else []

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Does anyone know how to encode an alternative template/compiler (i.e. to swap out betterproto.plugin.compiler.py) as part of the command line options?

adriangb Aug 6, 2020
edited
Loading

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The goal here is that at the very least someone could copy compiler.py to my_compiler.py and edit the template (or the rendering method altogether) and pass an option to protoc that would tell plugin.py to import my_compiler.outputfile_compiler and use that instead of the default one. It's not a super clean API or anything but it should be powerful and a good starting place for other changes. This options parsing doesn't need to be part of this PR, just asking for future reference.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess you have in mind being able to do something like:

protoc --python_betterproto_out=lib --custom_opt=TYPE_VALIDATION,SILLY_WALKS,WHATEVER -I ...

I like the idea of stuff being modular and potentially configurable in this way. But I wouldn't race to provide an API to support fully support this without a real use case.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this change stands on it's own, and I agree with you that more discussion is needed before providing an API to do the above, but I do want to make sure that this change is at least compatible with that approach.

nat-n merged commit c93351e into danielgtaylor:master Aug 9, 2020
adriangb deleted the split-off-compiler branch August 9, 2020 18:15
abn mentioned this pull request Nov 24, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL