script_meditate/toml.rs
1#[allow(clippy::module_name_repetitions)]
2#[doc(hidden)]
3pub use serde_toml;
4
5/// Extracts, parses, and returns the TOML frontmatter.
6///
7/// # Panics
8///
9/// Panics if the frontmatter cannot be found or if its contents cannot be parsed.
10#[macro_export]
11macro_rules! extract_toml_frontmatter {
12 () => {{
13 // Works only if this script is not directly in the user's directory
14 let source = include_str!(file!());
15 let frontmatter = $crate::extract_frontmatter(source, "toml")
16 .expect("script file should contain a TOML frontmatter");
17 $crate::serde_toml::from_str(frontmatter).expect("could not parse the data")
18 }};
19}