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

Args for commands? #128

Open
fleming79 opened this issue Aug 12, 2023 · 3 comments
Open

Args for commands? #128

fleming79 opened this issue Aug 12, 2023 · 3 comments

Comments

@fleming79
Copy link

Thank you for providing this module. I'd been looking for a way to open the Jupyter console from python.

Looking through your example notebook I can see you are using args for the commands such as:

app.commands.execute('console:create', {
    'insertMode': 'split-right',
    'kernelPreference': {
        'shutdownOnClose': True,
    }
})

. Would it be possible to provide some details on what args can be passed to each of the commands?

The best ref I found sofar was here: https://jupyterlab.readthedocs.io/en/latest/user/commands.html#commands-list
however it only lists the commands without arguments.

@jtpio
Copy link
Owner

jtpio commented Aug 17, 2023

Thanks @fleming79.

The best ref I found sofar was here: https://jupyterlab.readthedocs.io/en/latest/user/commands.html#commands-list

Indeed that would be the best place for documenting what args can be passed. Which I think is auto-generated.

Unfortunately the args are not all well typed, so not sure it would be easy to add them to the documentation easily.

Likely this would require something like jupyterlab/lumino#58.

@fleming79
Copy link
Author

Thank you @jtpio for the link to the issue. It looks like the feature (describedBy) may now exist in Lumino, but not yet in Jupyterlab jupyterlab/jupyterlab#13962?

In the meantime it is worth mentioning (for others who may be looking) that it is relatively straight forward to text search the Jupyterlab source code for the command_id definition with a capable IDE.

As an example; searching in the Jupyterlab source for 'apputils:notify';) gives one definition:

  export const notify = 'apputils:notify';

CTRL + left click on notify to follow the link.

    app.commands.addCommand(CommandIDs.notify, {
      label: trans.__('Emit a notification'),
      caption: trans.__(
        'Notification is described by {message: string, type?: string, options?: {autoClose?: number | false, actions: {label: string, commandId: string, args?: ReadOnlyJSONObject, caption?: string, className?: string}[], data?: ReadOnlyJSONValue}}.'
      ),
      execute: args => {
        const { message, type } = args as any;
        const options = (args.options as any) ?? {};

Here we can see the args are 'message' and 'options'. Fortunately 'caption' also provides some useful details about usage.

@jtpio
Copy link
Owner

jtpio commented Aug 21, 2023

It looks like the feature (describedBy) may now exist in Lumino, but not yet in Jupyterlab jupyterlab/jupyterlab#13962?

Indeed, it would still need to be implemented in JupyterLab.

In the meantime it is worth mentioning (for others who may be looking) that it is relatively straight forward to text search the Jupyterlab source code for the command_id definition with a capable IDE.

Good point. Maybe we should document this in the ipylab repo?

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

No branches or pull requests

2 participants