Mention import renaming in the docs
This commit is contained in:
parent
ff2650373c
commit
88404e924b
@ -8,9 +8,9 @@ use crate::diag::StrResult;
|
|||||||
|
|
||||||
/// An evaluated module, either built-in or resulting from a file.
|
/// An evaluated module, either built-in or resulting from a file.
|
||||||
///
|
///
|
||||||
/// You can access definitions from the module using [field access
|
/// You can access definitions from the module using
|
||||||
/// notation]($scripting/#fields) and interact with it using the [import and
|
/// [field access notation]($scripting/#fields) and interact with it using the
|
||||||
/// include syntaxes]($scripting/#modules).
|
/// [import and include syntaxes]($scripting/#modules).
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```example
|
/// ```example
|
||||||
|
@ -291,13 +291,15 @@ ways:
|
|||||||
- **Import:** `{import "bar.typ"}` \
|
- **Import:** `{import "bar.typ"}` \
|
||||||
Evaluates the file at the path `bar.typ` and inserts the resulting
|
Evaluates the file at the path `bar.typ` and inserts the resulting
|
||||||
[module]($module) into the current scope as `bar` (filename without
|
[module]($module) into the current scope as `bar` (filename without
|
||||||
extension).
|
extension). You can use the `as` keyword to rename the imported module:
|
||||||
|
`{import "bar.typ" as baz}`
|
||||||
|
|
||||||
- **Import items:** `{import "bar.typ": a, b}` \
|
- **Import items:** `{import "bar.typ": a, b}` \
|
||||||
Evaluates the file at the path `bar.typ`, extracts the values of the variables
|
Evaluates the file at the path `bar.typ`, extracts the values of the variables
|
||||||
`a` and `b` (that need to be defined in `bar.typ`, e.g. through `{let}`
|
`a` and `b` (that need to be defined in `bar.typ`, e.g. through `{let}`
|
||||||
bindings) and defines them in the current file. Replacing `a, b` with `*` loads
|
bindings) and defines them in the current file. Replacing `a, b` with `*`
|
||||||
all variables defined in a module.
|
loads all variables defined in a module. You can use the `as` keyword to
|
||||||
|
rename the individual items: `{import "bar.typ": a as one, b as two}`
|
||||||
|
|
||||||
Instead of a path, you can also use a [module value]($module), as shown in the
|
Instead of a path, you can also use a [module value]($module), as shown in the
|
||||||
following example:
|
following example:
|
||||||
|
Loading…
Reference in New Issue
Block a user