Skip to content

Commit

Permalink
Use 'doc_cfg' only when building docs.
Browse files Browse the repository at this point in the history
Resolves #177.
  • Loading branch information
SergioBenitez committed Jul 14, 2021
1 parent 97fd2b6 commit 4d1ede6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl CookieJar {
/// assert!(jar.get("private").is_some());
/// ```
#[cfg(feature = "private")]
#[cfg_attr(nightly, doc(cfg(feature = "private")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "private")))]
pub fn private<'a>(&'a self, key: &Key) -> PrivateJar<&'a Self> {
PrivateJar::new(self, key)
}
Expand Down Expand Up @@ -438,7 +438,7 @@ impl CookieJar {
/// jar.private_mut(&key).remove(Cookie::named("private"));
/// ```
#[cfg(feature = "private")]
#[cfg_attr(nightly, doc(cfg(feature = "private")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "private")))]
pub fn private_mut<'a>(&'a mut self, key: &Key) -> PrivateJar<&'a mut Self> {
PrivateJar::new(self, key)
}
Expand Down Expand Up @@ -473,7 +473,7 @@ impl CookieJar {
/// assert!(jar.get("signed").is_some());
/// ```
#[cfg(feature = "signed")]
#[cfg_attr(nightly, doc(cfg(feature = "signed")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "signed")))]
pub fn signed<'a>(&'a self, key: &Key) -> SignedJar<&'a Self> {
SignedJar::new(self, key)
}
Expand All @@ -500,7 +500,7 @@ impl CookieJar {
/// jar.signed_mut(&key).remove(Cookie::named("signed"));
/// ```
#[cfg(feature = "signed")]
#[cfg_attr(nightly, doc(cfg(feature = "signed")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "signed")))]
pub fn signed_mut<'a>(&'a mut self, key: &Key) -> SignedJar<&'a mut Self> {
SignedJar::new(self, key)
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
//! features = ["secure", "percent-encode"]
//! ```

#![cfg_attr(nightly, feature(doc_cfg))]
#![cfg_attr(all(nightly, doc), feature(doc_cfg))]

#![doc(html_root_url = "https://docs.rs/cookie/0.15")]
#![deny(missing_docs)]
Expand Down Expand Up @@ -308,7 +308,7 @@ impl<'c> Cookie<'c> {
/// assert_eq!(c.http_only(), Some(true));
/// ```
#[cfg(feature = "percent-encode")]
#[cfg_attr(nightly, doc(cfg(feature = "percent-encode")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "percent-encode")))]
pub fn parse_encoded<S>(s: S) -> Result<Cookie<'c>, ParseError>
where S: Into<Cow<'c, str>>
{
Expand Down Expand Up @@ -1095,7 +1095,7 @@ impl<'c> Cookie<'c> {
/// assert_eq!(&c.encoded().stripped().to_string(), "my%20name=this%3B%20value%3F");
/// ```
#[cfg(feature = "percent-encode")]
#[cfg_attr(nightly, doc(cfg(feature = "percent-encode")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "percent-encode")))]
#[inline(always)]
pub fn encoded<'a>(&'a self) -> Display<'a, 'c> {
Display::new_encoded(self)
Expand Down Expand Up @@ -1214,7 +1214,7 @@ impl<'a, 'c> Display<'a, 'c> {
/// Percent-encode the name and value pair.
#[inline]
#[cfg(feature = "percent-encode")]
#[cfg_attr(nightly, doc(cfg(feature = "percent-encode")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "percent-encode")))]
pub fn encoded(mut self) -> Self {
self.encode = true;
self
Expand Down
4 changes: 2 additions & 2 deletions src/secure/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const_assert!(crate::secure::private::KEY_LEN == ENCRYPTION_KEY_LEN);
/// [`PrivateJar`](crate::PrivateJar) and [`SignedJar`](crate::SignedJar). A
/// single instance of a `Key` can be used for both a `PrivateJar` and a
/// `SignedJar` simultaneously with no notable security implications.
#[cfg_attr(nightly, doc(cfg(any(feature = "private", feature = "signed"))))]
#[cfg_attr(all(nightly, doc), doc(cfg(any(feature = "private", feature = "signed"))))]
#[derive(Clone)]
pub struct Key([u8; COMBINED_KEY_LENGTH /* SIGNING | ENCRYPTION */]);

Expand Down Expand Up @@ -86,7 +86,7 @@ impl Key {
/// let key = Key::derive_from(master_key);
/// ```
#[cfg(feature = "key-expansion")]
#[cfg_attr(nightly, doc(cfg(feature = "key-expansion")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "key-expansion")))]
pub fn derive_from(master_key: &[u8]) -> Self {
if master_key.len() < 32 {
panic!("bad master key length: expected >= 32 bytes, found {}", master_key.len());
Expand Down
2 changes: 1 addition & 1 deletion src/secure/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) const KEY_LEN: usize = 32;
/// `PrivateJar` are simultaneously assured confidentiality, integrity, and
/// authenticity. In other words, clients cannot discover nor tamper with the
/// contents of a cookie, nor can they fabricate cookie data.
#[cfg_attr(nightly, doc(cfg(feature = "private")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "private")))]
pub struct PrivateJar<J> {
parent: J,
key: [u8; KEY_LEN]
Expand Down
2 changes: 1 addition & 1 deletion src/secure/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) const KEY_LEN: usize = 32;
/// integrity and authenticity. In other words, clients cannot tamper with the
/// contents of a cookie nor can they fabricate cookie values, but the data is
/// visible in plaintext.
#[cfg_attr(nightly, doc(cfg(feature = "signed")))]
#[cfg_attr(all(nightly, doc), doc(cfg(feature = "signed")))]
pub struct SignedJar<J> {
parent: J,
key: [u8; KEY_LEN],
Expand Down

0 comments on commit 4d1ede6

Please sign in to comment.