Skip to content

Commit 72b2d8e

Browse files
committed
fix: add error context and improve documentation for Markdown generation
- Add .with_context() to push_str() for consistency with other generators - Differentiate documentation comment for internal implementation function - Addresses Copilot PR review feedback
1 parent 6f4a409 commit 72b2d8e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

wit-bindgen-wasm/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,15 @@ impl WitBindgen {
429429
}
430430
}
431431

432-
/// Generate Markdown documentation using wit-bindgen-markdown library
432+
/// Internal implementation for generating Markdown documentation.
433+
///
434+
/// This function performs the actual Markdown generation using the wit-bindgen-markdown library.
435+
/// It returns a `Result` containing a map of generated files, or an error if generation fails.
433436
fn generate_markdown_with_wit_bindgen(&self, content: &str, world_name: Option<&str>) -> Result<HashMap<String, String>, anyhow::Error> {
434437
let inline_path = Path::new("inline.wit");
435438
let mut resolve = Resolve::default();
436-
let package_id = resolve.push_str(inline_path, content)?;
439+
let package_id = resolve.push_str(inline_path, content)
440+
.with_context(|| "Failed to parse WIT content for Markdown generation")?;
437441

438442
let world_id = if let Some(world_name) = world_name {
439443
resolve.select_world(&[package_id], Some(world_name))?

0 commit comments

Comments
 (0)