Checks if an attribute's [`syn::Meta`] property is a name-value pair, like `doc = "Single line doc comments"`. if so, continues to check that the value (.e.g. "Single line doc comments") is a valid [`proc_macro2::TokenTree::Literal`], if so, add it to the collection of comment strings.
(attr: &syn::Attribute)
| 149 | /// (.e.g. "Single line doc comments") is a valid [`proc_macro2::TokenTree::Literal`], |
| 150 | /// if so, add it to the collection of comment strings. |
| 151 | fn check_doc_attribute(attr: &syn::Attribute) -> Vec<String> { |
| 152 | // Check if the attribute's meta is a NameValue, otherwise return |
| 153 | // right away. |
| 154 | let syn::Meta::NameValue(ref nv) = attr.meta else { |
| 155 | return Default::default(); |
| 156 | }; |
| 157 | |
| 158 | // Convert the value to a token stream, then iterate it, collecting |
| 159 | // only valid comment string. |
| 160 | nv.value |
| 161 | .to_token_stream() |
| 162 | .into_iter() |
| 163 | .filter_map(check_doc_tokens) |
| 164 | .collect::<Vec<String>>() |
| 165 | } |
| 166 | |
| 167 | /// Get the doc string comments from the syn::attributes |
| 168 | /// note: the compiler transforms doc comments into attributes |
nothing calls this directly
no outgoing calls
no test coverage detected