gstrfuncs: Improve and port g_set_str() docs to gi-docgen

Fixes link and code block and includes code syntax.

Improves documentation to be more in line with the developer guidelines.
This commit is contained in:
velsinki 2024-01-09 00:37:26 +01:00
parent f09bd17e32
commit 51fc82a567

View File

@ -456,16 +456,22 @@ gboolean g_ascii_string_to_unsigned (const gchar *str,
/**
* g_set_str: (skip)
* @str_pointer: (inout) (not optional) (nullable): a pointer to either a string or %NULL
* @new_str: (nullable): a string to assign to @str_pointer, or %NULL
* @str_pointer: (inout) (not optional) (nullable): a pointer to either
* a string or `NULL`
* @new_str: (nullable): a string to assign to @str_pointer
*
* Updates a pointer to a string to a copy of @new_str. The previous string
* pointed to by @str_pointer will be freed with g_free().
* Updates a pointer to a string to a copy of @new_str and returns whether the
* string was changed.
*
* @str_pointer must not be %NULL, but can point to a %NULL value.
* If @new_str matches the previous string, this function is a no-op. If
* @new_str is different, a copy of it will be assigned to @str_pointer and
* the previous string pointed to by @str_pointer will be freed with
* [func@GLib.free].
*
* @str_pointer must not be `NULL`, but can point to a `NULL` value.
*
* One convenient usage of this function is in implementing property settings:
* |[
* ```C
* void
* foo_set_bar (Foo *foo,
* const char *new_bar)
@ -475,9 +481,9 @@ gboolean g_ascii_string_to_unsigned (const gchar *str,
* if (g_set_str (&foo->bar, new_bar))
* g_object_notify (foo, "bar");
* }
* ]|
* ```
*
* Returns: %TRUE if the value of @str_pointer changed, %FALSE otherwise
* Returns: true if the value of @str_pointer changed, false otherwise
*
* Since: 2.76
*/