@@ -233,14 +233,20 @@ impl AttrItem {
233
233
234
234
impl Attribute {
235
235
/// Returns `true` if it is a sugared doc comment (`///` or `//!` for example).
236
- /// So `#[doc = "doc"]` will return `false`.
236
+ /// So `#[doc = "doc"]` (which is a doc comment) and `#[doc(...)]` (which is not
237
+ /// a doc comment) will return `false`.
237
238
pub fn is_doc_comment ( & self ) -> bool {
238
239
match self . kind {
239
240
AttrKind :: Normal ( ..) => false ,
240
241
AttrKind :: DocComment ( ..) => true ,
241
242
}
242
243
}
243
244
245
+ /// Returns the documentation and its kind if this is a doc comment or a sugared doc comment.
246
+ /// * `///doc` returns `Some(("doc", CommentKind::Line))`.
247
+ /// * `/** doc */` returns `Some(("doc", CommentKind::Block))`.
248
+ /// * `#[doc = "doc"]` returns `Some(("doc", CommentKind::Line))`.
249
+ /// * `#[doc(...)]` returns `None`.
244
250
pub fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > {
245
251
match self . kind {
246
252
AttrKind :: DocComment ( kind, data) => Some ( ( data, kind) ) ,
@@ -253,6 +259,10 @@ impl Attribute {
253
259
}
254
260
}
255
261
262
+ /// Returns the documentation if this is a doc comment or a sugared doc comment.
263
+ /// * `///doc` returns `Some("doc")`.
264
+ /// * `#[doc = "doc"]` returns `Some("doc")`.
265
+ /// * `#[doc(...)]` returns `None`.
256
266
pub fn doc_str ( & self ) -> Option < Symbol > {
257
267
match self . kind {
258
268
AttrKind :: DocComment ( .., data) => Some ( data) ,
0 commit comments