summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2024-03-20 14:15:01 +0100
committerMarcel Müller <neikos@neikos.email>2024-03-20 15:26:49 +0100
commitc3ad6385d74553f79783e579d3a1fb742d4f35f2 (patch)
tree69dc65fe477c9b28e5f8fdf4c6e3f3494eb5a4e9
parent33c9e158f907d85e0bbc271d2334dc1d35a6c07a (diff)
Outsource link generation to helper macro
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--mqtt-format/src/v5/mod.rs1
-rw-r--r--mqtt-format/src/v5/properties.rs4
-rw-r--r--mqtt-format/src/v5/util.rs16
3 files changed, 19 insertions, 2 deletions
diff --git a/mqtt-format/src/v5/mod.rs b/mqtt-format/src/v5/mod.rs
index 9686509..a16e819 100644
--- a/mqtt-format/src/v5/mod.rs
+++ b/mqtt-format/src/v5/mod.rs
@@ -6,6 +6,7 @@ pub mod packets;
pub mod properties;
pub mod reason_code;
pub mod strings;
+pub mod util;
pub mod variable_header;
pub type MResult<O> = winnow::PResult<O>;
diff --git a/mqtt-format/src/v5/properties.rs b/mqtt-format/src/v5/properties.rs
index b64885b..1f05429 100644
--- a/mqtt-format/src/v5/properties.rs
+++ b/mqtt-format/src/v5/properties.rs
@@ -52,12 +52,12 @@ macro_rules! define_properties {
#[doc = ""] // newline
)?
$(
- #[doc = std::concat!("[Specification](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#", $anker, ")")]
+ #[doc = $crate::v5::util::md_speclink!($anker)]
)?
pub struct $name < $lt > {
$(
$(
- #[doc = std::concat!("[Specification](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#", $prop_anker, ")")]
+ #[doc = $crate::v5::util::md_speclink!($prop_anker)]
)?
$prop_name: Option<$prop>
),*
diff --git a/mqtt-format/src/v5/util.rs b/mqtt-format/src/v5/util.rs
new file mode 100644
index 0000000..75c03eb
--- /dev/null
+++ b/mqtt-format/src/v5/util.rs
@@ -0,0 +1,16 @@
+macro_rules! speclink {
+ ($anker:literal) => {
+ std::concat!(
+ "https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#",
+ $anker
+ )
+ };
+}
+pub(crate) use speclink;
+
+macro_rules! md_speclink {
+ ($anker:literal) => {
+ std::concat!("[Specification](", $crate::v5::util::speclink!($anker), ")")
+ };
+}
+pub(crate) use md_speclink;