diff options
author | Minijackson <minijackson@riseup.net> | 2020-01-19 16:04:20 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2020-01-19 16:04:20 +0100 |
commit | 67720a789e0de3583bf805bfc5b2f99e6ab42f7a (patch) | |
tree | ce949c5ec1bb7a292a3ea052c944e6b35c7bc71f | |
parent | 7ca8ead3627721ba36e85429ae9b6dfc6d17fab6 (diff) | |
download | poseidoc-67720a789e0de3583bf805bfc5b2f99e6ab42f7a.tar.gz poseidoc-67720a789e0de3583bf805bfc5b2f99e6ab42f7a.zip |
clang-parser: parse `//!` style doc-comments
-rw-r--r-- | src/parser/clang/parsing.rs | 9 |
1 files 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 { | |||
897 | enum CommentStyle { | 897 | enum CommentStyle { |
898 | // Comments of type `/**` or `/*!` | 898 | // Comments of type `/**` or `/*!` |
899 | Starred, | 899 | Starred, |
900 | // Comments of type `///` | 900 | // Comments of type `///` or `//!` |
901 | SingleLine, | 901 | SingleLine, |
902 | } | 902 | } |
903 | 903 | ||
904 | let mut chars = raw.chars(); | 904 | let mut chars = raw.chars(); |
905 | let style = match &chars.as_str()[..3] { | 905 | let style = match &chars.as_str()[..3] { |
906 | "/*!" | "/**" => CommentStyle::Starred, | 906 | "/*!" | "/**" => CommentStyle::Starred, |
907 | "///" => CommentStyle::SingleLine, | 907 | "///" | "//!" => CommentStyle::SingleLine, |
908 | _ => panic!("Comment is empty or doesn't start with either `///`, `/**`, or `/*!`"), | 908 | _ => panic!("Comment is empty or doesn't start with either `///`, `//!`, `/**`, or `/*!`"), |
909 | }; | 909 | }; |
910 | 910 | ||
911 | chars.nth(2); | 911 | chars.nth(2); |
@@ -950,6 +950,7 @@ pub fn parse_comment(raw: String) -> String { | |||
950 | } | 950 | } |
951 | }; | 951 | }; |
952 | 952 | ||
953 | // `chars` is right after the first non whitespace character | ||
953 | match style { | 954 | match style { |
954 | CommentStyle::Starred if first_non_ws_ch == '*' => { | 955 | CommentStyle::Starred if first_non_ws_ch == '*' => { |
955 | if &chars.as_str()[..1] == "/" { | 956 | if &chars.as_str()[..1] == "/" { |
@@ -960,7 +961,7 @@ pub fn parse_comment(raw: String) -> String { | |||
960 | CommentStyle::SingleLine => { | 961 | CommentStyle::SingleLine => { |
961 | assert!(first_non_ws_ch == '/'); | 962 | assert!(first_non_ws_ch == '/'); |
962 | let rest = chars.as_str(); | 963 | let rest = chars.as_str(); |
963 | if &rest[..2] == "//" { | 964 | if &rest[..2] == "//" || &rest[..2] == "/!" { |
964 | chars.nth(1); | 965 | chars.nth(1); |
965 | } else if &rest[..1] == "/" { | 966 | } else if &rest[..1] == "/" { |
966 | chars.nth(0); | 967 | chars.nth(0); |