Skip to content

Commit 2c06035

Browse files
authored
Add support for docs to create_enum (#1851)
* Add support for docs to create_enum Enables specifying docs for each enum value. * cargo fmt
1 parent d60b96c commit 2c06035

File tree

1 file changed

+14
-2
lines changed
  • sdk/typespec/typespec_client_core/src

1 file changed

+14
-2
lines changed

sdk/typespec/typespec_client_core/src/macros.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
/// Turns into a struct where each variant can be turned into and construct from the corresponding string.
1010
#[macro_export]
1111
macro_rules! create_enum {
12-
($(#[$meta:meta])* $name:ident, $(($variant:ident, $value:expr)), *) => (
13-
$(#[$meta])*
12+
($(#[$type_doc:meta])* $name:ident, $($(#[$val_doc:meta])* ($variant:ident, $value:expr)), *) => (
13+
$(#[$type_doc])*
1414
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone, Copy)]
1515
pub enum $name {
1616
$(
17+
$(#[$val_doc])*
1718
$variant,
1819
)*
1920
}
@@ -157,6 +158,17 @@ mod test {
157158
create_enum!(Colors, (Black, "Black"), (White, "White"), (Red, "Red"));
158159
create_enum!(ColorsMonochrome, (Black, "Black"), (White, "White"));
159160

161+
create_enum!(
162+
#[doc = "Defines operation states"]
163+
OperationState,
164+
#[doc = "The operation hasn't started"]
165+
(NotStarted, "notStarted"),
166+
#[doc = "The operation is in progress"]
167+
(InProgress, "inProgress"),
168+
#[doc = "The operation has completed"]
169+
(Completed, "completed")
170+
);
171+
160172
struct Options {
161173
a: Option<String>,
162174
b: u32,

0 commit comments

Comments
 (0)