summaryrefslogtreecommitdiff
path: root/crates/typst-library/src
diff options
context:
space:
mode:
authoralluring-mushroom <86041465+alluring-mushroom@users.noreply.github.com>2025-04-08 05:56:20 +1000
committerGitHub <noreply@github.com>2025-04-07 19:56:20 +0000
commit9829bd8326fc67ebf78593bf4e860390c5ae8804 (patch)
treef010742f435b6ccb87f097469fff79522015f3a4 /crates/typst-library/src
parent43c3d5d3afc945639a576535e48806112c161743 (diff)
Document exceptions and alternatives to using `type` (#6027)
Co-authored-by: Zedd Serjeant <Zedd.Serjeant@PumpkinEng.com.au> Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-library/src')
-rw-r--r--crates/typst-library/src/foundations/ty.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/typst-library/src/foundations/ty.rs b/crates/typst-library/src/foundations/ty.rs
index 40f7003c..9d769028 100644
--- a/crates/typst-library/src/foundations/ty.rs
+++ b/crates/typst-library/src/foundations/ty.rs
@@ -39,11 +39,25 @@ use crate::foundations::{
/// #type(image("glacier.jpg")).
/// ```
///
-/// The type of `10` is `int`. Now, what is the type of `int` or even `type`?
+/// The type of `{10}` is `int`. Now, what is the type of `int` or even `type`?
/// ```example
/// #type(int) \
/// #type(type)
/// ```
+///
+/// Unlike other types like `int`, [none] and [auto] do not have a name
+/// representing them. To test if a value is one of these, compare your value to
+/// them directly, e.g:
+/// ```example
+/// #let val = none
+/// #if val == none [
+/// Yep, it's none.
+/// ]
+/// ```
+///
+/// Note that `type` will return [`content`] for all document elements. To
+/// programmatically determine which kind of content you are dealing with, see
+/// [`content.func`].
#[ty(scope, cast)]
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct Type(Static<NativeTypeData>);