From 0af9ee509357ae664e4fdce5916a61174864bf3b Mon Sep 17 00:00:00 2001 From: Jonas Pleyer Date: Sun, 25 Feb 2024 13:37:37 +0100 Subject: [PATCH] move docstrings to inline comments - also hide the count! macro, since it is only used as a helper --- plotters/blub.png | 3 ++ plotters/src/style/colors/colormaps.rs | 57 ++++++++++++-------------- 2 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 plotters/blub.png diff --git a/plotters/blub.png b/plotters/blub.png new file mode 100644 index 00000000..f65ee435 --- /dev/null +++ b/plotters/blub.png @@ -0,0 +1,3 @@ + + + diff --git a/plotters/src/style/colors/colormaps.rs b/plotters/src/style/colors/colormaps.rs index 1650bc68..27215b80 100644 --- a/plotters/src/style/colors/colormaps.rs +++ b/plotters/src/style/colors/colormaps.rs @@ -81,19 +81,19 @@ macro_rules! calculate_new_color_value( }; ); -/// Helper function to calculate the lower and upper index nearest to a provided float value. -/// -/// Used to obtain colors from a colorscale given a value h between 0.0 and 1.0. -/// It also returns the relative difference which can then be used to calculate a linear interpolation between the two nearest colors. -/// ``` -/// # use plotters::prelude::*; -/// let r = calculate_relative_difference_index_lower_upper(1.2, 1.0, 3.0, 4); -/// let (relative_difference, lower_index, upper_index) = r; -/// -/// assert_eq!(relative_difference, 0.7000000000000001); -/// assert_eq!(lower_index, 0); -/// assert_eq!(upper_index, 1); -/// ``` +// Helper function to calculate the lower and upper index nearest to a provided float value. +// +// Used to obtain colors from a colorscale given a value h between 0.0 and 1.0. +// It also returns the relative difference which can then be used to calculate a linear interpolation between the two nearest colors. +// ``` +// # use plotters::prelude::*; +// let r = calculate_relative_difference_index_lower_upper(1.2, 1.0, 3.0, 4); +// let (relative_difference, lower_index, upper_index) = r; +// +// assert_eq!(relative_difference, 0.7000000000000001); +// assert_eq!(lower_index, 0); +// assert_eq!(upper_index, 1); +// ``` #[doc(hidden)] pub fn calculate_relative_difference_index_lower_upper< FloatType: num_traits::Float + num_traits::FromPrimitive + num_traits::ToPrimitive, @@ -148,25 +148,22 @@ macro_rules! implement_color_scale_for_derived_color_map{ implement_color_scale_for_derived_color_map! {RGBAColor, RGBColor, HSLColor} -#[doc(inline)] -pub use crate::count; - #[macro_export] #[doc(hidden)] -/// Counts the number of arguments which are separated by spaces -/// -/// This macro is used internally to determine the size of an array to hold all new colors. -/// ``` -/// # use plotters::count; -/// let counted = count!{Plotting is fun}; -/// assert_eq!(counted, 3); -/// -/// let counted2 = count!{0_usize was my favourite 1_f64 last century}; -/// assert_eq!(counted2, 7); -/// -/// let new_array = ["Hello"; count!(Plotting is fun)]; -/// assert_eq!(new_array, ["Hello"; 3]); -/// ``` +// Counts the number of arguments which are separated by spaces +// +// This macro is used internally to determine the size of an array to hold all new colors. +// ``` +// # use plotters::count; +// let counted = count!{Plotting is fun}; +// assert_eq!(counted, 3); +// +// let counted2 = count!{0_usize was my favourite 1_f64 last century}; +// assert_eq!(counted2, 7); +// +// let new_array = ["Hello"; count!(Plotting is fun)]; +// assert_eq!(new_array, ["Hello"; 3]); +// ``` macro_rules! count { () => (0usize); ($x:tt $($xs:tt)* ) => (1usize + $crate::count!($($xs)*));