From 9718c649526a47561f58625d1a0286e1f6117d9d Mon Sep 17 00:00:00 2001 From: Anand Krishnamoorthi Date: Tue, 21 May 2024 16:39:32 -0700 Subject: [PATCH] Use correct docsrs feature annotation Signed-off-by: Anand Krishnamoorthi --- src/engine.rs | 7 ++++--- src/lib.rs | 1 - src/value.rs | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/engine.rs b/src/engine.rs index 5d72089f..f9b164f8 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -95,6 +95,7 @@ impl Engine { /// # } /// ``` #[cfg(feature = "std")] + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn add_policy_from_file>(&mut self, path: P) -> Result { let source = Source::from_file(path)?; let mut parser = Parser::new(&source)?; @@ -644,7 +645,7 @@ impl Engine { } #[cfg(feature = "coverage")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "coverage")))] + #[cfg_attr(docsrs, doc(cfg(feature = "coverage")))] /// Get the coverage report. /// /// ```rust @@ -688,7 +689,7 @@ impl Engine { } #[cfg(feature = "coverage")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "coverage")))] + #[cfg_attr(docsrs, doc(cfg(feature = "coverage")))] /// Enable/disable policy coverage. /// /// If `enable` is different from the current value, then any existing coverage @@ -698,7 +699,7 @@ impl Engine { } #[cfg(feature = "coverage")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "coverage")))] + #[cfg_attr(docsrs, doc(cfg(feature = "coverage")))] /// Clear the gathered policy coverage data. pub fn clear_coverage_data(&mut self) { self.interpreter.clear_coverage_data() diff --git a/src/lib.rs b/src/lib.rs index a63befbe..16c30d61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,6 @@ // Use README.md as crate documentation. #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] -#![cfg_attr(docsrs, feature(doc_cfg))] // We'll default to building for no_std - use core, alloc instead of std. #![no_std] diff --git a/src/value.rs b/src/value.rs index 758368ca..8000b766 100644 --- a/src/value.rs +++ b/src/value.rs @@ -327,6 +327,7 @@ impl Value { /// # } /// ``` #[cfg(feature = "std")] + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn from_json_file>(path: P) -> Result { match std::fs::read_to_string(&path) { Ok(c) => Self::from_json_str(c.as_str()), @@ -400,6 +401,7 @@ impl Value { /// Deserialize a value from YAML. /// Note: Deserialization from YAML does not support arbitrary precision numbers. #[cfg(feature = "yaml")] + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn from_yaml_str(yaml: &str) -> Result { Ok(serde_yaml::from_str(yaml)?) } @@ -408,6 +410,8 @@ impl Value { /// Note: Deserialization from YAML does not support arbitrary precision numbers. #[cfg(feature = "std")] #[cfg(feature = "yaml")] + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] + #[cfg_attr(docsrs, doc(cfg(feature = "yaml")))] pub fn from_yaml_file(path: &String) -> Result { match std::fs::read_to_string(path) { Ok(c) => Self::from_yaml_str(c.as_str()), @@ -609,6 +613,7 @@ impl From for Value { } #[cfg(feature = "yaml")] +#[cfg_attr(docsrs, doc(cfg(feature = "yaml")))] impl From for Value { /// Create a [`Value`] from [`serde_yaml::Value`]. ///