Skip to content

Commit b150020

Browse files
Properly indent the doc comments of enum variants (rustwasm#4153)
1 parent 95bf437 commit b150020

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

crates/cli-support/src/js/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3794,7 +3794,11 @@ __wbg_set_wasm(wasm);"
37943794
if enum_.generate_typescript {
37953795
self.typescript.push('\n');
37963796
if !variant_docs.is_empty() {
3797-
self.typescript.push_str(&variant_docs);
3797+
for line in variant_docs.lines() {
3798+
self.typescript.push_str(" ");
3799+
self.typescript.push_str(line);
3800+
self.typescript.push('\n');
3801+
}
37983802
}
37993803
self.typescript.push_str(&format!(" {name} = {value},"));
38003804
}

crates/cli/tests/reference/enums.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@ export function option_string_enum_echo(color?: ColorName): ColorName | undefine
2424
* A color.
2525
*/
2626
export enum Color {
27+
/**
28+
* Green as a leaf.
29+
*/
2730
Green = 0,
31+
/**
32+
* Yellow as the sun.
33+
*/
2834
Yellow = 1,
35+
/**
36+
* Red as a rose.
37+
*/
2938
Red = 2,
3039
}
3140
/**

crates/cli/tests/reference/enums.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,19 @@ export function option_string_enum_echo(color) {
6565
/**
6666
* A color.
6767
*/
68-
export const Color = Object.freeze({ Green:0,"0":"Green",Yellow:1,"1":"Yellow",Red:2,"2":"Red", });
68+
export const Color = Object.freeze({
69+
/**
70+
* Green as a leaf.
71+
*/
72+
Green:0,"0":"Green",
73+
/**
74+
* Yellow as the sun.
75+
*/
76+
Yellow:1,"1":"Yellow",
77+
/**
78+
* Red as a rose.
79+
*/
80+
Red:2,"2":"Red", });
6981

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

crates/cli/tests/reference/enums.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ use wasm_bindgen::prelude::*;
44
#[wasm_bindgen]
55
#[derive(PartialEq, Debug)]
66
pub enum Color {
7+
/// Green as a leaf.
78
Green,
9+
/// Yellow as the sun.
810
Yellow,
11+
/// Red as a rose.
912
Red,
1013
}
1114

0 commit comments

Comments
 (0)