Coming in 8.1.18: Script editor improvements

I tend to do what I think is googles style but an example of something that works currnetly in 8.1.3 in script console

def exampleFunc(someNum):
    """
    Some small description of what the function does here.
    Args:
        someNum: int, this gets a 1 added to it
    Returns:
        int, the param with a 1 added to it
    """
    return someNum + 1

This doc string method currently works in script console going even using 8.1.3 - an example from a current project (though black text on a dark background - any way to change this?)

I do believe python expects that if there’s triple quotes immediately right after function declaration that its expected to be the docstring of the function and hence why Ignition is able to pick this up even before all these very nice improvements. I expect it will stay the same way though perhaps they will also offer an alternative to the triple quote method immediately after a function declaration.

Some examples - Example Google Style Python Docstrings — napoleon 0.7 documentation

4 Likes

If I can get this working at some point in the future, the way to do proper type-hints would be the suggested syntax for PEP-484 in Python 2: PEP 484 – Type Hints | peps.python.org

In the meantime, yes, all this does is pick up the docstring (first string expression following a declaration). There’s some trickery involving class bodies and __init__ methods, but other than that it’s fairly straightforward.

4 Likes

Maybe I’m missing something, but is there any way to easily add the optional method parameters when it auto completes?

I still have to go back and forth to see what optional parameters a method takes

1 Like

Here’s a feature request.

When we type system.db. we only get the list of functions. My request is to also list the constants.

Same for system.gui, system.serial constants, and all other I am not listing.

1 Like

And if I may.

What about com.inductiveautomation.* and other Java libraries?

Thanks again

That’s planned, but may have to wait for 8.2 for the sake of API compatibility for third party module authors.

At some point, local AST parsing might be able to use reflection to offer limited autocomplete for local Java libraries. It probably won’t ever work across scope boundaries, so there won’t be any hints offered if you’re in a Perspective or other gateway scope.

1 Like

Of course for both of these scenarios one may use ignition-api (PyCharm and Visual Studio Code) and/or ignition-api-stubs (PyCharm).

Both will provide autocompletion for the constants under db, gui, and serial, as well as some (not all) com.inductiveautomation.* classes and other supporting Java libraries.

Had I mentioned this before? :stuck_out_tongue_closed_eyes:

4 Likes

Re: @Bradley_Phillips on June 1st, comment 12.

Came here to say this!

Big fan of VS Code here. With all the work being done in VSCode + extensions, I feel I’ll always be disappointed by the designer editor.

That’s not meant to be a knock on IA team, I just think they have bigger fish to fry and the number of total hours spent developing VS Code (including community extensions) is probably staggering.

I wanted to point out that VS Code does have a remote development mode. Perhaps that technology could be used to edit scripts on the gateway? I really don’t know what the architecture for that would even look like. Just throwing it out there. Probably a IA backed extension for VSCode??

I’d pitch this as a way to give Ignition users a rich script editing experience that would probably even take some work off the IA team.

@PGriffith, anyone ever think of this kind of approach?

2 Likes

Here is a technical answer to how it would be done, though it doesn’t really call out if it’s on the docket. I would have to assume it’s sadly pretty far out. We are talking about practices that are likely the future of the product, but the team at IA are probably focused on the problems of today before that of tomorrow. Don’t get me wrong, this type of feature would revolutionize the platform, and I would be the first to adopt it. However It’s probably a ways out, unless there are some
Module dev gurus willing to take on the challenge of making this a module feature, if a module can even handle it.

@scottmwyant; see my post higher in this thread. There’s a lot of technical hurdles to giving external editors access to scripting. You can sort of do it right now, with the project library, but the way other areas of Ignition ‘bundle’ scripts into arbitrary resources is the main problem with attempting to edit other areas. Getting an external editor to ‘understand’ all the context of an Ignition scripting environment (and giving it access to bidirectionally update text in a script) is a big hurdle. That’s why I mention making the designer an LSP client; then it’s a lot easier to ‘offload’ autocomplete work to external programs that have all that time invested.

Definitely something we’re thinking about into the future, though.

1 Like

Agreed on all of the above. I do like the ability to modify the search string and to use regular expressions, but having to keep going back and forth between mouse and keyboard slows things down significantly.

1 Like

I just wanted to say that the addition of “intellisense” of user script library functions is incredibly useful! It’s a very nice creature comfort to have! :slight_smile: thanks for adding it!

10 Likes

Yes Big up to @PGriffith and the IA team for this great feature !

There is still a few room for small improvments…shortcuts, function comment generator, function list sort option, etc

A ctrl-shift-arrowdown shortcut for copying lines would also be nice. It's so useful in vscode, makes copying lines so fast!

Ctrl + D will duplicate the current line; that might be the same as what you're looking for?

Rebinding of keyboard shortcuts is a thing we'd really like to add :slight_smile:

For me, ctrl-d removes the current line :thinking:. Is there a documentation of all the current bindings?

What version of Ignition are you using? Ctrl + D would delete in the older editor, but is duplicate in the new one.

You can put this as the very last item on the wish list but since we are talking about key bindings, a way to enable vim key bindings would be cool

I was testing this on 8.1.18, but I see on 8.1.21 it does work, great!

It's not working for me too.

Windows 11, French Canada QWERTY Keyboard.

When i press CTRL-/, it just collapse Every indentation. This is one of the most annoying problem i've found in Ignition. The 1st major irritant i've about Ignition is that when i press ESC when a popup is shown in the designer, i expect it to Cancel this popup. Windows and many other OS are built like this since ages...

1 Like