warning_system.rst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .. _doc_gdscript_warning_system:
  2. GDScript warning system
  3. =======================
  4. The GDScript warning system complements :ref:`static typing <doc_gdscript_static_typing>`
  5. (but it can work without static typing too). It's here to help you avoid
  6. mistakes that are hard to spot during development, and that may lead
  7. to runtime errors.
  8. You can configure warnings in the Project Settings under the section
  9. called **Gdscript**:
  10. .. figure:: img/typed_gdscript_warning_system_settings.png
  11. :alt: Warning system project settings
  12. Warning system project settings
  13. You can find a list of warnings for the active GDScript file in the
  14. script editor's status bar. The example below has 3 warnings:
  15. .. figure:: img/typed_gdscript_warning_example.png
  16. :alt: Warning system example
  17. Warning system example
  18. To ignore specific warnings in one file, insert a special comment of the
  19. form ``# warning-ignore:warning-id``, or click on the ignore link to the
  20. right of the warning's description. Godot will add a comment above the
  21. corresponding line and the code won't trigger the corresponding warning
  22. anymore:
  23. .. figure:: img/typed_gdscript_warning_system_ignore.png
  24. :alt: Warning system ignore example
  25. Warning system ignore example
  26. You can also choose to ignore not just one but all warnings of a certain
  27. type in this file with ``# warning-ignore-all:warning-id``. To ignore all
  28. warnings of all types in a file add the comment ``# warnings-disable`` to it.
  29. Warnings won't prevent the game from running, but you can turn them into
  30. errors if you'd like. This way your game won't compile unless you fix
  31. all warnings. Head to the ``GDScript`` section of the Project Settings to
  32. turn on this option. Here's the same file as the previous example with
  33. warnings as errors turned on:
  34. .. figure:: img/typed_gdscript_warning_system_errors.png
  35. :alt: Warnings as errors
  36. Warnings as errors