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

[request] fix broken code samples in migration guide #2843

Open
1 task
cars10 opened this issue Oct 11, 2024 · 0 comments
Open
1 task

[request] fix broken code samples in migration guide #2843

cars10 opened this issue Oct 11, 2024 · 0 comments
Labels
discuss Does this require further discussion before it's dealt with? enhancement Does it add or improve content?

Comments

@cars10
Copy link

cars10 commented Oct 11, 2024

Question you want answered

Fix example code

Where did you look for an answer?

Global shortcut plugin

Reading the migration guide for the global search plugin and checking the rust code snippet. https://v2.tauri.app/start/migrate/from-tauri-1/#migrate-to-global-shortcut-plugin
It includes this snippet:

    .plugin(
        tauri_plugin_global_shortcut::Builder::with_handler(|app, shortcut| {
            println!("Shortcut triggered: {:?}", shortcut);
        })
        .build(),
    )

Sadly it does not work:

error[E0061]: this function takes 2 arguments but 1 argument was supplied
   --> src/lib.rs:28:13
    |
28  |               tauri_plugin_global_shortcut::Builder::with_handler(|app, shortcut| {
    |  _____________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^_-
29  | |                 println!("Shortcut triggered: {:?}", shortcut);
30  | |             })
    | |_____________- argument #1 of type `tauri_plugin_global_shortcut::Builder<_>` is missing
    |

Menu

Similar thing for the menu examples: https://v2.tauri.app/start/migrate/from-tauri-1/#use-taurimenusubmenubuilder

This code

let submenu = SubmenuBuilder::new(app, "Sub")
            .text("Tauri")
            .separator()
            .check("Is Awesome")
            .build()?;

also does not work at all:

error[E0061]: this method takes 2 arguments but 1 argument was supplied
   --> src/lib.rs:33:14
    |
33  |             .text("Tauri")
    |              ^^^^--------- argument #2 is missing
    |
note: method defined here
   --> /Users/ckoenig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-2.0.2/src/menu/builders/submenu.rs:103:10
    |
103 |   pub fn text<I: Into<MenuId>, S: AsRef<str>>(mut self, id: I, text: S) -> Self {
    |          ^^^^
help: provide the argument
    |
33  |             .text("Tauri", /* text */)
    |                  ~~~~~~~~~~~~~~~~~~~~~

error[E0061]: this method takes 2 arguments but 1 argument was supplied
   --> src/lib.rs:35:14
    |
35  |             .check("Is Awesome")
    |              ^^^^^-------------- argument #2 is missing
    |
note: method defined here
   --> /Users/ckoenig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-2.0.2/src/menu/builders/submenu.rs:111:10
    |
111 |   pub fn check<I: Into<MenuId>, S: AsRef<str>>(mut self, id: I, text: S) -> Self {
    |          ^^^^^
help: provide the argument
    |
35  |             .check("Is Awesome", /* text */)

This are the first two snippets that i tried. Maybe there are more errors.

Page URL

https://v2.tauri.app/start/migrate/from-tauri-1/

Additional context

It would be nice if the code snippets of the official migration docs work. Right now it causes a lot of work to upgrade because many things are not documented at all (what permissions does plugin X have, what is the new "gen" folder, etc etc)

Are you willing to work on this yourself?

  • I want to work on this myself
@cars10 cars10 added discuss Does this require further discussion before it's dealt with? enhancement Does it add or improve content? labels Oct 11, 2024
@github-project-automation github-project-automation bot moved this to 🪵 Backlog in Documentation Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Does this require further discussion before it's dealt with? enhancement Does it add or improve content?
Projects
Status: 🪵 Backlog
Development

No branches or pull requests

1 participant