Plugin design approach

Hi,

I'm building a plugin that will need to open a yml file, take Python code from one of its keys, and enable developing from there. The development language itself would be Python. I'm not sure what would be the right design, as it is not clear that there's a need for custom language support here. (seems like an overkill)

Illustration for yml file:

```

name: myYMLFile
script:
    print ('this is my python code')
    print('end')

```

I want to take the code under the script key, have it displayed in the editor, and that people would be able to continue developing Python code from there.

Is the right approach here to do a custom language support, or is there a simpler way? The file itself is yml, I planned to assign it with a unique ending, and then when a file of this kind would be opened, put in only the value of the yml key that has code in it (it's a constant key).

As the development language itself is Python, I don't see language injection as the right fit here (I don't have a mix of language, I want to do file manipulation to take in only the Python part).
No need for a separate editor as well since people need only the Python code.
Also, I couldn't find any option to modify a file between it being open till displayed in the editor (so I could pull the script part from the yml), is there one?

Would love your thought about what would be the right approach to create a plugin here.

Thank you,
Shachar Hirshberg

0

Do I understand correctly that you want your users to see only Python code in the editor, without the surrounding YAML stuff? Can such YAML file contain several Python fragments? If yes, how should they be merged? What if people really want to edit YAML?

0
Avatar
Permanently deleted user

Hi Peter,

Yes, I want the users to see only Python code. There will always be only Python fragment.

My thought was to create a tool window to display and edit the other YAML properties.

Shachar

0

There's currently no way to substitute file contents for editing. But we plan to support similar cases for Jupyter notebooks, and then, probably, we'll have such API.

0
Avatar
Permanently deleted user

Hi Peter, in that case, I've decided on a different approach:

1. Pre-split the YAML file into Python file (the script part from the YAML), and YAML file (can be JSON as well if it's better handled).
2. Open the Python file and work on it normally.
3. Open the YAML file (the split part) in a tool window and edit it from there. 

This way, the user can both develop Python code and edit the YAML if needed. Does this approach make sense? Is it possible to actually open and edit the YAML from a tool window?

Thank you,
Shachar

0

Sure, opening an editor for a file in a toolwindow is easy, just use EditorFactory to create an editor for the document corresponding to that file. It's editing Python fragment that's currently very complicated.

1

请先登录再写评论。