Skip to content

Commit cd55d67

Browse files
author
Ngo Iok Ui (Wu Yu Wei)
authored
doc: update tauri documentations (#2446)
1 parent 13003ec commit cd55d67

32 files changed

Lines changed: 176 additions & 162 deletions

.changes/doc-tauri-utils.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
"tauri": minor
33
---
44

5-
`tauri::api` no longer re-export items in `tauri-utils`. We already expose necessary items in the root of `tauri`.
5+
Move items which `tauri::api` re-exports from `tauri-utils` to individual module `utils`. Because these items has their
6+
own Error/Result types which are not related to api module at all.
7+

ARCHITECTURE.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Tauri apps can have custom menus and have tray-type interfaces. They can be upda
1515
The following section briefly describes the roles of the various parts of Tauri.
1616
### Tauri Core [STABLE RUST]
1717
#### [tauri](https://github.com/tauri-apps/tauri/tree/dev/core/tauri)
18-
This is the glue crate that holds everything together. It brings the runtimes, macros, utilities and API into one final product. It reads the `tauri.conf.json` file at compile time in order to bring in features and undertake actual configuration of the app (and even the `Cargo.toml` file in the project's folder). It handles script injection (for polyfills / prototype revision) at runtime, hosts the API for systems interaction, and even manages updating.
18+
This is the major crate that holds everything together. It brings the runtimes, macros, utilities and API into one final product. It reads the `tauri.conf.json` file at compile time in order to bring in features and undertake actual configuration of the app (and even the `Cargo.toml` file in the project's folder). It handles script injection (for polyfills / prototype revision) at runtime, hosts the API for systems interaction, and even manages updating.
1919

2020
#### [tauri-build](https://github.com/tauri-apps/tauri/tree/dev/core/tauri-build)
2121
Apply the macros at build-time in order to rig some special features needed by `cargo`.
@@ -53,24 +53,6 @@ This rust executable provides the full interface to all of the required activiti
5353
#### [create-tauri-app](https://github.com/tauri-apps/tauri/tree/dev/tooling/create-tauri-app) [JS]
5454
This is a toolkit that will enable engineering teams to rapidly scaffold out a new tauri-apps project using the frontend framework of their choice (as long as it has been configured).
5555

56-
## TAURI RUST API
57-
- **app** The App API module allows you to manage application processes.
58-
- **assets** The Assets module allows you to read files that have been bundled by tauri Assets handled by Tauri during compile time and runtime.
59-
- **config** The Tauri config definition.
60-
- **dialog** The Dialog API module allows you to show messages and prompt for file paths.
61-
- **dir** The Dir module is a helper for file system directory management.
62-
- **file** The File API module contains helpers to perform file operations.
63-
- **http** The HTTP request API.
64-
- **notification** The desktop notifications API module.
65-
- **path** The file system path operations API.
66-
- **process** Process helpers including the management of child processes.
67-
- **rpc** The RPC module includes utilities to send messages to the JS layer of the webview.
68-
- **shell** The shell api.
69-
- **shortcuts** Global shortcuts interface.
70-
- **version** The semver API.
71-
72-
73-
7456
# External Crates
7557
The Tauri-Apps organisation maintains two "upstream" crates from Tauri, namely TAO for creating and managing application windows, and WRY for interfacing with the Webview that lives within the window.
7658

core/tauri-codegen/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
9797
quote!(env!("CARGO_PKG_VERSION").to_string())
9898
};
9999
let package_info = quote!(
100-
#root::api::PackageInfo {
100+
#root::PackageInfo {
101101
name: #package_name,
102102
version: #package_version,
103103
}

core/tauri-codegen/src/embedded_assets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl ToTokens for EmbeddedAssets {
304304

305305
// we expect phf related items to be in path when generating the path code
306306
tokens.append_all(quote! {{
307-
use ::tauri::api::assets::{EmbeddedAssets, phf, phf::phf_map};
307+
use ::tauri::utils::assets::{EmbeddedAssets, phf, phf::phf_map};
308308
EmbeddedAssets::from_zstd(phf_map! { #map })
309309
}});
310310
}

core/tauri-utils/src/config.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// SPDX-License-Identifier: MIT
44

55
//! The Tauri configuration used at runtime.
6-
//! It is pulled from a `tauri.conf.json` file and the [`config::Config`] struct is generated at compile time.
6+
//!
7+
//! It is pulled from a `tauri.conf.json` file and the [`Config`] struct is generated at compile time.
78
//!
89
//! # Stability
910
//! This is a core functionality that is not considered part of the stable API.
@@ -648,7 +649,7 @@ mod build {
648649
macro_rules! literal_struct {
649650
($tokens:ident, $struct:ident, $($field:ident),+) => {
650651
$tokens.append_all(quote! {
651-
::tauri::api::config::$struct {
652+
::tauri::utils::config::$struct {
652653
$($field: #$field),+
653654
}
654655
});
@@ -657,7 +658,7 @@ mod build {
657658

658659
impl ToTokens for WindowUrl {
659660
fn to_tokens(&self, tokens: &mut TokenStream) {
660-
let prefix = quote! { ::tauri::api::config::WindowUrl };
661+
let prefix = quote! { ::tauri::utils::config::WindowUrl };
661662

662663
tokens.append_all(match self {
663664
Self::App(path) => {
@@ -834,7 +835,7 @@ mod build {
834835

835836
impl ToTokens for AppUrl {
836837
fn to_tokens(&self, tokens: &mut TokenStream) {
837-
let prefix = quote! { ::tauri::api::config::AppUrl };
838+
let prefix = quote! { ::tauri::utils::config::AppUrl };
838839

839840
tokens.append_all(match self {
840841
Self::Url(url) => {
@@ -915,7 +916,7 @@ mod build {
915916
str_lit,
916917
json_value_lit,
917918
);
918-
tokens.append_all(quote! { ::tauri::api::config::PluginConfig(#config) })
919+
tokens.append_all(quote! { ::tauri::utils::config::PluginConfig(#config) })
919920
}
920921
}
921922

core/tauri/src/api/cli.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5-
use crate::api::config::{CliArg, CliConfig};
5+
//! Types and functions related to CLI arguments.
6+
7+
use crate::utils::config::{CliArg, CliConfig};
68

79
use clap::{
810
crate_authors, crate_description, crate_name, crate_version, App, Arg, ArgMatches, ErrorKind,
@@ -14,17 +16,16 @@ use std::collections::HashMap;
1416
#[macro_use]
1517
mod macros;
1618

17-
/// The resolution of a arg match.
19+
/// The resolution of a argument match.
1820
#[derive(Default, Debug, Serialize)]
1921
#[non_exhaustive]
2022
pub struct ArgData {
21-
/// The value of the arg.
22-
/// - Value::Bool if it's a flag,
23-
/// - Value::Array if it's multiple,
24-
/// - Value::String if it has value,
25-
/// - Value::Null otherwise.
23+
/// - [`Value::Bool`] if it's a flag,
24+
/// - [`Value::Array`] if it's multiple,
25+
/// - [`Value::String`] if it has value,
26+
/// - [`Value::Null`] otherwise.
2627
pub value: Value,
27-
/// The number of occurrences of the arg.
28+
/// The number of occurrences of the argument.
2829
/// e.g. `./app --arg 1 --arg 2 --arg 2 3 4` results in three occurrences.
2930
pub occurrences: u64,
3031
}
@@ -35,11 +36,11 @@ pub struct ArgData {
3536
pub struct SubcommandMatches {
3637
/// The subcommand name.
3738
pub name: String,
38-
/// The subcommand arg matches.
39+
/// The subcommand argument matches.
3940
pub matches: Matches,
4041
}
4142

42-
/// The arg matches of a command.
43+
/// The argument matches of a command.
4344
#[derive(Default, Debug, Serialize)]
4445
#[non_exhaustive]
4546
pub struct Matches {
@@ -61,7 +62,7 @@ impl Matches {
6162
}
6263
}
6364

64-
/// Gets the arg matches of the CLI definition.
65+
/// Gets the argument matches of the CLI definition.
6566
pub fn get_matches(cli: &CliConfig) -> crate::api::Result<Matches> {
6667
let about = cli
6768
.description()

core/tauri/src/api/dialog.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5+
//! Types and functions related to display dialog.
6+
57
#[cfg(any(dialog_open, dialog_save))]
68
use std::path::{Path, PathBuf};
79

@@ -29,6 +31,7 @@ macro_rules! run_dialog {
2931
}
3032

3133
/// The file dialog builder.
34+
///
3235
/// Constructs file picker dialogs that can select single/multiple files or directories.
3336
#[cfg(any(dialog_open, dialog_save))]
3437
#[derive(Debug, Default)]

core/tauri/src/api/dir.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5+
//! Types and functions related to file system directory management.
6+
57
use serde::Serialize;
68
use std::{
79
fs::{self, metadata},
810
path::{Path, PathBuf},
911
};
1012
use tempfile::{self, tempdir};
1113

12-
/// The result of the `read_dir` function.
14+
/// A disk entry which is either a file or a directory.
1315
///
14-
/// A DiskEntry is either a file or a directory.
15-
/// The `children` Vec is always `Some` if the entry is a directory.
16+
/// This is the result of the [`read_dir`]. The `children` field is always `Some` if the entry is a directory.
1617
#[derive(Debug, Serialize)]
1718
#[non_exhaustive]
1819
pub struct DiskEntry {
19-
/// The path to this entry.
20+
/// The path to the entry.
2021
pub path: PathBuf,
21-
/// The name of this entry (file name with extension or directory name)
22+
/// The name of the entry (file name with extension or directory name).
2223
pub name: Option<String>,
2324
/// The children of this entry if it's a directory.
2425
#[serde(skip_serializing_if = "Option::is_none")]
@@ -59,7 +60,7 @@ pub fn read_dir<P: AsRef<Path>>(path: P, recursive: bool) -> crate::api::Result<
5960
Result::Ok(files_and_dirs)
6061
}
6162

62-
/// Runs a closure with a temp dir argument.
63+
/// Runs a closure with a temporary directory argument.
6364
pub fn with_temp_dir<F: FnOnce(&tempfile::TempDir)>(callback: F) -> crate::api::Result<()> {
6465
let dir = tempdir()?;
6566
callback(&dir);

core/tauri/src/api/file.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5+
//! Types and functions related to file operations.
6+
57
mod extract;
68
mod file_move;
79

core/tauri/src/api/file/extract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub enum Compression {
2626
Gz,
2727
}
2828

29-
/// The extract manager.
29+
/// The extract manager to retrieve files from archives.
3030
#[derive(Debug)]
3131
pub struct Extract<'a> {
3232
source: &'a path::Path,

0 commit comments

Comments
 (0)