From b9bc4255b70ef87977029072b86a9de8667bc40c Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Thu, 28 Aug 2025 15:05:34 +0200 Subject: [PATCH] Move class reference primer back to godot docs, as they are very technical. --- ...lass_reference.rst => class_reference.rst} | 10 +- .../class_reference_primer.rst | 355 ------------------ documentation/class_reference/index.rst | 20 - index.rst | 2 +- 4 files changed, 9 insertions(+), 378 deletions(-) rename documentation/{class_reference/updating_the_class_reference.rst => class_reference.rst} (92%) delete mode 100644 documentation/class_reference/class_reference_primer.rst delete mode 100644 documentation/class_reference/index.rst diff --git a/documentation/class_reference/updating_the_class_reference.rst b/documentation/class_reference.rst similarity index 92% rename from documentation/class_reference/updating_the_class_reference.rst rename to documentation/class_reference.rst index a202e55..d43c0af 100644 --- a/documentation/class_reference/updating_the_class_reference.rst +++ b/documentation/class_reference.rst @@ -1,6 +1,6 @@ .. _doc_updating_the_class_reference: -Making changes to the class reference +Contributing to the class reference ===================================== .. highlight:: shell @@ -11,6 +11,11 @@ methods, properties, and global objects, available for scripting. The class refe is available online, from the documentation sidebar, and in the Godot editor, from the help menu. +.. seealso:: + + To learn how the class reference works on a technical level, see the + `latest documentation of the class reference `__. + As the engine grows and features are added or modified, some parts of the class reference become obsolete and new descriptions and examples need to be added. While developers are required to document their work in the class reference when @@ -36,7 +41,8 @@ In the main repository the class reference is stored in XML files, one for each class or global object. The majority of these files is located in `doc/classes/ `_, but some modules contain their own documentation as well. You will find it in the ``modules//doc_classes/`` -directory. To learn more about editing XML files refer to :ref:`doc_class_reference_primer`. +directory. To learn more about editing XML files refer to the latest documentation of the +`class reference `__. .. seealso:: diff --git a/documentation/class_reference/class_reference_primer.rst b/documentation/class_reference/class_reference_primer.rst deleted file mode 100644 index 2e15c66..0000000 --- a/documentation/class_reference/class_reference_primer.rst +++ /dev/null @@ -1,355 +0,0 @@ -.. _doc_class_reference_primer: - -Class reference primer -====================== - -This page explains how to write the class reference. You will learn where to -write new descriptions for the classes, methods, and properties for Godot's -built-in node types. - -.. seealso:: - - To learn to submit your changes to the Godot project using the Git version - control system, see :ref:`doc_updating_the_class_reference`. - -The reference for each class is contained in an XML file like the one below: - -.. code-block:: xml - - - - A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index. - - - A 2D game object, with a transform (position, rotation, and scale). All 2D nodes, including physics objects and sprites, inherit from Node2D. Use Node2D as a parent node to move, scale and rotate children in a 2D project. Also gives control of the node's render order. - - - https://docs.godotengine.org/en/latest/tutorials/2d/custom_drawing_in_2d.html - https://github.com/godotengine/godot-demo-projects/tree/master/2d - - - - - - - - - Multiplies the current scale by the [code]ratio[/code] vector. - - - [...] - - - - - - - Translates the node by the given [code]offset[/code] in local coordinates. - - - - - - Global position. - - [...] - - Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others. - - - - - - - -It starts with brief and long descriptions. In the generated docs, the brief -description is always at the top of the page, while the long description lies -below the list of methods, variables, and constants. You can find methods, -member variables, constants, and signals in separate XML nodes. - -For each, you want to learn how they work in Godot's source code. Then, fill -their documentation by completing or improving the text in these tags: - -- `` -- `` -- `` -- `` (in its `` tag; return types and arguments don't take separate - documentation strings) -- `` -- `` (in its `` tag; arguments don't take separate documentation strings) -- `` - -Write in a clear and simple language. Always follow the :ref:`writing guidelines -` to keep your descriptions short and easy to read. -**Do not leave empty lines** in the descriptions: each line in the XML file will -result in a new paragraph, even if it is empty. - -.. _doc_class_reference_editing_xml: - -How to edit class XML ---------------------- - -Edit the file for your chosen class in ``doc/classes/`` to update the class -reference. The folder contains an XML file for each class. The XML lists the -constants and methods you will find in the class reference. Godot generates and -updates the XML automatically. - -.. note:: For some modules in the engine's source code, you'll find the XML - files in the ``modules//doc_classes/`` directory instead. - -Edit it using your favorite text editor. If you use a code editor, make sure -that it doesn't change the indent style: you should use tabs for the XML and -four spaces inside BBCode-style blocks. More on that below. - -To check that the modifications you've made are correct in the generated -documentation, navigate to the ``doc/`` folder and run the command ``make rst``. -This will convert the XML files to the online documentation's format and output -errors if anything's wrong. - -Alternatively, you can build Godot and open the modified page in the built-in -code reference. To learn how to compile the engine, read the :ref:`compilation -guide `. - -We recommend using a code editor that supports XML files like Vim, Atom, Visual Studio Code, -Notepad++, or another to comfortably edit the file. You can also use their -search feature to find classes and properties quickly. - -.. tip:: - - If you use Visual Studio Code, you can install the - `vscode-xml extension `__ - to get linting for class reference XML files. - -.. _doc_class_reference_bbcode: - -Improve formatting with BBCode style tags -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Godot's XML class reference supports BBCode-like tags for linking as well as formatting text and code. -In the tables below you can find the available tags, usage examples and the results after conversion to reStructuredText. - -Linking -""""""" - -Whenever you link to a member of another class, you need to specify the class name. -For links to the same class, the class name is optional and can be omitted. - -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| Tag and Description | Example | Result | -+================================+=========================================+==============================================================+ -| | ``[Class]`` | ``Move the [Sprite2D].`` | Move the :ref:`class_Sprite2D`. | -| | Link to class | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[annotation Class.name]`` | ``See [annotation @GDScript.@rpc].`` | See :ref:`@GDScript.@rpc `. | -| | Link to annotation | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[constant Class.name]`` | ``See [constant Color.RED].`` | See :ref:`Color.RED `. | -| | Link to constant | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[enum Class.name]`` | ``See [enum Mesh.ArrayType].`` | See :ref:`Mesh.ArrayType `. | -| | Link to enum | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[member Class.name]`` | ``Get [member Node2D.scale].`` | Get :ref:`Node2D.scale `. | -| | Link to member | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[method Class.name]`` | ``Call [method Node3D.hide].`` | Call :ref:`Node3D.hide() `. | -| | Link to method | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[constructor Class.name]`` | ``Use [constructor Color.Color].`` | Use :ref:`Color.Color `. | -| | Link to built-in constructor | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[operator Class.name]`` | ``Use [operator Color.operator *].`` | Use :ref:`Color.operator * `. | -| | Link to built-in operator | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[signal Class.name]`` | ``Emit [signal Node.renamed].`` | Emit :ref:`Node.renamed `. | -| | Link to signal | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[theme_item Class.name]`` | ``See [theme_item Label.font].`` | See :ref:`Label.font `. | -| | Link to theme item | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ -| | ``[param name]`` | ``Takes [param size] for the size.`` | Takes ``size`` for the size. | -| | Parameter name (as code) | | | -+--------------------------------+-----------------------------------------+--------------------------------------------------------------+ - -.. note:: - - Currently only :ref:`class_@GDScript` has annotations. - -Formatting text -""""""""""""""" - -+--------------------------------+----------------------------------------------+------------------------------------+ -| Tag and Description | Example | Result | -+================================+==============================================+====================================+ -| | ``[br]`` | | ``Line 1.[br]`` | | Line 1. | -| | Line break | | ``Line 2.`` | | Line 2. | -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[lb]`` ``[rb]`` | ``[lb]b[rb]text[lb]/b[rb]`` | [b]text[/b] | -| | ``[`` and ``]`` respectively | | | -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[b]`` ``[/b]`` | ``Do [b]not[/b] call this method.`` | Do **not** call this method. | -| | Bold | | | -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[i]`` ``[/i]`` | ``Returns the [i]global[/i] position.`` | Returns the *global* position. | -| | Italic | | | -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[u]`` ``[/u]`` | ``[u]Always[/u] use this method.`` | .. raw:: html | -| | Underline | | | -| | | Always use this method. | -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[s]`` ``[/s]`` | ``[s]Outdated information.[/s]`` | .. raw:: html | -| | Strikethrough | | | -| | | Outdated information. | -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[url]`` ``[/url]`` | | ``[url]https://example.com[/url]`` | | https://example.com | -| | Hyperlink | | ``[url=https://example.com]Website[/url]`` | | `Website `_ | -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[center]`` ``[/center]`` | ``[center]2 + 2 = 4[/center]`` | .. raw:: html | -| | Horizontal centering | | | -| | |
2 + 2 = 4
| -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[kbd]`` ``[/kbd]`` | ``Press [kbd]Ctrl + C[/kbd].`` | Press :kbd:`Ctrl + C`. | -| | Keyboard/mouse shortcut | | | -+--------------------------------+----------------------------------------------+------------------------------------+ -| | ``[code]`` ``[/code]`` | ``Returns [code]true[/code].`` | Returns ``true``. | -| | Inline code fragment | | | -+--------------------------------+----------------------------------------------+------------------------------------+ - -.. note:: - - 1. Some supported tags like ``[color]`` and ``[font]`` are not listed here because they are not recommended in the engine documentation. - 2. ``[kbd]`` disables BBCode until the parser encounters ``[/kbd]``. - 3. ``[code]`` disables BBCode until the parser encounters ``[/code]``. - -Formatting code blocks -"""""""""""""""""""""" - -There are two options for formatting code blocks: - -1. Use ``[codeblock]`` if you want to add an example for a specific language. -2. Use ``[codeblocks]``, ``[gdscript]``, and ``[csharp]`` if you want to add the same example for both languages, GDScript and C#. - -By default, ``[codeblock]`` highlights GDScript syntax. You can change it using -the ``lang`` attribute. Currently supported options are: - -- ``[codeblock lang=text]`` disables syntax highlighting; -- ``[codeblock lang=gdscript]`` highlights GDScript syntax; -- ``[codeblock lang=csharp]`` highlights C# syntax (only in .NET version). - -.. note:: - - ``[codeblock]`` disables BBCode until the parser encounters ``[/codeblock]``. - -.. warning:: - - Use ``[codeblock]`` for pre-formatted code blocks. Since Godot 4.5, - **tabs** should be used for indentation. - -For example: - -.. code-block:: none - - [codeblock] - func _ready(): - var sprite = get_node("Sprite2D") - print(sprite.get_pos()) - [/codeblock] - -Will display as: - -.. code-block:: gdscript - - func _ready(): - var sprite = get_node("Sprite2D") - print(sprite.get_pos()) - -If you need to have different code version in GDScript and C#, use -``[codeblocks]`` instead. If you use ``[codeblocks]``, you also need to have at -least one of the language-specific tags, ``[gdscript]`` and ``[csharp]``. - -Always write GDScript code examples first! You can use this `experimental code -translation tool `_ to speed up your -workflow. - -.. code-block:: none - - [codeblocks] - [gdscript] - func _ready(): - var sprite = get_node("Sprite2D") - print(sprite.get_pos()) - [/gdscript] - [csharp] - public override void _Ready() - { - var sprite = GetNode("Sprite2D"); - GD.Print(sprite.GetPos()); - } - [/csharp] - [/codeblocks] - -The above will display as: - -.. tabs:: - .. code-tab:: gdscript GDScript - - func _ready(): - var sprite = get_node("Sprite2D") - print(sprite.get_pos()) - - .. code-tab:: csharp - - public override void _Ready() - { - var sprite = GetNode("Sprite2D"); - GD.Print(sprite.GetPos()); - } - -Formatting notes and warnings -""""""""""""""""""""""""""""" - -To denote important information, add a paragraph starting with "[b]Note:[/b]" at -the end of the description: - -.. code-block:: none - - [b]Note:[/b] Only available when using the Vulkan renderer. - -To denote crucial information that could cause security issues or loss of data -if not followed carefully, add a paragraph starting with "[b]Warning:[/b]" at -the end of the description: - -.. code-block:: none - - [b]Warning:[/b] If this property is set to [code]true[/code], it allows clients to execute arbitrary code on the server. - -In all the paragraphs described above, make sure the punctuation is part of the -BBCode tags for consistency. - -Marking API as deprecated/experimental -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -To mark an API as deprecated or experimental, you need to add the corresponding XML attribute. The attribute value must be a message -explaining why the API is not recommended (BBCode markup is supported) or an empty string (the default message will be used). -If an API element is marked as deprecated/experimental, then it is considered documented even if the description is empty. - -.. code-block:: xml - - - [...] - - - - HTTP status code [code]305 Use Proxy[/code]. - - - - Toggles if any text should automatically change to its translated version depending on the current locale. - - - - - - Returns the call mode used for "Call Method" tracks. - - diff --git a/documentation/class_reference/index.rst b/documentation/class_reference/index.rst deleted file mode 100644 index 5ac7ba0..0000000 --- a/documentation/class_reference/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -:allow_comments: False - -.. _doc_contributing_class_reference: - -Contributing to the class reference -=================================== - -The pages below focus on the class reference. - -As the reference is included in the Godot editor, its source files are part of -the `godot repository `_. We use XML files -to write it, so the process to contribute to the class reference differs from -writing the online manual. - -.. toctree:: - :maxdepth: 1 - :name: toc-contributing-class-reference - - updating_the_class_reference - class_reference_primer diff --git a/index.rst b/index.rst index 822b3ca..4e63d1c 100644 --- a/index.rst +++ b/index.rst @@ -65,7 +65,7 @@ for your topic of interest. You can also use the search function in the top-left documentation/overview documentation/guidelines/index - documentation/class_reference/index + documentation/class_reference documentation/manual/index documentation/translation/index