how_to_read_the_godot_api.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. .. _doc_how_to_read_the_godot_api:
  2. How to read the Godot API
  3. =========================
  4. On this page, you'll learn how to read the class reference for the Godot API.
  5. The API, or Application Programming Interface, is an index of what Godot offers
  6. users. It provides a brief summary of which classes exist, how they are
  7. related to each other, what features they have, and how to use them.
  8. Inheritance
  9. -----------
  10. .. image:: img/class_api_inheritance.webp
  11. At the top of each file, you will see the name of the class.
  12. The "Inherits" section lists each class the current one inherits.
  13. Here ``CanvasItem`` inherits ``Node`` and ``Node`` inherits ``Object``.
  14. The "Inherited By" section lists each class which directly inherits the
  15. current class. Here ``Control`` and ``Node2D`` both inherit ``CanvasItem``.
  16. Brief Description
  17. -----------------
  18. .. image:: img/class_api_brief_description.webp
  19. Next a brief description of the class. This text appears in Godot Editor
  20. popups for creating Nodes, Resources, and other types.
  21. Description
  22. -----------
  23. .. image:: img/class_api_description.webp
  24. Next a more detailed description the class, its features, and its use case(s).
  25. Things you may find here:
  26. 1. Specifics of how the class works.
  27. 2. Code samples of common use cases.
  28. 3. Usage details which are shared between each of the class's methods.
  29. 4. Warnings about required dependencies or configuration.
  30. 5. Links to other related parts of the Godot API.
  31. Tutorials
  32. ---------
  33. .. image:: img/class_api_tutorials.webp
  34. The page then provides links to parts of the manual which mention or make use
  35. of the current class.
  36. Properties
  37. ----------
  38. .. image:: img/class_api_properties_table.webp
  39. The Properties table lists the variables which belong to each instance of the
  40. class, also known as the "properties."
  41. The left column contains the data type of the property. The text is also a
  42. link to that data type's Godot API page.
  43. The center column contains the name of the property. The text is also a link
  44. to that property's full description on the page. Use this name to get the
  45. property's data or set a new value to it.
  46. The right column contains the default value of the property. To initialize it
  47. with a different value, you must set a different value via script or the
  48. Inspector.
  49. Methods
  50. -------
  51. .. image:: img/class_api_methods_table.webp
  52. The Methods table lists the functions which belong to each instance of the
  53. class, also known as the "methods."
  54. The left column contains the data type of the method's return value.
  55. The right column contains the name, parameters, and qualifiers of the method.
  56. The name is the text before the opening parenthesis. It is also a link to the
  57. method's full description on the page. Use this name to call the method.
  58. For each parameter, the page details its data type, name, and default value,
  59. if any.
  60. Possible qualifiers include...
  61. - ``const``: the method does not change any data in the class instance.
  62. - ``virtual``: the method does nothing but wait for a script to override it.
  63. - ``vararg``: the method can accept an arbitrary number of arguments.
  64. Signals
  65. -------
  66. .. image:: img/class_api_signals.webp
  67. The Signals list details the names and parameters of events which "signal" a
  68. change in game state to other class instances.
  69. Like the Methods table, any parameters will include their data type and name.
  70. Each signal also has a detailed explanation of when the signal is emitted.
  71. Enumerations
  72. ------------
  73. .. image:: img/class_api_enumerations.webp
  74. The Enumerations list details the enumerable data types associated with the
  75. current class.
  76. For each enumeration, the page states its name and then lists its possible
  77. values.
  78. For each enumeration value, the page states its name, its integer value, and
  79. an explanation of its use case(s) and/or affects.
  80. Constants
  81. ---------
  82. .. image:: img/class_api_constants.webp
  83. The Constants list details named integer constants in the current class.
  84. For each constant, the page states its name, its integer value, and an
  85. explanation of its use case(s) and/or affects.
  86. ``NOTIFICATION_*`` constants' descriptions will state which engine event
  87. triggers the notification.
  88. Property Descriptions
  89. ---------------------
  90. .. image:: img/class_api_property_descriptions.webp
  91. The Property Descriptions list details everything about each property.
  92. It restates the data type and name of the property.
  93. Every property in the Godot API is bound to a pair of setter and getter
  94. functions. Using either is equivalent. They are listed here.
  95. Below that is a detailed summary of what the property's data represents, its
  96. use case(s) and/or the affects of changing it. It may include code samples
  97. and/or links to relevant parts of the Godot API.
  98. .. note:: Knowing the setter and getter names is useful when one must bind a
  99. method name or :ref:`Callable<class_Callable>` to something.
  100. Method Descriptions
  101. -------------------
  102. .. image:: img/class_api_method_descriptions.webp
  103. The Method Descriptions list details everything about each method.
  104. It restates the method's return data type, parameter names/types/defaults, and
  105. qualifiers.
  106. Below that is a detailed summary of what the method does and its use case(s).
  107. It may include code samples and/or links to relevant parts of the Godot API.