Skip to content

Commit 9b285cc

Browse files
authored
wit-parser: inject package metadata when decoding component (#2443)
* fix: inject package metadata when decoding component * test: component wit docs roundtrip
1 parent b3666ed commit 9b285cc

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

crates/wit-parser/src/decoding.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ impl ComponentInfo {
343343
}
344344
}
345345

346-
let (resolve, _) = decoder.finish(package);
346+
let (mut resolve, pkg) = decoder.finish(package);
347+
if let Some(package_metadata) = &self.package_metadata {
348+
package_metadata.inject(&mut resolve, pkg)?;
349+
}
347350
Ok((resolve, world))
348351
}
349352
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: component wit % --wasm | component wit
2+
3+
package foo:docs-test;
4+
5+
/// The interface.
6+
interface my-interface {
7+
/// The function.
8+
my-func: func(
9+
/// The function's argument.
10+
my-arg: string,
11+
) -> string;
12+
}
13+
14+
/// A world with documentation.
15+
world my-world {
16+
export my-interface;
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// RUN: component wit % --wasm | component wit
2+
package foo:docs-test;
3+
4+
/// The interface.
5+
interface my-interface {
6+
/// The function.
7+
my-func: func(my-arg: string) -> string;
8+
}
9+
10+
/// A world with documentation.
11+
world my-world {
12+
export my-interface;
13+
}

0 commit comments

Comments
 (0)