summaryrefslogtreecommitdiff
path: root/library/src/meta
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-10 12:55:21 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-10 12:55:21 +0100
commit62f35602a87574dcc607f1637aeae1be574981ff (patch)
tree363a1918006e06d7d79dc2ace5f8e59cd3b6bb19 /library/src/meta
parentc38d72383d2068361d635d6c1c78ba97aa917801 (diff)
New #[func] macro
Diffstat (limited to 'library/src/meta')
-rw-r--r--library/src/meta/heading.rs1
-rw-r--r--library/src/meta/link.rs2
-rw-r--r--library/src/meta/numbering.rs70
-rw-r--r--library/src/meta/reference.rs1
4 files changed, 33 insertions, 41 deletions
diff --git a/library/src/meta/heading.rs b/library/src/meta/heading.rs
index 09cbc8b1..3a8d811c 100644
--- a/library/src/meta/heading.rs
+++ b/library/src/meta/heading.rs
@@ -74,7 +74,6 @@ pub struct HeadingNode {
pub outlined: bool,
/// The heading's title.
- #[positional]
#[required]
pub body: Content,
}
diff --git a/library/src/meta/link.rs b/library/src/meta/link.rs
index d4d4d8ca..572c55b4 100644
--- a/library/src/meta/link.rs
+++ b/library/src/meta/link.rs
@@ -46,7 +46,6 @@ pub struct LinkNode {
/// ]
/// ```
///
- #[positional]
#[required]
#[parse(
let dest = args.expect::<Destination>("destination")?;
@@ -59,7 +58,6 @@ pub struct LinkNode {
/// The content that should become a link. If `dest` is an URL string, the
/// parameter can be omitted. In this case, the URL will be shown as the
/// link.
- #[positional]
#[required]
#[parse(match &dest {
Destination::Url(url) => match args.eat()? {
diff --git a/library/src/meta/numbering.rs b/library/src/meta/numbering.rs
index d3e1ee4d..4e6e1aed 100644
--- a/library/src/meta/numbering.rs
+++ b/library/src/meta/numbering.rs
@@ -27,46 +27,42 @@ use crate::text::Case;
/// )
/// ```
///
-/// ## Parameters
-/// - numbering: `Numbering` (positional, required)
-/// Defines how the numbering works.
-///
-/// **Counting symbols** are `1`, `a`, `A`, `i`, `I` and `*`. They are
-/// replaced by the number in the sequence, in the given case.
-///
-/// The `*` character means that symbols should be used to count, in the
-/// order of `*`, `†`, `‡`, `§`, `¶`, and `‖`. If there are more than six
-/// items, the number is represented using multiple symbols.
-///
-/// **Suffixes** are all characters after the last counting symbol. They are
-/// repeated as-is at the end of any rendered number.
-///
-/// **Prefixes** are all characters that are neither counting symbols nor
-/// suffixes. They are repeated as-is at in front of their rendered
-/// equivalent of their counting symbol.
-///
-/// This parameter can also be an arbitrary function that gets each number as
-/// an individual argument. When given a function, the `numbering` function
-/// just forwards the arguments to that function. While this is not
-/// particularly useful in itself, it means that you can just give arbitrary
-/// numberings to the `numbering` function without caring whether they are
-/// defined as a pattern or function.
-///
-/// - numbers: `NonZeroUsize` (positional, variadic)
-/// The numbers to apply the numbering to. Must be positive.
-///
-/// If `numbering` is a pattern and more numbers than counting symbols are
-/// given, the last counting symbol with its prefix is repeated.
-///
-/// - returns: any
-///
/// Display: Numbering
/// Category: meta
+/// Returns: any
#[func]
-pub fn numbering(vm: &Vm, args: &mut Args) -> SourceResult<Value> {
- let numbering = args.expect::<Numbering>("pattern or function")?;
- let numbers = args.all::<NonZeroUsize>()?;
- numbering.apply(vm.world(), &numbers)
+pub fn numbering(
+ /// Defines how the numbering works.
+ ///
+ /// **Counting symbols** are `1`, `a`, `A`, `i`, `I` and `*`. They are
+ /// replaced by the number in the sequence, in the given case.
+ ///
+ /// The `*` character means that symbols should be used to count, in the
+ /// order of `*`, `†`, `‡`, `§`, `¶`, and `‖`. If there are more than six
+ /// items, the number is represented using multiple symbols.
+ ///
+ /// **Suffixes** are all characters after the last counting symbol. They are
+ /// repeated as-is at the end of any rendered number.
+ ///
+ /// **Prefixes** are all characters that are neither counting symbols nor
+ /// suffixes. They are repeated as-is at in front of their rendered
+ /// equivalent of their counting symbol.
+ ///
+ /// This parameter can also be an arbitrary function that gets each number as
+ /// an individual argument. When given a function, the `numbering` function
+ /// just forwards the arguments to that function. While this is not
+ /// particularly useful in itself, it means that you can just give arbitrary
+ /// numberings to the `numbering` function without caring whether they are
+ /// defined as a pattern or function.
+ numbering: Numbering,
+ /// The numbers to apply the numbering to. Must be positive.
+ ///
+ /// If `numbering` is a pattern and more numbers than counting symbols are
+ /// given, the last counting symbol with its prefix is repeated.
+ #[variadic]
+ numbers: Vec<NonZeroUsize>,
+) -> Value {
+ numbering.apply(vm.world(), &numbers)?
}
/// How to number an enumeration.
diff --git a/library/src/meta/reference.rs b/library/src/meta/reference.rs
index 55051b5e..20354556 100644
--- a/library/src/meta/reference.rs
+++ b/library/src/meta/reference.rs
@@ -20,7 +20,6 @@ use crate::text::TextNode;
#[node(Show)]
pub struct RefNode {
/// The label that should be referenced.
- #[positional]
#[required]
pub target: EcoString,
}