8000 Document command ID naming conventions by lucyleeow · Pull Request #405 · napari/docs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Document command ID naming conventions #405

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

Merged
merged 3 commits into from
Aug 2, 2024
Merged

Conversation

lucyleeow
Copy link
Collaborator
@lucyleeow lucyleeow commented Apr 15, 2024

References and relevant issues

Follow up from: napari/napari#6777 (review)

Description

Naming conventions.
Note the window prefix was noted by Talley: https://github.com/napari/napari/pull/4826/files#r954915004

Open to discussion and changes.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 15, 2024
Copy link
Collaborator Author
@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions


* use `.` to separate words
* start with `napari` for builtin commands or the plugin name for plugin commands
* `napari.window` prefix indicates the `napari` command is part of a GUI menu
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only for napari commands? We don't have this convention for plugins, or should we?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I noticed that our layer actions do not have window but they are part of a menu

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `napari.window` prefix indicates the `napari` command is part of a GUI menu
* the `napari.window` prefix indicates the `napari` command is part of a GUI menu

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think anyone has thought about it deeply before (?), so we can discuss. Maybe it's meant to indicate a menubar menu item?

I'm also not sure why command ids aren't just package:fully.qualified.python.name?

Copy link
Collaborator Author
@lucyleeow lucyleeow Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I am just following what was left by Talley.

Sometimes we use the same callback, e.g., a lot of help menu items just open a URL. I guess in that case we can append an extra word.

I am not opposed to fully qualified python name:

  • It would probably be equally long as current system - (which is fine though shorter would be nice just formatting style wise)
  • It would follow plugin naming convention
  • No extra info about where this command is (i.e., which menu)
  • Is it slightly confusing c.f. the plugin manifest python_name which uses : before the final function name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with fully qualifying the python name. If we move forward with allowing actions to take kwargs, then multiple actions might share the same name. Similarly we sometimes wrap actions in napari stuff, and we may not have a fully qualified python name. I much prefer having the command ID give me a sense of where the command lives in the viewer, rather than in the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will say I don't love napari.window either. I think it should be napari.menus.menu for stuff that lives in a menu (including a context menu I guess?) and then just napari.callback_name for stuff that doesn't live in menus. I think everything does now maybe but longer term

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the only pro for python name is that it would follow what is happening in plugin manifests, though maybe we want to update that? With NAP-6, maybe we want the command ID to indicate where in the menu the action will live?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh I mean I super don't care if we have different convention internally vs. for plugins tbh. And also, for plugins, cant the make their command ID whatever they want anyway? As long as it starts with their plugin name?

@lucyleeow
Copy link
Collaborator Author

cc @jni @DragaDoncila

8000 @lucyleeow lucyleeow added this to the 0.5.0 milestone Apr 16, 2024
Copy link
Contributor
@Czaki Czaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be nice to point that commandID should not be updated only because of code refactor. For simplify of reusability.

@DragaDoncila
Copy link
Contributor

It will be nice to point that commandID should not be updated only because of code refactor. For simplify of reusability.

@Czaki I'm not sure what you mean sorry, can you expand?

@jni
Copy link
Member
jni commented Apr 17, 2024

I think @Czaki is responding to my suggestion that IDs should be a fully qualified Python path. That ties the IDs to implementation details, which is indeed problematic. So I'm open to scrapping that idea and coming up with a different system. Any suggestions?

@lucyleeow
Copy link
Collaborator Author
lucyleeow commented May 2, 2024

So I'm open to scrapping that idea and coming up with a different system.

Do you not like the current system, which I think is like this:

<napari/plugin name>.<window (if require GUI)>.<menu name>.<name describing action>

?

@DragaDoncila
Copy link
Contributor

The PR is documenting the current state of things so we think it's worth it going in as is. @jni and I both think the broader discussion about what we want the convention to be warrants discussion, but we will open an issue in napari for this, as it might also require PRs to change the current IDs if we decide on something new. @lucyleeow yell out if that sounds crazy!

@lucyleeow
Copy link
Collaborator Author

Sounds OK to me, thanks!

@jni jni merged commit 354a349 into napari:main Aug 2, 2024
8 checks passed
6D40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Development

Successfully merging this pull request may close these issues.

4 participants
0