Fixed counter's "Time travel" doc example (#2002)

This commit is contained in:
Andrew Voynov 2023-08-26 00:42:50 +05:00 committed by GitHub
parent 2e86052340
commit 0f794c8c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,20 +181,20 @@ use crate::prelude::*;
/// the document. We then pass this location to our counter's `at` method to /// the document. We then pass this location to our counter's `at` method to
/// get its value at the current location. The `at` method always returns an /// get its value at the current location. The `at` method always returns an
/// array because counters can have multiple levels. As the counter starts at /// array because counters can have multiple levels. As the counter starts at
/// one, the first value is thus `{(1,)}`. /// zero, the first value is thus `{(0,)}`.
/// ///
/// - We now [`query`]($func/query) the document for all elements with the /// - We now [`query`]($func/query) the document for all elements with the
/// `{<intro>}` label. The result is an array from which we extract the first /// `{<intro>}` label. The result is an array from which we extract the first
/// (and only) element's [location]($type/content.location). We then look up /// (and only) element's [location]($type/content.location). We then look up
/// the value of the counter at that location. The first update to the counter /// the value of the counter at that location. The first update to the counter
/// sets it to `{1 + 3 = 4}`. At the introduction heading, the value is thus /// sets it to `{0 + 3 = 3}`. At the introduction heading, the value is thus
/// `{(4,)}`. /// `{(3,)}`.
/// ///
/// - Last but not least, we call the `final` method on the counter. It tells us /// - Last but not least, we call the `final` method on the counter. It tells us
/// what the counter's value will be at the end of the document. We also need /// what the counter's value will be at the end of the document. We also need
/// to give it a location to prove that we are inside of a `locate` call, but /// to give it a location to prove that we are inside of a `locate` call, but
/// which one doesn't matter. After the heading follow two calls to `step()`, /// which one doesn't matter. After the heading follow two calls to `step()`,
/// so the final value is `{(6,)}`. /// so the final value is `{(5,)}`.
/// ///
/// ## Other kinds of state { #other-state } /// ## Other kinds of state { #other-state }
/// The `counter` function is closely related to [state]($func/state) function. /// The `counter` function is closely related to [state]($func/state) function.