@@ -40,6 +40,57 @@ pub struct Action {
4040 pub dependencies : Vec < String > ,
4141}
4242
43+ /// Macro to define the `BuiltinDefinition` enum and its methods.
44+ ///
45+ /// Example input:
46+ ///
47+ /// ```
48+ /// builtin_definitions! {
49+ /// Name {
50+ /// name: "name",
51+ /// description: "Package name",
52+ /// example: "I don't know how %(name) is used in practice",
53+ /// },
54+ /// Version {
55+ /// name: "version",
56+ /// description: "Package version",
57+ /// example: "I don't know how %(version) is used in practice",
58+ /// },
59+ /// }
60+ /// ```
61+ ///
62+ /// Corresponding output:
63+ ///
64+ /// ```
65+ /// pub enum BuiltinDefinition {
66+ /// Name,
67+ /// Version,
68+ /// }
69+ ///
70+ /// impl BuiltinDefinition {
71+ /// pub fn name(&self) -> &str {
72+ /// match self {
73+ /// Self::Name => "name",
74+ /// Self::Version => "version",
75+ /// }
76+ /// }
77+ ///
78+ /// pub fn details(&self) -> DefinitionDetails<'_> {
79+ /// match self {
80+ /// Self::Name => DefinitionDetails {
81+ /// name: "name",
82+ /// description: "Package name",
83+ /// example: "I don't know how %(name) is used in practice",
84+ /// },
85+ /// Self::Version => DefinitionDetails {
86+ /// name: "version",
87+ /// description: "Package version",
88+ /// example: "I don't know how %(version) is used in practice",
89+ /// },
90+ /// }
91+ /// }
92+ /// }
93+ /// ```
4394macro_rules! builtin_definitions {
4495 (
4596 $(
0 commit comments