mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-03 15:14:35 +00:00
Provide some "bare-bones" documentation for component libraries (#3865)
Sadly, this makes it a bit more obvious that this feature is practically only available to Rust devs using build.rs at the moment. Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
This commit is contained in:
parent
432103d38f
commit
2acaa222d0
2 changed files with 25 additions and 0 deletions
|
@ -98,6 +98,7 @@ myst_enable_extensions = [
|
||||||
myst_url_schemes = {
|
myst_url_schemes = {
|
||||||
"slint-cpp": f"https://slint.dev/releases/{version}/docs/cpp/{{{{path}}}}",
|
"slint-cpp": f"https://slint.dev/releases/{version}/docs/cpp/{{{{path}}}}",
|
||||||
"slint-rust": f"https://slint.dev/releases/{version}/docs/rust/slint/{{{{path}}}}",
|
"slint-rust": f"https://slint.dev/releases/{version}/docs/rust/slint/{{{{path}}}}",
|
||||||
|
"slint-build-rust": f"https://slint.dev/releases/{version}/docs/rust/slint_build/{{{{path}}}}",
|
||||||
"slint-node": f"https://slint.dev/releases/{version}/docs/node/{{{{path}}}}",
|
"slint-node": f"https://slint.dev/releases/{version}/docs/node/{{{{path}}}}",
|
||||||
'http': None, 'https': None, 'mailto': None,
|
'http': None, 'https': None, 'mailto': None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,3 +110,27 @@ export { MySwitch as Alias1, MyButton as Alias2 };
|
||||||
// Re-export all types from other module
|
// Re-export all types from other module
|
||||||
export * from "other_module.slint";
|
export * from "other_module.slint";
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Component Libraries
|
||||||
|
|
||||||
|
Splitting your code base into separate module files promotes re-use and
|
||||||
|
improves encapsulation by allow you to hide helper components. This works
|
||||||
|
well within a project's own directory structure. To share libraries of
|
||||||
|
components between projects without hardcoding their relative paths, use
|
||||||
|
the component library syntax:
|
||||||
|
|
||||||
|
```slint,ignore
|
||||||
|
import { MySwitch } from "@mylibrary";
|
||||||
|
```
|
||||||
|
|
||||||
|
In the above example, the `MySwitch` component will be imported from a component
|
||||||
|
library called "mylibrary". The path to this library must be defined separately at compilation time.
|
||||||
|
Use one of the following methods to help the Slint compiler resolve "mylibrary" to the correct
|
||||||
|
path on disk:
|
||||||
|
|
||||||
|
* When using Rust and `build.rs`, call [`with_library_paths`](slint-build-rust:struct.CompilerConfiguration#method.with_library_paths)
|
||||||
|
to provide a mapping from library name to path.
|
||||||
|
* When invoking the `slint-viewer` from the command line, pass `-Lmylibrary=/path/to/my/library` for each component
|
||||||
|
library.
|
||||||
|
* When using the live-preview in the VS code extension, configure the Slint extension's library path
|
||||||
|
using the `Slint: Library Paths` setting.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue