Skip to content

Commit

Permalink
Silently ignore non-doc-comment comments.
Browse files Browse the repository at this point in the history
As part of bytecodealliance#1362, silently ignore comments
that aren't `///` comments. This won't break any actual code; it just
means that documentation comments won't show up in generated bindings
unless the `///` syntax is used.

All wit files I've seen already use `///` syntax for comments, so I
expect the impact of this change will be low.
  • Loading branch information
sunfishcode committed Jan 9, 2024
1 parent 0616ef1 commit d1fd637
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/wit-parser/src/ast/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,10 +1280,9 @@ impl<'a> Resolver<'a> {
fn docs(&mut self, doc: &super::Docs<'_>) -> Docs {
let mut lines = vec![];
for doc in doc.docs.iter() {
if let Some(doc) = doc.strip_prefix("/**") {
lines.push(doc.strip_suffix("*/").unwrap().trim());
} else {
lines.push(doc.trim_start_matches('/').trim());
// Comments which are not doc-comments are silently ignored
if let Some(doc) = doc.strip_prefix("/// ") {
lines.push(doc);
}
}
let contents = if lines.is_empty() {
Expand Down

0 comments on commit d1fd637

Please sign in to comment.