diff --git a/tutorials/scripting/gdscript/img/typed_gdscript_warning_example.png b/tutorials/scripting/gdscript/img/typed_gdscript_warning_example.png deleted file mode 100644 index 86a58278e31..00000000000 Binary files a/tutorials/scripting/gdscript/img/typed_gdscript_warning_example.png and /dev/null differ diff --git a/tutorials/scripting/gdscript/img/typed_gdscript_warning_example.webp b/tutorials/scripting/gdscript/img/typed_gdscript_warning_example.webp new file mode 100644 index 00000000000..6c80c7445de Binary files /dev/null and b/tutorials/scripting/gdscript/img/typed_gdscript_warning_example.webp differ diff --git a/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_errors.png b/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_errors.png deleted file mode 100644 index 022c84997df..00000000000 Binary files a/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_errors.png and /dev/null differ diff --git a/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_errors.webp b/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_errors.webp new file mode 100644 index 00000000000..37bf508f623 Binary files /dev/null and b/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_errors.webp differ diff --git a/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_ignore.png b/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_ignore.png deleted file mode 100644 index a311365dd96..00000000000 Binary files a/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_ignore.png and /dev/null differ diff --git a/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_ignore.webp b/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_ignore.webp new file mode 100644 index 00000000000..ec9f19f923c Binary files /dev/null and b/tutorials/scripting/gdscript/img/typed_gdscript_warning_system_ignore.webp differ diff --git a/tutorials/scripting/gdscript/warning_system.rst b/tutorials/scripting/gdscript/warning_system.rst index 6312f522c09..d494a76b5c0 100644 --- a/tutorials/scripting/gdscript/warning_system.rst +++ b/tutorials/scripting/gdscript/warning_system.rst @@ -12,44 +12,49 @@ You can configure warnings in the Project Settings under the section called **GDScript**: .. figure:: img/typed_gdscript_warning_system_settings.webp - :alt: Warning system project settings + :alt: Warning system project settings - Warning system project settings + Warning system project settings .. note:: - As shown in the image above, you must enable **Advanced Settings** in order to see the GDScript section. + As shown in the image above, you must enable **Advanced Settings** in order to see the GDScript section. You can find a list of warnings for the active GDScript file in the -script editor's status bar. The example below has 3 warnings: +script editor's status bar. The example below has 2 warnings: -.. figure:: img/typed_gdscript_warning_example.png - :alt: Warning system example +.. figure:: img/typed_gdscript_warning_example.webp + :alt: Warning system example - Warning system example + Warning system example -To ignore specific warnings in one file, insert a special comment of the -form ``# warning-ignore:warning-id``, or click on the ignore link to the -right of the warning's description. Godot will add a comment above the -corresponding line and the code won't trigger the corresponding warning -anymore: +To ignore specific warnings, insert the :ref:`@warning_ignore ` +annotation before the definition or statement that generates the warning:: -.. figure:: img/typed_gdscript_warning_system_ignore.png - :alt: Warning system ignore example + func test(): + return + @warning_ignore("unreachable_code") + print("Can't reach") - Warning system ignore example +You can also click on the "Ignore" link near the warning description +and the editor will insert the annotation automatically: -You can also choose to ignore not just one but all warnings of a certain -type in this file with ``# warning-ignore-all:warning-id``. To ignore all -warnings of all types in a file add the comment ``# warnings-disable`` to it. +.. figure:: img/typed_gdscript_warning_system_ignore.webp + :alt: Warning system ignore example -Warnings won't prevent the game from running, but you can turn them into -errors if you'd like. This way your game won't compile unless you fix -all warnings. Head to the ``GDScript`` section of the Project Settings to + Warning system ignore example + +.. warning:: + + This part of GDScript currently has issues. Some warnings may not be ignored with an annotation, + and the editor may insert an annotation where it is not allowed (within a multiline expression). + +Warnings won't prevent the game from running, but you can turn certain warnings into +errors if you'd like. Head to the ``GDScript`` section of the Project Settings to turn on this option. Here's the same file as the previous example with -warnings as errors turned on: +the ``UNUSED_PARAMETER`` warning treated as an error: -.. figure:: img/typed_gdscript_warning_system_errors.png - :alt: Warnings as errors +.. figure:: img/typed_gdscript_warning_system_errors.webp + :alt: Warnings as errors - Warnings as errors + Warnings as errors