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