Skip to content

Commit

Permalink
Properly indent the doc comments of enum variants (#4153)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Oct 9, 2024
1 parent 95bf437 commit b150020
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
6 changes: 5 additions & 1 deletion crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3794,7 +3794,11 @@ __wbg_set_wasm(wasm);"
if enum_.generate_typescript {
self.typescript.push('\n');
if !variant_docs.is_empty() {
self.typescript.push_str(&variant_docs);
for line in variant_docs.lines() {
self.typescript.push_str(" ");
self.typescript.push_str(line);
self.typescript.push('\n');
}
}
self.typescript.push_str(&format!(" {name} = {value},"));
}
Expand Down
9 changes: 9 additions & 0 deletions crates/cli/tests/reference/enums.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ export function option_string_enum_echo(color?: ColorName): ColorName | undefine
* A color.
*/
export enum Color {
/**
* Green as a leaf.
*/
Green = 0,
/**
* Yellow as the sun.
*/
Yellow = 1,
/**
* Red as a rose.
*/
Red = 2,
}
/**
Expand Down
14 changes: 13 additions & 1 deletion crates/cli/tests/reference/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,19 @@ export function option_string_enum_echo(color) {
/**
* A color.
*/
export const Color = Object.freeze({ Green:0,"0":"Green",Yellow:1,"1":"Yellow",Red:2,"2":"Red", });
export const Color = Object.freeze({
/**
* Green as a leaf.
*/
Green:0,"0":"Green",
/**
* Yellow as the sun.
*/
Yellow:1,"1":"Yellow",
/**
* Red as a rose.
*/
Red:2,"2":"Red", });

const __wbindgen_enum_ColorName = ["green", "yellow", "red"];

Expand Down
3 changes: 3 additions & 0 deletions crates/cli/tests/reference/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ use wasm_bindgen::prelude::*;
#[wasm_bindgen]
#[derive(PartialEq, Debug)]
pub enum Color {
/// Green as a leaf.
Green,
/// Yellow as the sun.
Yellow,
/// Red as a rose.
Red,
}

Expand Down

0 comments on commit b150020

Please sign in to comment.