GeezerVison is showing github.com — Fix pedantic doc/lazy-static lints and add_frames duplication · dathere/plotly@a21da1f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: CHANGELOG.md +6Lines changed: 6 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -31,12 +31,18 @@ This is the last release bundling plotly.js 3.x; the upgrade to plotly.js 4.x is | 31 | 31 | - `plotly_static` bumped to 0.2.0 (breaking: `ImageFormat::EPS` removed) | 32 | 32 | - Bump `darling` to 0.24 and `syn` to 3 in `plotly_derive`, and `dirs` to 7 in `plotly_static` | 33 | 33 | - Bump example dependencies: `reqwest` 0.13, `env_logger` 0.11, `itertools` 0.15, `ndarray` 0.17, `rand`/`rand_chacha` 0.10 | | 34 | +- Theme statics in `plotly::layout::themes` (`DEFAULT`, `PLOTLY_WHITE`, `PLOTLY_DARK`, …) are now `std::sync::LazyLock<Template>` instead of `once_cell::sync::Lazy<Template>`; the `once_cell` dependency is dropped. Code that only dereferences them is unaffected | | 35 | +- Add `# Errors`/`# Panics` sections to public fallible APIs and tidy doc formatting (clippy `missing_errors_doc`, `missing_panics_doc`, `doc_markdown`) | 34 | 36 |
| 35 | 37 | ### Removed | 36 | 38 |
| 37 | 39 | - The deprecated Kaleido static export backend: the `plotly_kaleido` crate is no longer part of the workspace, and the `kaleido` and `kaleido_download` features are gone. Use the `static_export_*` features (`plotly_static`) instead | 38 | 40 | - The deprecated `ImageFormat::EPS` variant. Use `ImageFormat::SVG` or `ImageFormat::PDF` for vector output | 39 | 41 |
| | 42 | +### Fixed | | 43 | + | | 44 | +- `Plot::add_frames` no longer adds every frame twice when the plot has no frames yet | | 45 | + | 40 | 46 | ### Security | 41 | 47 |
| 42 | 48 | - Remove the unused `zip` build-dependency from `plotly_static`; with `plotly_kaleido` gone, no workspace crate depends on `zip` directly | |
Collapse file Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +doc-valid-idents = ["WebDriver", "MapLibre", "GeoJSON", "MathJax", "ModeBar", ".."] |
Collapse file Copy file name to clipboardExpand all lines: plotly/Cargo.toml -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,7 +8,6 @@ authors = [ | 8 | 8 | ] | 9 | 9 | license = "MIT" | 10 | 10 | readme = "../README.md" | 11 | | -homepage = "https://github.com/plotly/plotly.rs" | 12 | 11 | documentation = "https://docs.rs/plotly" | 13 | 12 | repository = "https://github.com/plotly/plotly.rs" | 14 | 13 | edition = "2021" | @@ -57,7 +56,6 @@ image = { version = "0.25", optional = true } | 57 | 56 | plotly_derive = { version = "0.15", path = "../plotly_derive" } | 58 | 57 | plotly_static = { version = "0.2", path = "../plotly_static", optional = true } | 59 | 58 | ndarray = { version = "0.17", optional = true } | 60 | | -once_cell = "1" | 61 | 59 | serde = { version = "1.0", features = ["derive"] } | 62 | 60 | serde_json = "1.0" | 63 | 61 | serde_repr = "0.1" | |
Collapse file Copy file name to clipboardExpand all lines: plotly/src/bindings.rs +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,6 +22,11 @@ extern "C" { | 22 | 22 | /// The function signature is slightly constrained in that `id` is a `&str` | 23 | 23 | /// which represents the `id` of an existing HTML `div` element, rather than | 24 | 24 | /// also allowing an instance of a `div` element, itself. | | 25 | +/// | | 26 | +/// # Panics | | 27 | +/// | | 28 | +/// Panics if plotly.js rejects the plot (e.g. no element with the given `id` | | 29 | +/// exists). | 25 | 30 | pub async fn new_plot(id: &str, plot: &Plot) { | 26 | 31 | let plot_obj = &plot.to_js_object(); | 27 | 32 |
| @@ -37,6 +42,11 @@ pub async fn new_plot(id: &str, plot: &Plot) { | 37 | 42 | /// The function signature is slightly constrained in that `id` is a `&str` | 38 | 43 | /// which represents the `id` of an existing HTML `div` element, rather than | 39 | 44 | /// also allowing an instance of a `div` element, itself. | | 45 | +/// | | 46 | +/// # Panics | | 47 | +/// | | 48 | +/// Panics if plotly.js rejects the plot (e.g. no element with the given `id` | | 49 | +/// exists). | 40 | 50 | pub async fn react(id: &str, plot: &Plot) { | 41 | 51 | let plot_obj = &plot.to_js_object(); | 42 | 52 |
| |
Collapse file Copy file name to clipboardExpand all lines: plotly/src/callbacks.rs +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -57,6 +57,12 @@ extern "C" { | 57 | 57 | /// web_sys::console::log_1(&format!("{:?}", evt).into()); | 58 | 58 | /// }); | 59 | 59 | /// ``` | | 60 | +/// | | 61 | +/// # Panics | | 62 | +/// | | 63 | +/// Panics if no element with the given `div_id` exists. The registered | | 64 | +/// listener panics if a click event cannot be deserialized into | | 65 | +/// `ClickEvent`. | 60 | 66 | pub fn bind_click<F>(div_id: &str, mut cb: F) | 61 | 67 | where | 62 | 68 | F: 'static + FnMut(ClickEvent), | |
Collapse file Copy file name to clipboardExpand all lines: plotly/src/common/color.rs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,9 +49,9 @@ impl Color for i16 {} | 49 | 49 | impl Color for i8 {} | 50 | 50 | impl Color for usize {} | 51 | 51 |
| 52 | | -/// ColorArray is only used internally to provide a helper method for converting | 53 | | -/// Vec<impl Color> to Vec<Box<dyn Color>>, as we would otherwise fall foul of | 54 | | -/// the orphan rules. | | 52 | +/// `ColorArray` is only used internally to provide a helper method for | | 53 | +/// converting Vec<impl Color> to Vec<Box<dyn Color>>, as we would otherwise | | 54 | +/// fall foul of the orphan rules. | 55 | 55 | pub(crate) struct ColorArray<C: Color>(pub(crate) Vec<C>); | 56 | 56 |
| 57 | 57 | #[allow(clippy::from_over_into)] | |
Collapse file Copy file name to clipboardExpand all lines: plotly/src/configuration.rs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -211,8 +211,8 @@ impl Configuration { | 211 | 211 |
| 212 | 212 | /// When set it determines base URL for the "Edit in Chart Studio" | 213 | 213 | /// `show_edit_in_chart_studio`/`show_send_to_cloud` mode bar button and | 214 | | - /// the show_link/send_data on-graph link. To enable sending your data to | 215 | | - /// Chart Studio Cloud, you need to set both `plotly_server_url` to <https://chart-studio.plotly.com> and | | 214 | + /// the `show_link`/`send_data` on-graph link. To enable sending your data | | 215 | + /// to Chart Studio Cloud, you need to set both `plotly_server_url` to <https://chart-studio.plotly.com> and | 216 | 216 | /// also set `showSendToCloud` to `true`. | 217 | 217 | pub fn plotly_server_url(mut self, plotly_server_url: &str) -> Self { | 218 | 218 | self.plotly_server_url = Some(plotly_server_url.to_string()); | @@ -228,7 +228,7 @@ impl Configuration { | 228 | 228 | } | 229 | 229 |
| 230 | 230 | /// Determines whether the graphs are plotted with respect to | 231 | | - /// layout.auto_size: true and infer its container size. | | 231 | + /// `layout.auto_size: true` and infer its container size. | 232 | 232 | pub fn autosizable(mut self, autosizable: bool) -> Self { | 233 | 233 | self.autosizable = Some(autosizable); | 234 | 234 | self | |
Collapse file Copy file name to clipboardExpand all lines: plotly/src/export.rs +24-9Lines changed: 24 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,9 +7,9 @@ pub mod sync { | 7 | 7 | /// Extension methods for exporting plots using a synchronous exporter. | 8 | 8 | pub trait ExporterSyncExt { | 9 | 9 | /// Convert the `Plot` to a static image of the given image format and | 10 | | - /// save at the given location using a provided StaticExporter. | | 10 | + /// save at the given location using a provided `StaticExporter`. | 11 | 11 | /// | 12 | | - /// This method allows you to reuse a StaticExporter instance across | | 12 | + /// This method allows you to reuse a `StaticExporter` instance across | 13 | 13 | /// multiple plots, which is more efficient than creating a new one for | 14 | 14 | /// each operation. | 15 | 15 | /// | @@ -18,7 +18,7 @@ pub mod sync { | 18 | 18 | /// | 19 | 19 | /// # Arguments | 20 | 20 | /// | 21 | | - /// * `exporter` - A mutable reference to a StaticExporter instance | | 21 | + /// * `exporter` - A mutable reference to a `StaticExporter` instance | 22 | 22 | /// * `filename` - The destination path for the output file | 23 | 23 | /// * `format` - The desired output image format | 24 | 24 | /// * `width` - The width of the output image in pixels | @@ -45,6 +45,11 @@ pub mod sync { | 45 | 45 | /// | 46 | 46 | /// exporter.close(); | 47 | 47 | /// ``` | | 48 | + /// | | 49 | + /// # Errors | | 50 | + /// | | 51 | + /// Returns an error if the export fails, if the image file cannot be | | 52 | + /// written, or if called from within an async (Tokio) context. | 48 | 53 | fn write_image<P: AsRef<Path>>( | 49 | 54 | &mut self, | 50 | 55 | plot: &Plot, | @@ -56,10 +61,10 @@ pub mod sync { | 56 | 61 | ) -> Result<(), Box<dyn std::error::Error>>; | 57 | 62 |
| 58 | 63 | /// Convert the `Plot` to a static image and return the image as a | 59 | | - /// `base64` string. Supported formats are [ImageFormat::JPEG], | 60 | | - /// [ImageFormat::PNG] and [ImageFormat::WEBP]. | | 64 | + /// `base64` string. Supported formats are [`ImageFormat::JPEG`], | | 65 | + /// [`ImageFormat::PNG`] and [`ImageFormat::WEBP`]. | 61 | 66 | /// | 62 | | - /// This method allows you to reuse the same StaticExporter instance | | 67 | + /// This method allows you to reuse the same `StaticExporter` instance | 63 | 68 | /// across multiple plots, which is more efficient than creating | 64 | 69 | /// a new one for each operation. | 65 | 70 | /// | @@ -91,6 +96,11 @@ pub mod sync { | 91 | 96 | /// | 92 | 97 | /// exporter.close(); | 93 | 98 | /// ``` | | 99 | + /// | | 100 | + /// # Errors | | 101 | + /// | | 102 | + /// Returns an error if `format` is not JPEG, PNG or WEBP, if the export | | 103 | + /// fails, or if called from within an async (Tokio) context. | 94 | 104 | fn to_base64( | 95 | 105 | &mut self, | 96 | 106 | plot: &Plot, | @@ -102,7 +112,7 @@ pub mod sync { | 102 | 112 |
| 103 | 113 | /// Convert the `Plot` to SVG and return it as a String. | 104 | 114 | /// | 105 | | - /// This method allows you to reuse the same StaticExporter instance | | 115 | + /// This method allows you to reuse the same `StaticExporter` instance | 106 | 116 | /// across multiple plots, which is more efficient than creating | 107 | 117 | /// a new one for each operation. | 108 | 118 | /// | @@ -133,6 +143,11 @@ pub mod sync { | 133 | 143 | /// | 134 | 144 | /// exporter.close(); | 135 | 145 | /// ``` | | 146 | + /// | | 147 | + /// # Errors | | 148 | + /// | | 149 | + /// Returns an error if the export fails, or if called from within an | | 150 | + /// async (Tokio) context. | 136 | 151 | fn to_svg( | 137 | 152 | &mut self, | 138 | 153 | plot: &Plot, | @@ -218,7 +233,7 @@ pub mod r#async { | 218 | 233 | /// the given location using the asynchronous exporter. | 219 | 234 | /// | 220 | 235 | /// The exporter must have been built with the `build_async` method of | 221 | | - /// the StaticExporterBuilder. | | 236 | + /// the `StaticExporterBuilder`. | 222 | 237 | /// | 223 | 238 | /// Functionally signature equivalent to the sync version in | 224 | 239 | /// [`crate::export::sync::ExporterSyncExt::write_image`], but meant for | @@ -239,7 +254,7 @@ pub mod r#async { | 239 | 254 | /// `base64` string using the asynchronous exporter. | 240 | 255 | /// | 241 | 256 | /// The exporter must have been built with the `build_async` method of | 242 | | - /// the StaticExporterBuilder. | | 257 | + /// the `StaticExporterBuilder`. | 243 | 258 | /// | 244 | 259 | /// Functionally signature equivalent to the sync version in | 245 | 260 | /// [`crate::export::sync::ExporterSyncExt::to_base64`], but meant for | |
Collapse file Copy file name to clipboardExpand all lines: plotly/src/layout/animation.rs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,7 +11,7 @@ use serde::Serialize; | 11 | 11 | use crate::{Layout, Traces}; | 12 | 12 |
| 13 | 13 | /// A frame represents a single state in an animation sequence. | 14 | | -/// Based on Plotly.js frame_attributes.js specification | | 14 | +/// Based on Plotly.js `frame_attributes.js` specification | 15 | 15 | #[serde_with::skip_serializing_none] | 16 | 16 | #[derive(Serialize, Clone, FieldSetter)] | 17 | 17 | pub struct Frame { | @@ -63,7 +63,7 @@ impl Default for Animation { | 63 | 63 |
| 64 | 64 | impl Animation { | 65 | 65 | /// Create a new animation args with default values for options and | 66 | | - /// FramesMode set to all frames | | 66 | + /// `FramesMode` set to all frames | 67 | 67 | pub fn new() -> Self { | 68 | 68 | Self::default() | 69 | 69 | } | @@ -139,7 +139,7 @@ impl Serialize for FrameListMode { | 139 | 139 | } | 140 | 140 |
| 141 | 141 | /// Animation configuration options | 142 | | -/// Based on actual Plotly.js animation API from animation_attributes.js | | 142 | +/// Based on actual Plotly.js animation API from `animation_attributes.js` | 143 | 143 | #[serde_with::skip_serializing_none] | 144 | 144 | #[derive(Serialize, Clone, Debug, FieldSetter)] | 145 | 145 | pub struct AnimationOptions { | |
Collapse file Copy file name to clipboardExpand all lines: plotly/src/layout/axis.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -622,7 +622,7 @@ impl Axis { | 622 | 622 |
| 623 | 623 | /// Set the range of the axis. This method accepts various types and | 624 | 624 | /// converts them to `AxisRange` while also keeping backward compatibility | 625 | | - /// with API prior to AxisRange introduction. | | 625 | + /// with API prior to `AxisRange` introduction. | 626 | 626 | pub fn range(mut self, range: impl Into<AxisRange>) -> Self { | 627 | 627 | self.range = Some(range.into()); | 628 | 628 | self | |
|