@@ -233,14 +233,20 @@ impl AttrItem {
233233
234234impl Attribute {
235235 /// 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`.
237238 pub fn is_doc_comment ( & self ) -> bool {
238239 match self . kind {
239240 AttrKind :: Normal ( ..) => false ,
240241 AttrKind :: DocComment ( ..) => true ,
241242 }
242243 }
243244
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`.
244250 pub fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > {
245251 match self . kind {
246252 AttrKind :: DocComment ( kind, data) => Some ( ( data, kind) ) ,
@@ -253,6 +259,10 @@ impl Attribute {
253259 }
254260 }
255261
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`.
256266 pub fn doc_str ( & self ) -> Option < Symbol > {
257267 match self . kind {
258268 AttrKind :: DocComment ( .., data) => Some ( data) ,
0 commit comments