pub struct NumberingOptions {
pub counters: BTreeMap<Name, CounterOptions>,
}Expand description
The numbering options of a document: per counter, the counter within which it is numbered, and the value it has before it is first advanced.
These are the per-document option values of the numbering feature: an
option type bound on the document, which a render request may set again,
its value then replacing the document’s for that render
(Bind::Either). In data, they are
the settings key counters of the numbering feature, a map from a
counter’s name to its CounterOptions.
Whether a reference point is numbered at all is not an option of this feature: a point whose number source gives a counter is numbered, and the feature that owns the point decides whether it gives one (for example the numbering depth of the headings feature, fixed when the registry is built).
A counter that the options do not mention keeps what its declaring feature said. The numbering stage reports, once per run, every entry it cannot apply, and applies the others:
- an entry for a counter no feature declares is a Warning
(
flm.numbering.unknown-counter) and changes nothing; an entry that numbers a counter within a counter no feature declares is the same Warning, and itswithinchanges nothing (itsinitialstill applies); - an entry that numbers a counter within a parent set no feature registers
(
flm.numbering.unknown-parent-set), within no counter at all (an empty list of parents, or a parent set that holds no counter;flm.numbering.bad-within-joiner), or through a within-joiner that does not compile (flm.numbering.bad-within-joiner) or that no feature registers (flm.numbering.unknown-within-joiner), is an Error, and itswithinchanges nothing (itsinitialstill applies); - an entry whose within-joiner writes a counter that, under the options,
is not always one of the counters the counter is numbered within is an
Error (
flm.numbering.not-an-ancestor), and the counter keeps the place it was declared with; - an entry that moves a counter’s ancestors so that the declared
within-joiner or nesting joiner of a counter writes a counter it is no
longer always numbered within is an Error
(
flm.numbering.not-an-ancestor), and no point counting in that counter is numbered in that run; - entries that make counters numbered within each other are an Error
(
flm.numbering.hierarchy-cycle), and no point counting in those counters is numbered in that run.
§Examples
use flm_core::stdlib::features::numbering::{NumberingOptions, Within};
let options = NumberingOptions::new()
.initial("flm.headings.section", 0)
.within("flm.math.equation", Within::parent("flm.headings.section"));
assert_eq!(options.of("flm.headings.section").and_then(|entry| entry.initial), Some(0));
assert!(options.of("example.figure").is_none());Fields§
§counters: BTreeMap<Name, CounterOptions>What the document says about each counter it mentions, in name order.
Implementations§
Source§impl NumberingOptions
impl NumberingOptions
Sourcepub fn new() -> NumberingOptions
pub fn new() -> NumberingOptions
Returns options that say nothing about any counter.
Sourcepub fn of(&self, counter: &str) -> Option<&CounterOptions>
pub fn of(&self, counter: &str) -> Option<&CounterOptions>
Returns what these options say about counter, or None when they say
nothing about it.
Sourcepub fn counter(
self,
counter: impl Into<Name>,
entry: CounterOptions,
) -> NumberingOptions
pub fn counter( self, counter: impl Into<Name>, entry: CounterOptions, ) -> NumberingOptions
Builder: replaces what the options say about counter by entry.
Sourcepub fn within(
self,
counter: impl Into<Name>,
within: Within,
) -> NumberingOptions
pub fn within( self, counter: impl Into<Name>, within: Within, ) -> NumberingOptions
Builder: numbers counter within the counters within gives, keeping
the rest of what the options say about counter.
The counters that within gives must be declared by some feature; a
counter in within that no feature declares is reported as a Warning
and the option changes nothing. The reports and their effects are
listed under NumberingOptions.
Sourcepub fn within_nothing(self, counter: impl Into<Name>) -> NumberingOptions
pub fn within_nothing(self, counter: impl Into<Name>) -> NumberingOptions
Builder: numbers counter within nothing, keeping the rest of what the
options say about counter.
Sourcepub fn initial(self, counter: impl Into<Name>, value: u32) -> NumberingOptions
pub fn initial(self, counter: impl Into<Name>, value: u32) -> NumberingOptions
Builder: gives counter the value value before it is first advanced,
keeping the rest of what the options say about counter (see
CounterOptions::initial).
Trait Implementations§
Source§impl Clone for NumberingOptions
impl Clone for NumberingOptions
Source§impl Debug for NumberingOptions
impl Debug for NumberingOptions
Source§impl Default for NumberingOptions
impl Default for NumberingOptions
Source§impl<'de> Deserialize<'de> for NumberingOptionswhere
NumberingOptions: Default,
impl<'de> Deserialize<'de> for NumberingOptionswhere
NumberingOptions: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for NumberingOptions
Source§impl Hash for NumberingOptions
impl Hash for NumberingOptions
Source§impl JsonSchema for NumberingOptions
impl JsonSchema for NumberingOptions
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for NumberingOptions
impl PartialEq for NumberingOptions
impl StructuralPartialEq for NumberingOptions
Auto Trait Implementations§
impl Forget for NumberingOptions
impl Freeze for NumberingOptionswhere
*const LeafNode<Name, CounterOptions> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(Name, CounterOptions)>>: Freeze,
impl Move for NumberingOptions
impl RefUnwindSafe for NumberingOptions
impl Send for NumberingOptionswhere
NodeRef<Owned, Name, CounterOptions, LeafOrInternal>: Send,
BoxRaw<(Name, CounterOptions)>: Send,
impl Sync for NumberingOptionswhere
NodeRef<Owned, Name, CounterOptions, LeafOrInternal>: Sync,
BoxRaw<(Name, CounterOptions)>: Sync,
impl Unpin for NumberingOptions
impl UnsafeUnpin for NumberingOptionswhere
*const LeafNode<Name, CounterOptions> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(Name, CounterOptions)>>: UnsafeUnpin,
impl UnwindSafe for NumberingOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more