updating_the_class_reference.rst 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. .. _doc_updating_the_class_reference:
  2. Updating the class reference
  3. ============================
  4. Godot Engine provides an important number of classes that you can make
  5. use of to create your games. However, the :ref:`toc-class-ref` that
  6. lists all these classes with their methods is quite incomplete. We need
  7. your kind help to fill this reference. This page will explain you how.
  8. Please note: we aim at filling completely this reference in English
  9. first. Please do not start translating it for the moment.
  10. :ref:`doc_list_of_classes_and_documenters`
  11. Editing with Github
  12. -------------------
  13. Fork Godot Engine
  14. ~~~~~~~~~~~~~~~~~
  15. First of all, you need to fork the Godot Engine on your own GitHub
  16. repository.
  17. You will then need to clone the master branch of Godot Engine in order
  18. to work on the most recent version of the engine, including all of its
  19. features.
  20. ::
  21. git clone https://github.com/your_name/godot.git
  22. Then, create a new git branch that will contain your changes.
  23. ::
  24. git checkout -b reference-edition
  25. The branch you just created is identical to current master branch of
  26. Godot Engine. It already contains a doc/ folder, with the currently
  27. written reference.
  28. Updating the documentation template
  29. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  30. When classes are modified in the source code, the documentation template
  31. might become outdated. To make sure that you are editing an up-to-date
  32. version, you first need to compile Godot (you can follow the
  33. :ref:`doc_introduction_to_the_buildsystem` page), and then run the
  34. following command (assuming 64-bit Linux):
  35. ::
  36. ./bin/godot.x11.tools.64 -doctool doc/base/classes.xml
  37. The doc/base/classes.xml should then be up-to-date with current Godot
  38. Engine features. You can then check what changed (or not) using the
  39. ``git diff`` command. If there are changes to other classes than the one
  40. you are planning to document, please commit those changes first before
  41. starting to edit the template:
  42. ::
  43. git add doc/base/classes.xml
  44. git commit -m "Sync classes reference template with current code base"
  45. You are now ready to edit this file to add stuff.
  46. Push and request a pull of your changes
  47. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  48. Once your modifications are finished, push your changes on your GitHub
  49. repository:
  50. ::
  51. git add doc/base/classes.xml
  52. git commit -m "Explain your modifications."
  53. git push
  54. When it's done, you can ask for a Pull Request on the GitHub UI of your
  55. Godot fork.
  56. Edit doc/base/classes.xml file
  57. ------------------------------
  58. First of all, check the :ref:`doc_list_of_classes_and_documenters`. Try to work
  59. on classes not already assigned nor filled.
  60. This file is produced by Godot Engine. It is used by the editor, for
  61. example in the Help window (F1, Shift+F1).
  62. You can edit this file using your favourite text editor.
  63. Here is an example with the Node2D class:
  64. .. code:: xml
  65. <class name="Node2D" inherits="CanvasItem" category="Core">
  66. <brief_description>
  67. Base node for 2D system.
  68. </brief_description>
  69. <description>
  70. Base node for 2D system. Node2D contains a position, rotation and scale, which is used to position and animate. It can alternatively be used with a custom 2D transform ([Matrix32]). A tree of Node2Ds allows complex hierarchies for animation and positioning.
  71. </description>
  72. <methods>
  73. <method name="set_pos">
  74. <argument index="0" name="pos" type="Vector2">
  75. </argument>
  76. <description>
  77. Set the position of the 2d node.
  78. </description>
  79. </method>
  80. <method name="set_rot">
  81. <argument index="0" name="rot" type="float">
  82. </argument>
  83. <description>
  84. Set the rotation of the 2d node.
  85. </description>
  86. </method>
  87. <method name="set_scale">
  88. <argument index="0" name="scale" type="Vector2">
  89. </argument>
  90. <description>
  91. Set the scale of the 2d node.
  92. </description>
  93. </method>
  94. <method name="get_pos" qualifiers="const">
  95. <return type="Vector2">
  96. </return>
  97. <description>
  98. Return the position of the 2D node.
  99. </description>
  100. </method>
  101. <method name="get_rot" qualifiers="const">
  102. <return type="float">
  103. </return>
  104. <description>
  105. Return the rotation of the 2D node.
  106. </description>
  107. </method>
  108. <method name="get_scale" qualifiers="const">
  109. <return type="Vector2">
  110. </return>
  111. <description>
  112. Return the scale of the 2D node.
  113. </description>
  114. </method>
  115. <method name="rotate">
  116. <argument index="0" name="degrees" type="float">
  117. </argument>
  118. <description>
  119. </description>
  120. </method>
  121. <method name="move_local_x">
  122. <argument index="0" name="delta" type="float">
  123. </argument>
  124. <argument index="1" name="scaled" type="bool" default="false">
  125. </argument>
  126. <description>
  127. </description>
  128. </method>
  129. <method name="move_local_y">
  130. <argument index="0" name="delta" type="float">
  131. </argument>
  132. <argument index="1" name="scaled" type="bool" default="false">
  133. </argument>
  134. <description>
  135. </description>
  136. </method>
  137. <method name="get_global_pos" qualifiers="const">
  138. <return type="Vector2">
  139. </return>
  140. <description>
  141. Return the global position of the 2D node.
  142. </description>
  143. </method>
  144. <method name="set_global_pos">
  145. <argument index="0" name="arg0" type="Vector2">
  146. </argument>
  147. <description>
  148. </description>
  149. </method>
  150. <method name="set_transform">
  151. <argument index="0" name="xform" type="Matrix32">
  152. </argument>
  153. <description>
  154. </description>
  155. </method>
  156. <method name="set_global_transform">
  157. <argument index="0" name="xform" type="Matrix32">
  158. </argument>
  159. <description>
  160. </description>
  161. </method>
  162. <method name="edit_set_pivot">
  163. <argument index="0" name="arg0" type="Vector2">
  164. </argument>
  165. <description>
  166. </description>
  167. </method>
  168. </methods>
  169. <constants>
  170. </constants>
  171. </class>
  172. As you can see, some methods in this class have no description (i.e.
  173. there is no text between their marks). This can also happen for the
  174. description and the brief_description of the class, but in our case
  175. they are already filled. Let's edit the description of the rotate()
  176. method:
  177. .. code:: xml
  178. <method name="rotate">
  179. <argument index="0" name="degrees" type="float">
  180. </argument>
  181. <description>
  182. Rotates the node of "degrees" degrees.
  183. </description>
  184. </method>
  185. That's all!
  186. You simply have to write any missing text between these marks:
  187. - <description></description>
  188. - <brief_description></brief_description>
  189. - <constant></constant>
  190. Describe clearly and shortly what it does. You can include an example of
  191. use if needed. Avoid grammar faults.
  192. I don't know what this method does!
  193. -----------------------------------
  194. Not a problem. Leave it behind for now, and don't forget to notify the
  195. missing methods when you request a pull of your changes. Another
  196. editor will take care of it.
  197. If you wonder what a method does, you can still have a look at its
  198. implementation in Godot Engine's source code on GitHub. Also, if you
  199. have a doubt, feel free to ask on the
  200. `Forums <http://www.godotengine.org/projects/godot-engine/boards>`__
  201. and on IRC (freenode, #godotengine).