From 3364059e02e1bf603a897c2d3b37ff44b5b5a4be Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Tue, 7 Oct 2025 07:50:18 -0700 Subject: [PATCH] Add tooltip documentation to the graphic flattening nodes and string nodes (#3269) --- node-graph/gcore/src/graphic.rs | 2 ++ node-graph/gcore/src/logic.rs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/node-graph/gcore/src/graphic.rs b/node-graph/gcore/src/graphic.rs index bd7a4677..d6774c8c 100644 --- a/node-graph/gcore/src/graphic.rs +++ b/node-graph/gcore/src/graphic.rs @@ -354,6 +354,7 @@ async fn to_graphic> + 'n>( content.into() } +/// Removes a level of nesting from a graphic table, or all nesting if "Fully Flatten" is enabled. #[node_macro::node(category("General"))] async fn flatten_graphic(_: impl Ctx, content: Table, fully_flatten: bool) -> Table { // TODO: Avoid mutable reference, instead return a new Table? @@ -393,6 +394,7 @@ async fn flatten_graphic(_: impl Ctx, content: Table, fully_flatten: bo output } +/// Converts a graphic table into a vector table by deeply flattening any vector content it contains, and discarding any non-vector content. #[node_macro::node(category("Vector"))] async fn flatten_vector(_: impl Ctx, content: Table) -> Table { // TODO: Avoid mutable reference, instead return a new Table? diff --git a/node-graph/gcore/src/logic.rs b/node-graph/gcore/src/logic.rs index efcd4a7f..84842e00 100644 --- a/node-graph/gcore/src/logic.rs +++ b/node-graph/gcore/src/logic.rs @@ -9,11 +9,13 @@ use crate::vector::Vector; use crate::{Context, Ctx}; use glam::{DAffine2, DVec2}; +/// Type-asserts a value to be a string, so the automatic type conversion system can convert another type to a string. #[node_macro::node(category("Debug"))] fn to_string(_: impl Ctx, value: String) -> String { value } +/// Converts a value to a JSON string representation. #[node_macro::node(category("Text"))] fn serialize( _: impl Ctx, @@ -22,16 +24,21 @@ fn serialize( serde_json::to_string(&value).unwrap_or_else(|_| "Serialization Error".to_string()) } +/// Joins two strings together. #[node_macro::node(category("Text"))] fn string_concatenate(_: impl Ctx, #[implementations(String)] first: String, second: TextArea) -> String { first.clone() + &second } +/// Replaces all occurrences of "From" with "To" in the input string. #[node_macro::node(category("Text"))] fn string_replace(_: impl Ctx, string: String, from: TextArea, to: TextArea) -> String { string.replace(&from, &to) } +/// Extracts a substring from the input string, starting at "Start" and ending before "End". +/// Negative indices count from the end of the string. +/// If "Start" equals or exceeds "End", the result is an empty string. #[node_macro::node(category("Text"))] fn string_slice(_: impl Ctx, string: String, start: f64, end: f64) -> String { let total_chars = string.chars().count(); @@ -56,11 +63,13 @@ fn string_slice(_: impl Ctx, string: String, start: f64, end: f64) -> String { // TODO: Return u32, u64, or usize instead of f64 after #1621 is resolved and has allowed us to implement automatic type conversion in the node graph for nodes with generic type inputs. // TODO: (Currently automatic type conversion only works for concrete types, via the Graphene preprocessor and not the full Graphene type system.) +/// Counts the number of characters in a string. #[node_macro::node(category("Text"))] fn string_length(_: impl Ctx, string: String) -> f64 { string.chars().count() as f64 } +/// Evaluates either the "If True" or "If False" input branch based on whether the input condition is true or false. #[node_macro::node(category("Math: Logic"))] async fn switch( #[implementations(Context)] ctx: C,