Skip to content

Commit

Permalink
Mention serde impls explicitly in #[doc(cfg)]
Browse files Browse the repository at this point in the history
This can be done even if `serde` feature is disabled during docs publishing, would just be no-op.
  • Loading branch information
Bromeon committed May 24, 2024
1 parent 41ccbe8 commit 0a9c7fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions godot-core/src/builtin/string/gstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ mod serialize {
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt::Formatter;

// For "Available on crate feature `serde`" in docs. Cannot be inherited from module. Also does not support #[derive] (e.g. in Vector2).
#[cfg_attr(published_docs, doc(cfg(feature = "serde")))]
impl Serialize for GString {
#[inline]
fn serialize<S>(
Expand All @@ -361,8 +363,8 @@ mod serialize {
}
}

#[cfg(feature = "serde")]
impl<'de> serialize::Deserialize<'de> for GString {
#[cfg_attr(published_docs, doc(cfg(feature = "serde")))]
impl<'de> Deserialize<'de> for GString {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
where
Expand Down
3 changes: 3 additions & 0 deletions godot-core/src/builtin/string/node_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ mod serialize {
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt::Formatter;

// For "Available on crate feature `serde`" in docs. Cannot be inherited from module. Also does not support #[derive] (e.g. in Vector2).
#[cfg_attr(published_docs, doc(cfg(feature = "serde")))]
impl Serialize for NodePath {
#[inline]
fn serialize<S>(
Expand All @@ -172,6 +174,7 @@ mod serialize {
}
}

#[cfg_attr(published_docs, doc(cfg(feature = "serde")))]
impl<'de> Deserialize<'de> for NodePath {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
Expand Down
5 changes: 4 additions & 1 deletion godot-core/src/builtin/string/string_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ mod serialize {
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt::Formatter;

// For "Available on crate feature `serde`" in docs. Cannot be inherited from module. Also does not support #[derive] (e.g. in Vector2).
#[cfg_attr(published_docs, doc(cfg(feature = "serde")))]
impl Serialize for StringName {
#[inline]
fn serialize<S>(
Expand All @@ -378,7 +380,8 @@ mod serialize {
}
}

impl<'de> serialize::Deserialize<'de> for StringName {
#[cfg_attr(published_docs, doc(cfg(feature = "serde")))]
impl<'de> Deserialize<'de> for StringName {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
where
Expand Down

0 comments on commit 0a9c7fb

Please sign in to comment.