summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Löring <52287649+4BlueTurtles@users.noreply.github.com>2023-08-21 16:53:56 +0200
committerGitHub <noreply@github.com>2023-08-21 16:53:56 +0200
commitf6005156256dd4b4f99d1a1c15babb43fcc78788 (patch)
tree494ed05c02fcc11740dd2b2d102909e0018c2cf8
parent73999fe8232514efcc8dab9abce69028335fcbeb (diff)
Improve clarity regarding location parameter in counter.final() (#1962)
-rw-r--r--crates/typst-library/src/meta/counter.rs13
-rw-r--r--crates/typst-library/src/meta/query.rs7
-rw-r--r--crates/typst-library/src/meta/state.rs15
3 files changed, 19 insertions, 16 deletions
diff --git a/crates/typst-library/src/meta/counter.rs b/crates/typst-library/src/meta/counter.rs
index ca4f3bc5..35afd2f8 100644
--- a/crates/typst-library/src/meta/counter.rs
+++ b/crates/typst-library/src/meta/counter.rs
@@ -267,12 +267,13 @@ use crate::prelude::*;
/// array of integers, even if the counter has just one number.
///
/// - location: location (positional, required)
-/// Can be any location. Why is it required then? Typst has to evaluate parts
-/// of your code multiple times to determine all counter values. By only
-/// allowing this method within [`locate`]($func/locate) calls, the amount of
-/// code that can depend on the method's result is reduced. If you could call
-/// `final` directly at the top level of a module, the evaluation of the whole
-/// module and its exports could depend on the counter's value.
+/// Can be an arbitrary location, as its value is irrelevant for the method's
+/// return value. Why is it required then? Typst has to evaluate parts of your
+/// code multiple times to determine all counter values. By only allowing this
+/// method within [`locate`]($func/locate) calls, the amount of code that can
+/// depend on the method's result is reduced. If you could call `final`
+/// directly at the top level of a module, the evaluation of the whole module
+/// and its exports could depend on the counter's value.
///
/// - returns: array
///
diff --git a/crates/typst-library/src/meta/query.rs b/crates/typst-library/src/meta/query.rs
index a644000d..eb520896 100644
--- a/crates/typst-library/src/meta/query.rs
+++ b/crates/typst-library/src/meta/query.rs
@@ -140,9 +140,10 @@ pub fn query(
/// have an explicit label attached to them. This limitation will be
/// resolved in the future.
target: LocatableSelector,
- /// Can be any location. Why is it required then? As noted before, Typst has
- /// to evaluate parts of your code multiple times to determine the values of
- /// all state. By only allowing this function within
+ /// Can be an arbitrary location, as its value is irrelevant for the
+ /// function's return value. Why is it required then? As noted before, Typst
+ /// has to evaluate parts of your code multiple times to determine the
+ /// values of all state. By only allowing this function within
/// [`locate`]($func/locate) calls, the amount of code that can depend on
/// the query's result is reduced. If you could call it directly at the top
/// level of a module, the evaluation of the whole module and its exports
diff --git a/crates/typst-library/src/meta/state.rs b/crates/typst-library/src/meta/state.rs
index 5b304972..ee2a6e32 100644
--- a/crates/typst-library/src/meta/state.rs
+++ b/crates/typst-library/src/meta/state.rs
@@ -222,13 +222,14 @@ use crate::prelude::*;
/// Gets the value of the state at the end of the document.
///
/// - location: location (positional, required)
-/// Can be any location. Why is it required then? As noted before, Typst has
-/// to evaluate parts of your code multiple times to determine the values of
-/// all state. By only allowing this method within [`locate`]($func/locate)
-/// calls, the amount of code that can depend on the method's result is
-/// reduced. If you could call `final` directly at the top level of a module,
-/// the evaluation of the whole module and its exports could depend on the
-/// state's value.
+/// Can be an arbitrary location, as its value is irrelevant for the method's
+/// return value. Why is it required then? As noted before, Typst has to
+/// evaluate parts of your code multiple times to determine the values of all
+/// state. By only allowing this method within [`locate`]($func/locate) calls,
+/// the amount of code that can depend on the method's result is reduced. If
+/// you could call `final` directly at the top level of a module, the
+/// evaluation of the whole module and its exports could depend on the state's
+/// value.
///
/// - returns: any
///