Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

Commit d80d7df

Browse files
author
David Boles
committed
Update documentation for #57
1 parent 2ee7b01 commit d80d7df

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ The precise Unicode conversions are as defined by [`str::to_lowercase`] and
117117

118118
<br>
119119

120-
## Pasting documentation strings
120+
## Pasting string literals into attributes
121121

122-
Within the `paste!` macro, arguments to a #\[doc ...\] attribute are implicitly
123-
concatenated together to form a coherent documentation string.
122+
Within the `paste!` macro, if there are two or more arguments to an attribute they are implicitly
123+
concatenated together to form a string literal.
124124

125125
```rust
126126
use paste::paste;
@@ -129,14 +129,18 @@ macro_rules! method_new {
129129
($ret:ident) => {
130130
paste! {
131131
#[doc = "Create a new `" $ret "` object."]
132+
#[cfg(feature = "" $ret:snake)]
132133
pub fn new() -> $ret { todo!() }
133134
}
134135
};
135136
}
136137

137138
pub struct Paste {}
138139

139-
method_new!(Paste); // expands to #[doc = "Create a new `Paste` object"]
140+
// expands to:
141+
// #[doc = "Create a new `Paste` object."]
142+
// #[cfg(feature = "paste")]
143+
method_new!(Paste);
140144
```
141145

142146
<br>

src/lib.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,30 @@
115115
//!
116116
//! <br>
117117
//!
118-
//! # Pasting documentation strings
119-
//!
120-
//! Within the `paste!` macro, arguments to a #\[doc ...\] attribute are
121-
//! implicitly concatenated together to form a coherent documentation string.
122-
//!
118+
//! ## Pasting string literals into attributes
119+
//!
120+
//! Within the `paste!` macro, if there are two or more arguments to an attribute they are implicitly
121+
//! concatenated together to form a string literal.
122+
//!
123123
//! ```
124124
//! use paste::paste;
125-
//!
125+
//!
126126
//! macro_rules! method_new {
127127
//! ($ret:ident) => {
128128
//! paste! {
129129
//! #[doc = "Create a new `" $ret "` object."]
130+
//! #[cfg(feature = "" $ret:snake)]
130131
//! pub fn new() -> $ret { todo!() }
131132
//! }
132133
//! };
133134
//! }
134-
//!
135+
//!
135136
//! pub struct Paste {}
136-
//!
137-
//! method_new!(Paste); // expands to #[doc = "Create a new `Paste` object"]
137+
//!
138+
//! // expands to:
139+
//! // #[doc = "Create a new `Paste` object."]
140+
//! // #[cfg(feature = "paste")]
141+
//! method_new!(Paste);
138142
//! ```
139143
140144
#![doc(html_root_url = "https://docs.rs/paste/1.0.15")]

0 commit comments

Comments
 (0)