From 67720a789e0de3583bf805bfc5b2f99e6ab42f7a Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 19 Jan 2020 16:04:20 +0100 Subject: clang-parser: parse `//!` style doc-comments --- src/parser/clang/parsing.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/parser/clang/parsing.rs b/src/parser/clang/parsing.rs index fd3e392..6883d06 100644 --- a/src/parser/clang/parsing.rs +++ b/src/parser/clang/parsing.rs @@ -897,15 +897,15 @@ pub fn parse_comment(raw: String) -> String { enum CommentStyle { // Comments of type `/**` or `/*!` Starred, - // Comments of type `///` + // Comments of type `///` or `//!` SingleLine, } let mut chars = raw.chars(); let style = match &chars.as_str()[..3] { "/*!" | "/**" => CommentStyle::Starred, - "///" => CommentStyle::SingleLine, - _ => panic!("Comment is empty or doesn't start with either `///`, `/**`, or `/*!`"), + "///" | "//!" => CommentStyle::SingleLine, + _ => panic!("Comment is empty or doesn't start with either `///`, `//!`, `/**`, or `/*!`"), }; chars.nth(2); @@ -950,6 +950,7 @@ pub fn parse_comment(raw: String) -> String { } }; + // `chars` is right after the first non whitespace character match style { CommentStyle::Starred if first_non_ws_ch == '*' => { if &chars.as_str()[..1] == "/" { @@ -960,7 +961,7 @@ pub fn parse_comment(raw: String) -> String { CommentStyle::SingleLine => { assert!(first_non_ws_ch == '/'); let rest = chars.as_str(); - if &rest[..2] == "//" { + if &rest[..2] == "//" || &rest[..2] == "/!" { chars.nth(1); } else if &rest[..1] == "/" { chars.nth(0); -- cgit v1.2.3