tauri-apps / tauri-apps/tauri-docs
[request] fix broken code samples in migration guide
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 1.1k
- Forks
- 887
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 48
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the migration guide at https://v2.tauri.app/start/migrate/from-tauri-1/ and inspect the Global Shortcut and Menu snippets described in the issue. Compare them with the reported Rust compiler errors and current API signatures, then verify that the corrected examples compile and that the migration page no longer shows the failing calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100