From 341e20f1425347fb796f019b5cd855c140f469bb Mon Sep 17 00:00:00 2001 From: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:56:32 +0200 Subject: [PATCH 1/4] update contributing file with new contact details Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0364fc57..a5e0a50a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ When your contribution is ready for review, make a pull request with your change ## Code of Conduct -In all forums, we follow the [Rust Code of Conduct]. For escalation or moderation issues please contact Ioannis (i.giagkiozis@gmail.com) instead of the Rust moderation team. +In all forums, we follow the [Rust Code of Conduct]. For escalation or moderation issues please reach out to @andrei-ng or the Plotly official community at [community@plot.ly](mailto:community@plot.ly) instead of the Rust moderation team. [Rust Code of Conduct]: https://www.rust-lang.org/conduct.html From e3e615aa63f5e28f12fe8eaccee8b2b838cec101 Mon Sep 17 00:00:00 2001 From: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:57:53 +0200 Subject: [PATCH 2/4] provide alternative show_html method - the show() method by default creates a random named file in `/tmp` dir, however in some cases `/tmp` is not available, e.g., snap's Firefox runs in an isolated enviroment and cannot access the system's `/tmp` - provide a method that calls write_html followed by show for easier access Closes #170 Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> --- plotly/src/plot.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plotly/src/plot.rs b/plotly/src/plot.rs index d02fe92d..d958ca90 100644 --- a/plotly/src/plot.rs +++ b/plotly/src/plot.rs @@ -275,6 +275,18 @@ impl Plot { Plot::show_with_default_app(temp_path); } + /// Display the fully rendered HTML `Plot` in the default system browser. + /// + /// The HTML file is generated and saved in the provided filename as long as the path + /// already exists, after the file is saved, it is read and displayed by the browser. + #[cfg(not(target_family = "wasm"))] + pub fn show_html + std::clone::Clone>(&self, filename: P) { + let path = filename.as_ref().to_str().unwrap(); + self.write_html(filename.clone()); + // Hand off the job of opening the browser to an OS-specific implementation. + Plot::show_with_default_app(path); + } + /// Display the fully rendered `Plot` as a static image of the given format /// in the default system browser. #[cfg(not(target_family = "wasm"))] @@ -311,7 +323,8 @@ impl Plot { pub fn write_html>(&self, filename: P) { let rendered = self.to_html(); - let mut file = File::create(filename).unwrap(); + let mut file = + File::create(filename).expect("Provided filepath does not exist or is not accessible"); file.write_all(rendered.as_bytes()) .expect("failed to write html output"); file.flush().unwrap(); From 77b0975a93216e44c6a3a73c74c322c9070402f2 Mon Sep 17 00:00:00 2001 From: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> Date: Wed, 31 Jul 2024 09:20:08 +0200 Subject: [PATCH 3/4] fix clippy & fmt warnings Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> --- plotly/src/plot.rs | 5 +++-- plotly/src/traces/histogram.rs | 12 +++++------- plotly/src/traces/scatter.rs | 12 +++++------- plotly/src/traces/scatter_polar.rs | 12 +++++------- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/plotly/src/plot.rs b/plotly/src/plot.rs index d958ca90..763adef4 100644 --- a/plotly/src/plot.rs +++ b/plotly/src/plot.rs @@ -277,8 +277,9 @@ impl Plot { /// Display the fully rendered HTML `Plot` in the default system browser. /// - /// The HTML file is generated and saved in the provided filename as long as the path - /// already exists, after the file is saved, it is read and displayed by the browser. + /// The HTML file is generated and saved in the provided filename as long as + /// the path already exists, after the file is saved, it is read and + /// displayed by the browser. #[cfg(not(target_family = "wasm"))] pub fn show_html + std::clone::Clone>(&self, filename: P) { let path = filename.as_ref().to_str().unwrap(); diff --git a/plotly/src/traces/histogram.rs b/plotly/src/traces/histogram.rs index b4b9b97f..cd804623 100644 --- a/plotly/src/traces/histogram.rs +++ b/plotly/src/traces/histogram.rs @@ -200,15 +200,13 @@ where /// `ndarray` feature. /// /// # Arguments - /// * `x` - One dimensional array (or view) that represents the - /// `x` axis coordinates. + /// * `x`- One dimensional array (or view) that represents the `x` axis + /// coordinates. /// * `traces_matrix` - Two dimensional array (or view) containing the `y` - /// axis coordinates of - /// the traces. + /// axis coordinates of the traces. /// * `array_traces` - Determines whether the traces are arranged in the - /// matrix over the - /// columns (`ArrayTraces::OverColumns`) or over the rows - /// (`ArrayTraces::OverRows`). + /// matrix over the columns (`ArrayTraces::OverColumns`) or over the rows + /// (`ArrayTraces::OverRows`). /// /// # Examples /// diff --git a/plotly/src/traces/scatter.rs b/plotly/src/traces/scatter.rs index fe9f5b9c..57d5e8a5 100644 --- a/plotly/src/traces/scatter.rs +++ b/plotly/src/traces/scatter.rs @@ -315,15 +315,13 @@ where /// indexed by `x`. This function requires the `ndarray` feature. /// /// # Arguments - /// * `x` - One dimensional array (or view) that represents the - /// `x` axis coordinates. + /// * `x`- One dimensional array (or view) that represents the `x` axis + /// coordinates. /// * `traces_matrix` - Two dimensional array (or view) containing the `y` - /// axis coordinates of - /// the traces. + /// axis coordinates of the traces. /// * `array_traces` - Determines whether the traces are arranged in the - /// matrix over the - /// columns (`ArrayTraces::OverColumns`) or over the rows - /// (`ArrayTraces::OverRows`). + /// matrix over the columns (`ArrayTraces::OverColumns`) or over the rows + /// (`ArrayTraces::OverRows`). /// /// # Examples /// diff --git a/plotly/src/traces/scatter_polar.rs b/plotly/src/traces/scatter_polar.rs index a9101607..7951ed4d 100644 --- a/plotly/src/traces/scatter_polar.rs +++ b/plotly/src/traces/scatter_polar.rs @@ -246,15 +246,13 @@ where /// `ndarray` feature. /// /// # Arguments - /// * `x` - One dimensional array (or view) that represents the - /// `x` axis coordinates. + /// * `x` - One dimensional array (or view) that represents the `x` axis + /// coordinates. /// * `traces_matrix` - Two dimensional array (or view) containing the `y` - /// axis coordinates of - /// the traces. + /// axis coordinates of the traces. /// * `array_traces` - Determines whether the traces are arranged in the - /// matrix over the - /// columns (`ArrayTraces::OverColumns`) or over the rows - /// (`ArrayTraces::OverRows`). + /// matrix over the columns (`ArrayTraces::OverColumns`) or over the rows + /// (`ArrayTraces::OverRows`). /// /// # Examples /// From d27cf18361d149af3a874742a9d94d9e66f4d454 Mon Sep 17 00:00:00 2001 From: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> Date: Wed, 31 Jul 2024 09:28:22 +0200 Subject: [PATCH 4/4] revert CI clippy darling package command patch - temporary patch introduced in 3130f5a43d1f9febb890fa48c50b35b03ca1050c to bypass clippy errors due to darling package: https://github.com/TedDriggs/darling/pull/296 Closes #210 Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> --- .github/workflows/ci.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d3cfb70..261d3677 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,15 +38,13 @@ jobs: components: clippy targets: wasm32-unknown-unknown # lint the main library workspace excluding the wasm feature - # Rust 1.79 generates a new lint in autogenerated code: - # Added clippy allow at the command line until it is fixed. See: https://github.com/rust-lang/rust-clippy/issues/12643 and https://github.com/TedDriggs/darling/issues/293 - - run: cargo clippy --features plotly_ndarray,plotly_image,kaleido -- -D warnings -Aclippy::manual_unwrap_or_default + - run: cargo clippy --features plotly_ndarray,plotly_image,kaleido -- -D warnings # lint the plotly library with wasm enabled - - run: cargo clippy --package plotly --features wasm --target wasm32-unknown-unknown -- -D warnings -Aclippy::manual_unwrap_or_default + - run: cargo clippy --package plotly --features wasm --target wasm32-unknown-unknown -- -D warnings # lint the non-wasm examples - - run: cd ${{ github.workspace }}/examples && cargo clippy --workspace --exclude "wasm*" -- -D warnings -Aclippy::manual_unwrap_or_default + - run: cd ${{ github.workspace }}/examples && cargo clippy --workspace --exclude "wasm*" -- -D warnings # lint the wasm examples - - run: cd ${{ github.workspace }}/examples && cargo clippy --target wasm32-unknown-unknown --package "wasm*" -- -Aclippy::manual_unwrap_or_default + - run: cd ${{ github.workspace }}/examples && cargo clippy --target wasm32-unknown-unknown --package "wasm*" semver: name: semver