Skip to content

Commit

Permalink
move docstrings to inline comments
Browse files Browse the repository at this point in the history
- also hide the count! macro, since it is only used as a helper
  • Loading branch information
jonaspleyer committed Feb 26, 2024
1 parent 3d3eebb commit 0af9ee5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
3 changes: 3 additions & 0 deletions plotters/blub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 27 additions & 30 deletions plotters/src/style/colors/colormaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)*));
Expand Down

0 comments on commit 0af9ee5

Please sign in to comment.