mirror of
https://github.com/godotengine/godot-contributing-docs.git
synced 2026-01-03 18:09:19 +03:00
Use more of the 'contributing' part of godot docs to fill in for documentation contribution guides.
This commit is contained in:
355
documentation/class_reference/class_reference_primer.rst
Normal file
355
documentation/class_reference/class_reference_primer.rst
Normal file
@@ -0,0 +1,355 @@
|
||||
.. _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
|
||||
|
||||
<class name="Node2D" inherits="CanvasItem" version="4.0">
|
||||
<brief_description>
|
||||
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
|
||||
</brief_description>
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="Custom drawing in 2D">https://docs.godotengine.org/en/latest/tutorials/2d/custom_drawing_in_2d.html</link>
|
||||
<link title="All 2D Demos">https://github.com/godotengine/godot-demo-projects/tree/master/2d</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="apply_scale">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="ratio" type="Vector2">
|
||||
</argument>
|
||||
<description>
|
||||
Multiplies the current scale by the [code]ratio[/code] vector.
|
||||
</description>
|
||||
</method>
|
||||
[...]
|
||||
<method name="translate">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="offset" type="Vector2">
|
||||
</argument>
|
||||
<description>
|
||||
Translates the node by the given [code]offset[/code] in local coordinates.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position">
|
||||
Global position.
|
||||
</member>
|
||||
[...]
|
||||
<member name="z_index" type="int" setter="set_z_index" getter="get_z_index" default="0">
|
||||
Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
||||
|
||||
|
||||
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:
|
||||
|
||||
- `<brief_description>`
|
||||
- `<description>`
|
||||
- `<constant>`
|
||||
- `<method>` (in its `<description>` tag; return types and arguments don't take separate
|
||||
documentation strings)
|
||||
- `<member>`
|
||||
- `<signal>` (in its `<description>` tag; arguments don't take separate documentation strings)
|
||||
- `<constant>`
|
||||
|
||||
Write in a clear and simple language. Always follow the :ref:`writing guidelines
|
||||
<doc_docs_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/<module_name>/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 <toc-devel-compiling>`.
|
||||
|
||||
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 <https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml>`__
|
||||
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 <class_@GDScript_annotation_@rpc>`. |
|
||||
| | Link to annotation | | |
|
||||
+--------------------------------+-----------------------------------------+--------------------------------------------------------------+
|
||||
| | ``[constant Class.name]`` | ``See [constant Color.RED].`` | See :ref:`Color.RED <class_Color_constant_RED>`. |
|
||||
| | Link to constant | | |
|
||||
+--------------------------------+-----------------------------------------+--------------------------------------------------------------+
|
||||
| | ``[enum Class.name]`` | ``See [enum Mesh.ArrayType].`` | See :ref:`Mesh.ArrayType <enum_Mesh_ArrayType>`. |
|
||||
| | Link to enum | | |
|
||||
+--------------------------------+-----------------------------------------+--------------------------------------------------------------+
|
||||
| | ``[member Class.name]`` | ``Get [member Node2D.scale].`` | Get :ref:`Node2D.scale <class_Node2D_property_scale>`. |
|
||||
| | Link to member | | |
|
||||
+--------------------------------+-----------------------------------------+--------------------------------------------------------------+
|
||||
| | ``[method Class.name]`` | ``Call [method Node3D.hide].`` | Call :ref:`Node3D.hide() <class_Node3D_method_hide>`. |
|
||||
| | Link to method | | |
|
||||
+--------------------------------+-----------------------------------------+--------------------------------------------------------------+
|
||||
| | ``[constructor Class.name]`` | ``Use [constructor Color.Color].`` | Use :ref:`Color.Color <class_Color_constructor_Color>`. |
|
||||
| | Link to built-in constructor | | |
|
||||
+--------------------------------+-----------------------------------------+--------------------------------------------------------------+
|
||||
| | ``[operator Class.name]`` | ``Use [operator Color.operator *].`` | Use :ref:`Color.operator * <class_Color_operator_mul_int>`. |
|
||||
| | Link to built-in operator | | |
|
||||
+--------------------------------+-----------------------------------------+--------------------------------------------------------------+
|
||||
| | ``[signal Class.name]`` | ``Emit [signal Node.renamed].`` | Emit :ref:`Node.renamed <class_Node_signal_renamed>`. |
|
||||
| | Link to signal | | |
|
||||
+--------------------------------+-----------------------------------------+--------------------------------------------------------------+
|
||||
| | ``[theme_item Class.name]`` | ``See [theme_item Label.font].`` | See :ref:`Label.font <class_Label_theme_font_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 | | |
|
||||
| | | <u>Always</u> use this method. |
|
||||
+--------------------------------+----------------------------------------------+------------------------------------+
|
||||
| | ``[s]`` ``[/s]`` | ``[s]Outdated information.[/s]`` | .. raw:: html |
|
||||
| | Strikethrough | | |
|
||||
| | | <s>Outdated information.</s> |
|
||||
+--------------------------------+----------------------------------------------+------------------------------------+
|
||||
| | ``[url]`` ``[/url]`` | | ``[url]https://example.com[/url]`` | | https://example.com |
|
||||
| | Hyperlink | | ``[url=https://example.com]Website[/url]`` | | `Website <https://example.com>`_ |
|
||||
+--------------------------------+----------------------------------------------+------------------------------------+
|
||||
| | ``[center]`` ``[/center]`` | ``[center]2 + 2 = 4[/center]`` | .. raw:: html |
|
||||
| | Horizontal centering | | |
|
||||
| | | <center>2 + 2 = 4</center> |
|
||||
+--------------------------------+----------------------------------------------+------------------------------------+
|
||||
| | ``[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 <https://github.com/HaSa1002/codetranslator>`_ 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
|
||||
|
||||
<class name="Parallax2D" inherits="Node2D" experimental="This node is meant to replace [ParallaxBackground] and [ParallaxLayer]. The implementation may change in the future." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
[...]
|
||||
</class>
|
||||
|
||||
<constant name="RESPONSE_USE_PROXY" value="305" enum="ResponseCode" deprecated="Many clients ignore this response code for security reasons. It is also deprecated by the HTTP standard.">
|
||||
HTTP status code [code]305 Use Proxy[/code].
|
||||
</constant>
|
||||
|
||||
<member name="auto_translate" type="bool" setter="set_auto_translate" getter="is_auto_translating" deprecated="Use [member Node.auto_translate_mode] instead.">
|
||||
Toggles if any text should automatically change to its translated version depending on the current locale.
|
||||
</member>
|
||||
|
||||
<method name="get_method_call_mode" qualifiers="const" deprecated="Use [member AnimationMixer.callback_mode_method] instead.">
|
||||
<return type="int" enum="AnimationPlayer.AnimationMethodCallMode" />
|
||||
<description>
|
||||
Returns the call mode used for "Call Method" tracks.
|
||||
</description>
|
||||
</method>
|
||||
20
documentation/class_reference/index.rst
Normal file
20
documentation/class_reference/index.rst
Normal file
@@ -0,0 +1,20 @@
|
||||
:allow_comments: False
|
||||
|
||||
.. _doc_contributing_writing_documentation:
|
||||
|
||||
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 <https://github.com/godotengine/godot>`_. 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
|
||||
@@ -1,7 +1,7 @@
|
||||
.. _doc_updating_the_class_reference:
|
||||
|
||||
Contributing to the class reference
|
||||
===================================
|
||||
Making Changes
|
||||
==============
|
||||
|
||||
.. highlight:: shell
|
||||
|
||||
94
documentation/guidelines/content_guidelines.rst
Normal file
94
documentation/guidelines/content_guidelines.rst
Normal file
@@ -0,0 +1,94 @@
|
||||
.. _doc_content_guidelines:
|
||||
|
||||
Content guidelines
|
||||
==================
|
||||
|
||||
This document outlines what should be included in the official documentation.
|
||||
Below, you will find a couple of principles and recommendations for writing
|
||||
accessible content.
|
||||
|
||||
We want to achieve two goals:
|
||||
|
||||
1. **Empathize with our users.** We should write in a way that makes it easy for
|
||||
them to learn from the docs.
|
||||
2. **Write a complete reference manual**. Our goal here is not to teach
|
||||
programming fundamentals. Instead, our goal is to provide a reference for how
|
||||
Godot's features work.
|
||||
|
||||
Guidelines and principles
|
||||
-------------------------
|
||||
|
||||
Below are the guidelines we should strive to follow. They are not hard rules,
|
||||
though: sometimes, a topic will require breaking one or more of them.
|
||||
Still, we should strive to achieve the two goals listed above.
|
||||
|
||||
Writing complete and accessible documentation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**A feature doesn't exist unless it is documented**. If a user can't find
|
||||
information about a feature and how it works, it doesn't exist to them. We
|
||||
should ensure that we cover everything Godot does.
|
||||
|
||||
.. note::
|
||||
|
||||
When adding or updating an engine feature, the documentation team needs to
|
||||
know about it. Contributors should open an issue on the `godot-docs` repository
|
||||
when their work gets merged and requires documentation.
|
||||
|
||||
Do your best to keep documents **under 1000 words in length**. If a page goes
|
||||
past that threshold, consider splitting it into two parts. Limiting page size
|
||||
forces us to write concisely and to break up large documents so that each page
|
||||
focuses on a particular problem.
|
||||
|
||||
Each page or section of a page should clearly state what **problem** it tackles
|
||||
and what it will teach the user. Users need to know if they're reading the
|
||||
correct guide for solving the problems they're encountering. For example,
|
||||
instead of writing the heading "Signals", consider writing "Reacting to changes
|
||||
with signals". The second title makes it clear what the purpose of signals is.
|
||||
|
||||
.. note::
|
||||
|
||||
Long section titles lead to long entries in the side menu, which can make
|
||||
navigation cumbersome. Try to keep headings five words long or less.
|
||||
|
||||
If the page assumes specific knowledge of other Godot features, mention it and
|
||||
link to the corresponding documentation. For instance, a page about physics
|
||||
may use signals, in which case you could note that the signals tutorial is a
|
||||
prerequisite. You may also link to other websites for prerequisites beyond the
|
||||
documentation's scope. For example, you could link to an introduction to
|
||||
programming in the getting started guide, or a website that teaches math theory
|
||||
in the math section.
|
||||
|
||||
Limiting cognitive load
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Limit the cognitive load required to read the documentation. The simpler and
|
||||
more explicit language we use, the more efficient it becomes for people to
|
||||
learn. You can do so by:
|
||||
|
||||
1. Introducing only one new concept at a time whenever possible.
|
||||
2. Using simple English, as we recommend in our writing guidelines.
|
||||
3. Including one or more **concrete usage examples**. Prefer a real-world example
|
||||
to one that uses names like ``foo``, ``bar``, or ``baz``.
|
||||
|
||||
While many people may understand more complex language and abstract examples,
|
||||
you will lose others. Understandable writing and practical examples benefit
|
||||
everyone.
|
||||
|
||||
Always make an effort to **put yourself in the user's shoes**. When we
|
||||
understand something thoroughly, it becomes obvious to us. We may fail to think
|
||||
about details relevant to a newcomer, but **good documentation meets users where
|
||||
they are**. We should explain each feature's capabilities or intended uses with
|
||||
the most straightforward language possible.
|
||||
|
||||
Try to remember what you first needed to know when learning about the feature or
|
||||
concept. What new terms did you need to learn? What confused you? What was the
|
||||
hardest to grasp? You will want users to review your work, and we recommend you
|
||||
practice explaining the feature before writing about it.
|
||||
|
||||
.. note::
|
||||
|
||||
Programming fundamentals are a prerequisite for using a complex engine like
|
||||
Godot. Talking about variables, functions, or classes is acceptable. But we
|
||||
should favor plain language over specific terminology like
|
||||
"metaprogramming". If you need to use precise terms, be sure to define them.
|
||||
71
documentation/guidelines/docs_contribution_checklist.rst
Normal file
71
documentation/guidelines/docs_contribution_checklist.rst
Normal file
@@ -0,0 +1,71 @@
|
||||
.. _docs_contribution_checklist:
|
||||
|
||||
Documentation contribution checklist
|
||||
====================================
|
||||
|
||||
This page is a summary of the guidelines to follow when contributing to the
|
||||
documentation. Before you press that **Create pull request** button on GitHub,
|
||||
read over this list to double check if you missed anything.
|
||||
|
||||
You don't need to read all the guidelines here in order to start contributing.
|
||||
If you do miss something, it will be pointed out during review. However,
|
||||
following the guidelines you are aware of as best you can will help speed up the
|
||||
review process.
|
||||
|
||||
Writing style
|
||||
-------------
|
||||
|
||||
:ref:`See here. <doc_docs_writing_guidelines_clear_english_rules>`
|
||||
|
||||
- Use the active voice.
|
||||
- Use precise action verbs.
|
||||
- Avoid verbs that end in -ing.
|
||||
- Remove unnecessary adverbs and adjectives.
|
||||
- Ban these 8 words: obvious, simple, basic, easy, actual, just, clear, and however.
|
||||
- Use explicit references.
|
||||
- Use 's to show possession.
|
||||
- Use the Oxford comma.
|
||||
|
||||
Code examples
|
||||
-------------
|
||||
|
||||
- Use dynamic typing. :ref:`See here. <doc_docs_writing_guidelines_dynamic_typing>`
|
||||
- Use real, practical examples. Avoid ``foo`` / ``bar`` examples. :ref:`See here. <doc_docs_writing_guidelines_real_world_code_example>`
|
||||
|
||||
Manual style and formatting
|
||||
---------------------------
|
||||
|
||||
- Use common vocabulary for the editor interface. :ref:`See here. <doc_docs_writing_guidelines_common_vocabulary>`
|
||||
- Use ``:kbd:`` for keyboard shortcuts. :ref:`See here. <doc_docs_writing_guidelines_keyboard_shortcuts>`
|
||||
- Literals use ``code style``. :ref:`See here. <doc_docs_writing_guidelines_literals>`
|
||||
- Classes link to the class reference once, then use ``ClassName`` for the rest
|
||||
of the page.
|
||||
Methods and properties link to the class ref once, then use ``PropertyName``
|
||||
for the rest of the page. :ref:`See here. <doc_docs_writing_guidelines_class_properties_methods>`
|
||||
- Editor UI, like menus, windows, and editor navigation paths, use
|
||||
``Bold Style``. :ref:`See here. <doc_docs_writing_guidelines_editor_ui>`
|
||||
- Link to project settings when referencing them. :ref:`See here. <doc_docs_writing_guidelines_project_settings>`
|
||||
- Text is manually wrapped to 80-100 characters. :ref:`See here. <doc_docs_writing_guidelines_manually_wrapping_lines>`
|
||||
- No trailing whitespace at the end of lines.
|
||||
- Most of the time, avoid mentioning a specific Godot version. :ref:`See here. <doc_docs_writing_guidelines_specific_version>`
|
||||
|
||||
Images and videos
|
||||
-----------------
|
||||
|
||||
- New (and updated) images are in WebP format. :ref:`See here. <doc_docs_image_guidelines_format_conversion>`
|
||||
- Editor screenshots are cropped. :ref:`See here. <doc_docs_image_guidelines_cropping>`
|
||||
- Images larger than 1080p or 300kb are scaled down. :ref:`See here. <doc_docs_image_guidelines_scaling_down>`
|
||||
- Outlines in images use ``fffb44`` yellow. :ref:`See here. <doc_docs_image_guidelines_outlines>`
|
||||
- Videos use the ``:autoplay:``, ``:loop:``, and ``:muted:`` tags. :ref:`See here. <doc_docs_image_guidelines_videos>`
|
||||
|
||||
GitHub
|
||||
------
|
||||
|
||||
- The PR title starts with a word like ``Fix``, ``Add``, ``Update``,
|
||||
``Clarify``, or ``Improve``.
|
||||
- If the PR closes an issue, link to the issue with one of GitHub's
|
||||
`keywords <https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests>`__:
|
||||
``closes``, ``fixes``, or ``resolves``, in the text of the PR.
|
||||
- Ideally, PR contains a single commit. However, multiple commits can be
|
||||
:ref:`squashed <doc_pr_workflow_rebase>` later.
|
||||
|
||||
267
documentation/guidelines/docs_image_guidelines.rst
Normal file
267
documentation/guidelines/docs_image_guidelines.rst
Normal file
@@ -0,0 +1,267 @@
|
||||
.. _docs_image_guidelines:
|
||||
|
||||
Creating documentation images and videos
|
||||
========================================
|
||||
|
||||
Throughout the documentation, images are often needed to make the explanation
|
||||
of a feature or concept as clear as possible for a reader. This page will
|
||||
explain the process from beginning to end.
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
Capturing an image
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To take a picture of something in Godot, a screen capture tool can be used.
|
||||
|
||||
On Windows 10 and 11 that would be the Snip & Sketch program.
|
||||
Pressing :kbd:`Windows + Shift + S` lets you take a screenshot
|
||||
of a portion of the screen and save it to the clipboard.
|
||||
After pressing those keys, click and drag over
|
||||
the area you wish to take a picture of.
|
||||
|
||||
On macOS, pressing :kbd:`Shift + Command + 3` does the same.
|
||||
To take a picture of the entire screen press :kbd:`Shift + Command + 4`.
|
||||
All screenshots taken will be saved to the desktop.
|
||||
|
||||
Each Linux desktop environment has its own screenshot tool. For example,
|
||||
on KDE Plasma the program Spectacle is used for taking screenshots. If your
|
||||
distribution doesn't come with one by default try searching its package
|
||||
repository, or Flathub if that's supported.
|
||||
|
||||
All screenshots should ideally be taken on a 1080p screen. Anything higher
|
||||
resolution is adding detail that doesn't make the documentation better and
|
||||
dramatically increases file size. If you're taking screenshots on a higher
|
||||
resolution screen the screenshot should be scaled down. There are instructions
|
||||
on how to do this later on this page.
|
||||
|
||||
.. _doc_docs_image_guidelines_format_conversion:
|
||||
|
||||
Format conversion
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
The current format for images in Godot's documentation is WebP (``.webp``).
|
||||
While some Linux programs will support saving screenshots in this format, macOS
|
||||
and the Snip & Sketch program on Windows do not. For images that don't need
|
||||
editing, such as precise cropping or adding outlines, Squoosh can be used.
|
||||
`Squoosh <https://squoosh.app/>`_ is a converter developed by Google, is open
|
||||
source, and doesn't give Google any image rights by using it. When choosing
|
||||
compression if you can get an image that's under 300KB in size use lossless
|
||||
compression. If it's over 300KB, use just enough lossy compression to get it
|
||||
under that size. If this results in noticeable compression artifacts using less
|
||||
compression is fine, even if the file size is bigger.
|
||||
|
||||
If you already have an image editor such as GIMP, Krita or Photoshop installed
|
||||
it may have the ability to open an image then save it as a WebP file.
|
||||
|
||||
.. note::
|
||||
|
||||
Since WebP supports animations and the documentation can display videos,
|
||||
GIFs should be avoided. Their compression is inefficient and they only support
|
||||
a 256-color palette with 1-bit transparency.
|
||||
|
||||
.. _doc_docs_image_guidelines_cropping:
|
||||
|
||||
Cropping
|
||||
~~~~~~~~
|
||||
|
||||
For a screenshot of a 2D or 3D scene in the editor, the above steps will be enough.
|
||||
But for most UI images some extra work should be done, specifically cropping to
|
||||
make an image look clean. Below is an example of good cropping.
|
||||
|
||||
.. image:: img/cropped_image.webp
|
||||
|
||||
For cropping Krita is the recommended program. While some screenshot programs do
|
||||
have cropping built-in it's not always easy to get something precise. And while
|
||||
Krita is designed as a painting program the cropping tool gives you pixel precision
|
||||
by default. Of course, feel free to use a different program you are familiar with.
|
||||
|
||||
If you've never used Krita before download it from the `official Krita website <https://krita.org/en/download/>`_,
|
||||
on Linux you may also be able to download it from your distributions repository,
|
||||
flathub is also an option. Once it's installed on your computer open Krita then
|
||||
open the image you want to crop. This button on the left panel is the crop tool.
|
||||
|
||||
.. image:: img/crop_tool.webp
|
||||
|
||||
After selecting it, click on the image, you should now have cropping tools available.
|
||||
|
||||
.. image:: img/crop_edit.webp
|
||||
|
||||
Click and drag the white boxes to adjust what gets cropped, if you zoom in close
|
||||
to the image you will see the individual pixels in an image, which is useful for
|
||||
precision.
|
||||
|
||||
.. image:: img/crop_pixels.webp
|
||||
|
||||
If you make a mistake and overcrop don't worry, cropping is non-destructive in
|
||||
Krita and can be adjusted. Click on the image with your cropping tool still selected
|
||||
and the controls will return.
|
||||
|
||||
.. _doc_docs_image_guidelines_scaling_down:
|
||||
|
||||
Scaling down an image
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
As explained earlier on this page, all images taken on a screen that is a higher resolution
|
||||
than 1080p should be scaled down. To do this in Krita click on **Image** on the top bar, and
|
||||
from the dropdown menu select **Scale Image To New Size**. This menu can also be opened by
|
||||
pressing :kbd:`Ctrl + Alt + I`. On this menu you want to adjust the pixel dimensions. For
|
||||
anything taken on a 4K monitor change the value of the width and height to half of its current
|
||||
value, for anything taken on a 1440p monitor multiply the width and height by 0.75. Make
|
||||
sure the **Constrain Proportions** box at the bottom of the menu is checked so you only have
|
||||
to change 1 value.
|
||||
|
||||
Saving as WebP in Krita
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To save an image as webp if it isn't already one, Go to **File > Save As**. Select **webp** from the
|
||||
**Save as type:** dropdown, then choose wherever you want to save it. After clicking **Save** a menu
|
||||
will popup with webp options. Make sure **Lossless** is checked and **Quality** is set to 100%. This
|
||||
means the image will not lose detail and will be as small as possible.
|
||||
|
||||
If the image is over 300KB in size try compressing it losslessly using `Squoosh <https://squoosh.app/>`_.
|
||||
If it's still over 300KB change to lossy compression and slowly increase the compression until it's under
|
||||
300KB. If this results in noticeable compression artifacts using less compression is fine, even if the file
|
||||
size is bigger.
|
||||
|
||||
.. _doc_docs_image_guidelines_outlines:
|
||||
|
||||
Outlines, arrows and text
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sometimes an image needs something extra to properly direct the readers
|
||||
attention, or make something clear. Outlines and arrows can be used
|
||||
for this purpose. For these types of edits Inkscape is the recommended open
|
||||
source program, it can be downloaded from the `official Inkscape website <https://inkscape.org/>`_.
|
||||
Like Krita, if you're on Linux you can also check your distributions repository
|
||||
or get it from Flathub.
|
||||
|
||||
A full tutorial on creating outlines is not provided here, we recommend searching
|
||||
for various tutorials on how to use it online. However there are two standards
|
||||
for doc image outlines and arrows. First, the color should be yellow, specifically
|
||||
this hex color: ``fffb44`` (``fffb44ff`` if there is a transparency value like in Inkscape).
|
||||
This color was chosen specifically to make sure color blind people do not have
|
||||
issues reading the documentation, other colors can be used in addition to this yellow
|
||||
if multiple outlines on an image are needed, red should be avoided. The second standard
|
||||
is that all outlines and arrow lines should be 2 pixels wide.
|
||||
|
||||
Finally, some images might require text to differentiate multiple parts of an image.
|
||||
There are no strict requirements other than use an easy to read non fancy font. As for
|
||||
color the yellow color from before should also be used, but black or other colors can
|
||||
be used if appropriate. For example, if yellow blends into the image, or if there are
|
||||
multiple outlines in multiple colors.
|
||||
|
||||
Adding an image to a documentation page
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Once you've finished working on your image, it can be added to the documentation.
|
||||
All images are stored in folders named ``img`` next to the page they are used in.
|
||||
|
||||
To add your image, add it to the ``img`` folder that's in the same folder as the
|
||||
``.rst`` file for the page (create it if it doesn't exist). In the ``.rst`` page,
|
||||
images should be included with the following code snippet:
|
||||
|
||||
::
|
||||
|
||||
.. image:: img/documentation_image.webp
|
||||
|
||||
Where ``documentation_image.webp`` would be changed to the name of the image you
|
||||
created. Name your images in a way that makes their meaning clear, possibly with
|
||||
a prefix that makes their relationship to a documentation page explicit.
|
||||
|
||||
.. _doc_docs_image_guidelines_videos:
|
||||
|
||||
Videos
|
||||
------
|
||||
|
||||
Capturing a video
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
To record a video of something in Godot, a screen capture tool can be used.
|
||||
Operating systems generally don't come with tools that are flexible enough
|
||||
for this, so you'll need to install a third-party utility.
|
||||
|
||||
`OBS Studio <https://obsproject.com/>`__ is the most popular option, but
|
||||
`SimpleScreenRecorder <https://www.maartenbaert.be/simplescreenrecorder/>`__
|
||||
can be used as an alternative on Linux. `ShareX <https://getsharex.com/>`__
|
||||
can be used as an alternative on Windows. All these tools can be configured
|
||||
to record the entire screen, a specific window or a predetermined rectangle.
|
||||
|
||||
The recommended framerate for video recordings is 60 FPS, although you can use
|
||||
30 FPS for longer videos to reduce their file size. For fullscreen videos,
|
||||
use a resolution of 1280×720.
|
||||
|
||||
.. note::
|
||||
|
||||
Godot's :ref:`Movie Maker mode <doc_creating_movies>` can be used to record
|
||||
the output of a running project, including its audio. This doesn't require
|
||||
installing any third-party software and avoids any frame drops (even when
|
||||
recording on a slow device), but it's less flexible.
|
||||
|
||||
Compressing the captured video
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The recommendation is to record your video in the highest quality possible
|
||||
(without dropping frames due to excessive CPU/GPU utilization), then re-encode
|
||||
it later to reduce its file size. This results in more efficient compression
|
||||
than directly aiming for a small file size, as real-time compression methods are
|
||||
less efficient than slower compression methods.
|
||||
|
||||
To re-encode videos for a smaller file size, use `HandBrake <https://handbrake.fr/>`__
|
||||
or the `FFmpeg <https://ffmpeg.org/>` command line below:
|
||||
|
||||
::
|
||||
|
||||
ffmpeg -i input.mp4 -crf 23 output.webm
|
||||
|
||||
The number after ``-crf`` adjusts the video quality, with higher numbers
|
||||
resulting in *lower* quality (and smaller file sizes). A CRF of ``23`` is a good
|
||||
starting point, but you may need to use a higher value for longer videos to
|
||||
ensure the file size remains reasonable. Try to aim for a file size under 2 MB
|
||||
if possible.
|
||||
|
||||
If the video was recorded in a higher resolution or framerate, you can adjust
|
||||
its output resolution and framerate as follows:
|
||||
|
||||
::
|
||||
|
||||
ffmpeg -i input.mp4 -crf 23 -vf scale=1280:-2 -r 30 output.webm
|
||||
|
||||
This results in a video resolution around 1280×720 at 30 FPS. The exact
|
||||
video resolution will vary depending on the source's aspect ratio.
|
||||
|
||||
.. tip::
|
||||
|
||||
If the video was recorded with an audio track but this audio track is not
|
||||
necessary, consider stripping it by adding the ``-an`` option to the FFmpeg
|
||||
command line (before the output file name). This will reduce file size and
|
||||
also ensure audio controls don't show up on the video when played in a
|
||||
browser.
|
||||
|
||||
Adding a video to a documentation page
|
||||
--------------------------------------
|
||||
|
||||
Once you've finished working on your video, it can be added to the documentation.
|
||||
All videos are stored in folders named ``video`` next to the page they are used in.
|
||||
|
||||
To add your video, add it to the ``video`` folder that's in the same folder as the
|
||||
``.rst`` file for the page (create it if it doesn't exist). In the ``.rst`` page,
|
||||
videos should be included with the following code snippet:
|
||||
|
||||
::
|
||||
|
||||
.. video:: video/csg_tools.webm
|
||||
:alt: Put a text description of the video here
|
||||
:autoplay:
|
||||
:loop:
|
||||
:muted:
|
||||
:align: default
|
||||
|
||||
Where ``documentation_video.webp`` would be changed to the name of the video you
|
||||
created. Name your videos in a way that makes their meaning clear, possibly with
|
||||
a prefix that makes their relationship to a documentation page explicit.
|
||||
|
||||
The ``:autoplay:``, ``:loop:`` and ``:muted:`` flags should always be specified
|
||||
unless the video needs to play audio. In this case, do not specify *any* of these flags.
|
||||
The ``:align: default`` flag should always be specified.
|
||||
917
documentation/guidelines/docs_writing_guidelines.rst
Normal file
917
documentation/guidelines/docs_writing_guidelines.rst
Normal file
@@ -0,0 +1,917 @@
|
||||
.. _doc_docs_writing_guidelines:
|
||||
|
||||
Writing guidelines
|
||||
==================
|
||||
|
||||
The Godot community is rich and international. Users come from all
|
||||
around the world. Some of them are young, and many aren't native English
|
||||
speakers. That's why we must all write using a clear and a common
|
||||
language. For the class reference, the goal is to make it easy to read
|
||||
for everyone and precise.
|
||||
|
||||
In summary, always try to:
|
||||
|
||||
1. Use the active voice
|
||||
2. Use precise action verbs
|
||||
3. Avoid verbs that end in -ing
|
||||
4. Remove unnecessary adverbs and adjectives.
|
||||
5. Ban these 8 words: obvious, simple, basic, easy, actual, just, clear, and however
|
||||
6. Use explicit references
|
||||
7. Use 's to show possession
|
||||
8. Use the Oxford comma
|
||||
|
||||
There are 3 rules to describe classes:
|
||||
|
||||
1. Give an overview of the node in the brief description
|
||||
2. Mention what methods return if it's useful
|
||||
3. Use "if true" to describe booleans
|
||||
|
||||
.. note::
|
||||
|
||||
A technical writer's job is to pack as much information as possible into
|
||||
the smallest and clearest sentences possible. These guidelines will help
|
||||
you work towards that goal.
|
||||
|
||||
.. seealso::
|
||||
|
||||
See the :ref:`content guidelines <doc_content_guidelines>` for information
|
||||
on the types of documentation you can write in the official documentation.
|
||||
|
||||
.. _doc_docs_writing_guidelines_clear_english_rules:
|
||||
|
||||
7 rules for clear English
|
||||
-------------------------
|
||||
|
||||
Use the active voice
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Use the active voice when possible. Take the classes, methods, and
|
||||
constants you describe as the subject. It's natural to write using the
|
||||
passive voice, but it's harder to read and produces longer sentences.
|
||||
|
||||
.. highlight:: none
|
||||
|
||||
Passive:
|
||||
|
||||
::
|
||||
|
||||
The man **was bitten** by the dog.
|
||||
|
||||
Active:
|
||||
|
||||
::
|
||||
|
||||
The dog bit the man.
|
||||
|
||||
**Don't** use the passive voice:
|
||||
|
||||
::
|
||||
|
||||
void edit_set_pivot ( Vector2 pivot )
|
||||
[...] This method **is implemented** only in some nodes that inherit Node2D.
|
||||
|
||||
**Do** use the node's name as a noun:
|
||||
|
||||
::
|
||||
|
||||
void edit_set_pivot ( Vector2 pivot )
|
||||
[...] Only some Node2Ds **implement** this method.
|
||||
|
||||
Use precise action verbs
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Favor precise yet common verbs over generic ones like ``make``, ``set``,
|
||||
and any expression you can replace with a single word.
|
||||
|
||||
**Don't** repeat the method's name. It already states it sets the pivot
|
||||
value to a new one:
|
||||
|
||||
::
|
||||
|
||||
void edit_set_pivot ( Vector2 pivot )
|
||||
Set the pivot position of the 2D node to [code]pivot[/code] value. [...]
|
||||
|
||||
**Do** explain what's the consequence of this "set": use precise verbs
|
||||
like ``place``, ``position``, ``rotate``, ``fade``, etc.
|
||||
|
||||
::
|
||||
|
||||
void edit_set_pivot ( Vector2 pivot )
|
||||
Position the node's pivot to the [code]pivot[/code] value. [...]
|
||||
|
||||
Avoid verbs that end in -ing
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The progressive forms describe continuous actions. E.g. "is calling",
|
||||
"is moving".
|
||||
|
||||
**Don't** use the progressive form for instant changes.
|
||||
|
||||
::
|
||||
|
||||
Vector2 move ( Vector2 rel_vec )
|
||||
Move the body in the given direction, **stopping** if there is an obstacle. [...]
|
||||
|
||||
**Do** use simple present, past, or future.
|
||||
|
||||
::
|
||||
|
||||
Vector2 move ( Vector2 rel_vec )
|
||||
Moves the body in the vector's direction. The body **stops** if it collides with an obstacle. [...]
|
||||
|
||||
Exception: If the subject is not clear, replacing "ing" verbs is not an
|
||||
improvement. For example, in the previous sentence, "it replaces"
|
||||
would not make much sense where "replacing" currently is.
|
||||
|
||||
You may use the progressive tense to describe actions that are
|
||||
continuous in time. Anything like animation or coroutines.
|
||||
|
||||
.. tip::
|
||||
|
||||
Verbs can turn into adjectival nouns with -ing. This is not a
|
||||
conjugation, so you may use them: ``the remaining movement``,
|
||||
``the missing file``, etc.
|
||||
|
||||
Remove unnecessary adverbs and adjectives
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Write as few adjectives and adverbs as possible. Only use them if they
|
||||
add key information to the description.
|
||||
|
||||
**Don't** use redundant or meaningless adverbs. Words that lengthen the
|
||||
documentation but don't add any information:
|
||||
|
||||
::
|
||||
|
||||
**Basically** a big texture [...]
|
||||
|
||||
**Do** write short sentences in a simple, descriptive language:
|
||||
|
||||
::
|
||||
|
||||
A big texture [...]
|
||||
|
||||
Ban these 8 words
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Don't** ever use these 8 banned words:
|
||||
|
||||
1. obvious
|
||||
2. simple
|
||||
3. basic
|
||||
4. easy
|
||||
5. actual
|
||||
6. just
|
||||
7. clear
|
||||
8. however (some uses)
|
||||
|
||||
Game creation and programming aren't simple, and nothing's easy to
|
||||
someone learning to use the API for the first time. Other words in the
|
||||
list, like ``just`` or ``actual`` won't add any info to the sentence.
|
||||
Don't use corresponding adverbs either: obviously, simply, basically,
|
||||
easily, actually, clearly.
|
||||
|
||||
**Don't** example. The banned words lengthen the description and take
|
||||
attention away from the most important info:
|
||||
|
||||
::
|
||||
|
||||
**TextureRect**
|
||||
Control frame that **simply** draws an assigned texture. It can stretch or not. It's a **simple** way to **just** show an image in a UI.
|
||||
|
||||
**Do** remove them:
|
||||
|
||||
::
|
||||
|
||||
**TextureRect**
|
||||
[Control] node that displays a texture. The texture can stretch to the node's bounding box or stay in the center. Useful to display sprites in your UIs.
|
||||
|
||||
"Simple" never helps. Remember, for other users, anything could be
|
||||
complex or frustrate them. There's nothing like a good old *it's simple*
|
||||
to make you cringe. Here's the old brief description, the first sentence
|
||||
on the Timer node's page:
|
||||
|
||||
::
|
||||
|
||||
**Timer**
|
||||
A **simple** Timer node.
|
||||
|
||||
**Do** explain what the node does instead:
|
||||
|
||||
::
|
||||
|
||||
**Timer**
|
||||
Calls a function of your choice after a certain duration.
|
||||
|
||||
**Don't** use "basic", it is too vague:
|
||||
|
||||
::
|
||||
|
||||
**Vector3**
|
||||
Vector class, which performs **basic** 3D vector math operations.
|
||||
|
||||
**Do** use the brief description to offer an overview of the node:
|
||||
|
||||
::
|
||||
|
||||
**Vector3**
|
||||
Provides essential math functions to manipulate 3D vectors: cross product, normalize, rotate, etc.
|
||||
|
||||
Use explicit references
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Favor explicit references over implicit ones.
|
||||
|
||||
**Don't** use words like "the former", "the latter", etc. They're not
|
||||
the most common in English, and they require you to check the reference.
|
||||
|
||||
::
|
||||
|
||||
[code]w[/code] and [code]h[/code] define right and bottom margins. The **latter** two resize the texture so it fits in the defined margin.
|
||||
|
||||
**Do** repeat words. They remove all ambiguity:
|
||||
|
||||
::
|
||||
|
||||
[code]w[/code] and [code]h[/code] define right and bottom margins. **[code]w[/code] and [code]h[/code]** resize the texture so it fits the margin.
|
||||
|
||||
If you need to repeat the same variable name 3 or 4 times, you probably
|
||||
need to rephrase your description.
|
||||
|
||||
Use 's to show possession
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Avoid "The milk **of** the cow". It feels unnatural in English. Write "The cow's
|
||||
milk" instead.
|
||||
|
||||
**Don't** write "of the X":
|
||||
|
||||
::
|
||||
|
||||
The region **of the AtlasTexture that is** used.
|
||||
|
||||
**Do** use ``'s``. It lets you put the main subject at the start of the
|
||||
sentence, and keep it short:
|
||||
|
||||
::
|
||||
|
||||
The **AtlasTexture's** used region.
|
||||
|
||||
Use the Oxford comma to enumerate anything
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
From the Oxford dictionary:
|
||||
|
||||
The 'Oxford comma' is an optional comma before the word 'and' at the end of a list:
|
||||
*We sell books, videos, and magazines.*
|
||||
|
||||
[...] Not all writers and publishers use it, but it can clarify the meaning of a sentence when the items in a list are not single words:
|
||||
*These items are available in black and white, red and yellow, and blue and green.*
|
||||
|
||||
**Don't** leave the last element of a list without a comma:
|
||||
|
||||
::
|
||||
|
||||
Create a CharacterBody2D node, a CollisionShape2D node and a sprite node.
|
||||
|
||||
**Do** add a comma before `and` or `or`, for the last
|
||||
element of a list with more than two elements.
|
||||
|
||||
::
|
||||
|
||||
Create a CharacterBody2D node, a CollisionShape2D node, and a sprite node.
|
||||
|
||||
|
||||
How to write methods and classes
|
||||
--------------------------------
|
||||
|
||||
.. _doc_docs_writing_guidelines_dynamic_typing:
|
||||
|
||||
Dynamic vs static typing
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The code examples in the documentation should follow a consistent style not to
|
||||
confuse users. As static type hints are an optional feature of GDScript, we
|
||||
chose to stick to writing dynamic code. This leads to writing GDScript that is
|
||||
concise and accessible.
|
||||
|
||||
The exception is topics that explain static typing concepts to users.
|
||||
|
||||
**Don't** add a type hint with a colon or by casting:
|
||||
|
||||
::
|
||||
|
||||
const MainAttack := preload("res://fire_attack.gd")
|
||||
var hit_points := 5
|
||||
var name: String = "Bob"
|
||||
var body_sprite := $Sprite2D as Sprite2D
|
||||
|
||||
|
||||
**Do** write constants and variables with dynamic typing:
|
||||
|
||||
::
|
||||
|
||||
const MainAttack = preload("res://fire_attack.gd")
|
||||
var hit_points = 5
|
||||
var name = "Bob"
|
||||
var body_sprite = $Sprite2D
|
||||
|
||||
|
||||
**Don't** write functions with inferred arguments or return types:
|
||||
|
||||
::
|
||||
|
||||
func choose(arguments: PackedStringArray) -> String:
|
||||
# Chooses one of the arguments from array with equal chances
|
||||
randomize()
|
||||
var size := arguments.size()
|
||||
var choice: int = randi() % size
|
||||
return arguments[choice]
|
||||
|
||||
**Do** write functions using dynamic typing:
|
||||
|
||||
::
|
||||
|
||||
func choose(arguments):
|
||||
# Chooses one of the arguments from array with equal chances
|
||||
randomize()
|
||||
var size = arguments.size()
|
||||
var choice = randi() % size
|
||||
return arguments[choice]
|
||||
|
||||
.. _doc_docs_writing_guidelines_real_world_code_example:
|
||||
|
||||
Use real-world code examples where appropriate
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Real-world examples are more accessible to beginners than abstract ``foos`` and
|
||||
``bars``. You can also copy them directly from your game projects, ensuring that
|
||||
any code snippet compiles without errors.
|
||||
|
||||
Writing ``var speed = 10`` rather than ``var my_var = 10`` allows beginners to
|
||||
understand code better. It gives them a frame of reference as to where they
|
||||
could use the code snippets in a live project.
|
||||
|
||||
**Don't** write made-up examples:
|
||||
|
||||
.. code-block:: gdscript
|
||||
|
||||
@onready var a = preload("res://MyPath")
|
||||
@onready var my_node = $MyNode
|
||||
|
||||
|
||||
func foo():
|
||||
# Do stuff
|
||||
|
||||
**Do** write concrete examples:
|
||||
|
||||
.. code-block:: gdscript
|
||||
|
||||
@onready var sfx_player_gun = preload("res://Assets/Sound/SFXPlayerGun.ogg")
|
||||
@onready var audio_player = $Audio/AudioStreamPlayer
|
||||
|
||||
|
||||
func play_shooting_sound():
|
||||
audio_player.stream = sfx_player_gun
|
||||
audio_player.play()
|
||||
|
||||
Of course, there are times when using real-world examples is impractical. In
|
||||
those situations, you should still avoid using names such as ``my_var``,
|
||||
``foo()`` or ``my_func()`` and consider more meaningful names for your examples.
|
||||
|
||||
Give an overview of the node in the brief description
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The brief description is the reference's most important sentence. It's
|
||||
the user's first contact with a node:
|
||||
|
||||
1. It's the only description in the "Create New Node" dialog.
|
||||
2. It's at the top of every page in the reference
|
||||
|
||||
The brief description should explain the node's role and its
|
||||
functionality, in up to 200 characters.
|
||||
|
||||
**Don't** write tiny and vague summaries:
|
||||
|
||||
::
|
||||
|
||||
**Node2D**
|
||||
Base node for 2D system.
|
||||
|
||||
**Do** give an overview of the node's functionality:
|
||||
|
||||
::
|
||||
|
||||
**Node2D**
|
||||
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
|
||||
|
||||
Use the node's full description to provide more information, and a code
|
||||
example, if possible.
|
||||
|
||||
Mention what methods return if it's useful
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Some methods return important values. Describe them at the end of the
|
||||
description, ideally on a new line. No need to mention the return values
|
||||
for any method whose name starts with ``set`` or ``get``.
|
||||
|
||||
**Don't** use the passive voice:
|
||||
|
||||
::
|
||||
|
||||
Vector2 move ( Vector2 rel_vec )
|
||||
[...] The returned vector is how much movement was remaining before being stopped.
|
||||
|
||||
**Do** always use "Returns".
|
||||
|
||||
::
|
||||
|
||||
Vector2 move ( Vector2 rel_vec )
|
||||
[...] Returns the remaining movement before the body was stopped.
|
||||
|
||||
Notice the exception to the "direct voice" rule: with the move method,
|
||||
an external collider can influence the method and the body that calls
|
||||
``move``. In this case, you can use the passive voice.
|
||||
|
||||
Use "if true" to describe booleans
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
For boolean member variables, always use ``if true`` and/or
|
||||
``if false``, to stay explicit. ``Controls whether or not`` may be
|
||||
ambiguous and won't work for every member variable.
|
||||
|
||||
Also, surround boolean values, variable names and methods with ``[code][/code]``.
|
||||
|
||||
**Do** start with "if true":
|
||||
|
||||
::
|
||||
|
||||
Timer.autostart
|
||||
If [code]true[/code], the timer will automatically start when entering the scene tree.
|
||||
|
||||
|
||||
Use ``[code]`` around arguments
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In the class reference, always surround arguments with ``[code][/code]``. In the
|
||||
documentation and in Godot, it will display like ``this``. When you edit XML
|
||||
files in the Godot repository, replace existing arguments written like 'this' or
|
||||
\`this\` with ``[code]this[/code]``.
|
||||
|
||||
.. _doc_docs_writing_guidelines_common_vocabulary:
|
||||
|
||||
Common vocabulary to use in Godot's documentation
|
||||
-------------------------------------------------
|
||||
|
||||
The developers chose some specific words to refer to areas of the
|
||||
interface. They're used in the sources, in the documentation, and you
|
||||
should always use them instead of synonyms, so the users know what
|
||||
you're talking about.
|
||||
|
||||
.. figure:: img/editor-vocabulary-overview.png
|
||||
:alt: Overview of the interface and common vocabulary
|
||||
|
||||
Overview of the interface and common vocabulary
|
||||
|
||||
In the top left corner of the editor lie the ``main menus``. In the
|
||||
center, the buttons change the ``workspace``. And together the buttons
|
||||
in the top right are the ``playtest buttons``. The area in the center,
|
||||
that displays the 2D or the 3D space, is the ``viewport``. At its top,
|
||||
you find a list of ``tools`` inside the ``toolbar``.
|
||||
|
||||
The tabs or dockable panels on either side of the viewport are
|
||||
``docks``. You have the ``FileSystem dock``, the ``Scene dock`` that
|
||||
contains your scene tree, the ``Import dock``, the ``Node dock``, and
|
||||
the ``Inspector`` or ``Inspector dock``. With the default layout you may
|
||||
call the tabbed docks ``tabs``: the ``Scene tab``, the ``Node tab``...
|
||||
|
||||
The Animation, Debugger, etc. at the bottom of the viewport are
|
||||
``panels``. Together they make up the ``bottom panels``.
|
||||
|
||||
Foldable areas of the Inspector are ``sections``. The node's parent
|
||||
class names, which you can't fold, are ``Classes`` e.g. the
|
||||
``CharacterBody2D class``. And individual lines with key-value pairs are
|
||||
``properties``. E.g. ``position`` or ``modulate color`` are both
|
||||
``properties``.
|
||||
|
||||
.. _doc_docs_writing_guidelines_keyboard_shortcuts:
|
||||
|
||||
Keyboard shortcut guidelines
|
||||
----------------------------
|
||||
|
||||
Keyboard and mouse shortcuts should make use of the ``:kbd:`` tag, which allows
|
||||
shortcuts to stand out from the rest of the text and inline code. Use the
|
||||
compact form for modifier keys (:kbd:`Ctrl`/:kbd:`Cmd`) instead of their spelled
|
||||
out form (:kbd:`Control`/:kbd:`Command`). For combinations, use the ``+`` symbol
|
||||
with a space on either side of the symbol.
|
||||
|
||||
Make sure to mention shortcuts that differ on macOS compared to other platforms.
|
||||
You can find a list of all shortcuts, including what they are on macOS, on
|
||||
:ref:`this page <doc_default_key_mapping>`.
|
||||
|
||||
Try to integrate the shortcut into sentences the best you can. Here are some
|
||||
examples with the ``:kbd:`` tag left as-is for better visibility:
|
||||
|
||||
- Press ``:kbd:`Ctrl + Alt + T``` to toggle the panel (``:kbd:`Opt + Cmd + T``` on macOS).
|
||||
- Press ``:kbd:`Space``` and hold the left mouse button to pan in the 2D editor.
|
||||
- Press ``:kbd:`Shift + Up Arrow``` to move the node upwards by 8 pixels.
|
||||
|
||||
.. _doc_docs_writing_guidelines_manual_style:
|
||||
|
||||
Manual style guidelines
|
||||
-----------------------
|
||||
|
||||
Follow these formatting and style guidelines when writing the manual.
|
||||
|
||||
Use your best judgement. If you can write more clearly by breaking one of these
|
||||
guidelines, please do! But remember that the guidelines exist for a reason.
|
||||
|
||||
.. note:: In many cases, the manual does not follow these guidelines. If you are
|
||||
already making changes to a paragraph or section of the docs, update it to
|
||||
follow these standards. Avoid making unrelated changes that *only* update style,
|
||||
since every change will require the paragraph to be re-translated.
|
||||
|
||||
Text styles
|
||||
~~~~~~~~~~~
|
||||
|
||||
There are a few styles that the manual uses.
|
||||
|
||||
+---------------------+--------------------------+------------------------------------------------------------------------+
|
||||
| Style | RST formatting | Typical usage |
|
||||
+=====================+==========================+========================================================================+
|
||||
| Plaintext | ``text`` | Used for most text. |
|
||||
+---------------------+--------------------------+------------------------------------------------------------------------+
|
||||
| *Italics* | ``*text*`` | Used for emphasis. Used for introducing new terms. |
|
||||
+---------------------+--------------------------+------------------------------------------------------------------------+
|
||||
| **Bold** | ``**text**`` | Used for emphasis, and for editor UI like menus and windows. |
|
||||
| | | |
|
||||
+---------------------+--------------------------+------------------------------------------------------------------------+
|
||||
| ``Code`` | `` text `` | Used for variable names, literal values, and code snippets. ``code`` is|
|
||||
| | | used in many cases where you would use "quoted plaintext" in typical |
|
||||
| | | English. |
|
||||
+---------------------+--------------------------+------------------------------------------------------------------------+
|
||||
| "Quotes" | ``"text"`` | Used for some literal or quoted values. In many cases, another |
|
||||
| | | style is preferred. |
|
||||
+---------------------+--------------------------+------------------------------------------------------------------------+
|
||||
|
||||
Emphasis
|
||||
~~~~~~~~
|
||||
|
||||
Use either **bold style** or *italic style* to emphasize words or sentences.
|
||||
In most cases, either **bold** or *italics* is fine. Use whichever seems best,
|
||||
or whatever the page already uses.
|
||||
|
||||
Prefer using **bold style** for simple emphasis.
|
||||
|
||||
- Do **not** close the window without saving first.
|
||||
|
||||
Use *italic style* or to emphasize one word in the context of a sentence.
|
||||
|
||||
- You can *add* a node to the scene (but you can't connect one).
|
||||
- You can add a *node* to the scene (but you can't add a resource).
|
||||
- You can add a node to the *scene* (but you can't add one to a resource).
|
||||
|
||||
Use *italic style* when introducing new technical terms. **Bold style**
|
||||
is fine too.
|
||||
|
||||
- Godot uses *nodes* with *scripts* in a *scene tree*.
|
||||
- Godot uses **nodes** with **scripts** in a **scene tree**.
|
||||
|
||||
.. _doc_docs_writing_guidelines_literals:
|
||||
|
||||
Literals
|
||||
~~~~~~~~
|
||||
|
||||
Use ``code style`` for literal values. Literals include:
|
||||
|
||||
- Integer or ``int`` literals like ``0``, ``-2``, or ``100``
|
||||
- Float literals like ``0.0``, ``0.5``, ``-2.0``, or ``100.0``
|
||||
- Vector literals like ``(0.0, 0.0)``, ``(0.5, -0.5, 0.5)``, or ``(1.0, 2.0, 3.0, 4.0)``.
|
||||
|
||||
.. _doc_docs_writing_guidelines_class_properties_methods:
|
||||
|
||||
Classes, properties, and methods
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Link to classes the first time that you mention them in a page. After the first
|
||||
mention, use ``code style``. For common classes, like ``Node``, ``Control``, or
|
||||
``Viewport``, you can also use plaintext.
|
||||
|
||||
Link to class members (properties, methods, enums, and constants) the first time
|
||||
that you mention them in a page. After the first mention, use ``code style``. If
|
||||
the class member is very common, like a Node2D's ``position``, you don't have to
|
||||
link.
|
||||
|
||||
When discussing properties in the context of the inspector, use **bold style**
|
||||
instead.
|
||||
|
||||
.. _doc_docs_writing_guidelines_editor_ui:
|
||||
|
||||
Editor UI
|
||||
~~~~~~~~~
|
||||
|
||||
Use **bold style** for editor UI, including window titles, menus, buttons, input
|
||||
fields, inspector properties, and inspector sections. Use the exact
|
||||
capitalization that the editor uses.
|
||||
|
||||
- Open the **Editor Settings** window.
|
||||
- Press the **Confirm** button.
|
||||
- Change the node's **Transform > Position** property to ``(0, 0)``.
|
||||
- In the **Project Settings** window, enable the **Advanced Settings** toggle.
|
||||
|
||||
Use **Bold > With > Separators** when describing sequence of menus that the
|
||||
reader must navigate. Use ``>`` as a separator. You can omit ellipses in menu names.
|
||||
|
||||
- In **Project > Project Settings > Input Map**, add a new input action.
|
||||
- Select **Scene > Export As... > MeshLibrary...**.
|
||||
- Select **Scene > Export As > MeshLibrary**.
|
||||
|
||||
.. note:: Sometimes, ``->`` or ``→`` is used as a separator. This is nonstandard.
|
||||
Replace it with ``>`` if you are already making changes to a section.
|
||||
|
||||
.. _doc_docs_writing_guidelines_project_settings:
|
||||
|
||||
Project settings
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Link to individual project settings. Either include the section and subsection
|
||||
in the link itself, or include the section and subsection separately from the
|
||||
link. Since long links are not split into multiple lines when the page is
|
||||
rendered, prefer splitting the setting name and the section when the link is long.
|
||||
|
||||
- Set the :ref:`Application > Run > Max FPS<class_ProjectSettings_property_application/run/max_fps>` setting to ``60``.
|
||||
- In the project settings under **Application > Run**, set :ref:`Max FPS<class_ProjectSettings_property_application/run/max_fps>` to ``60``.
|
||||
- In **Project Settings > Application > Run**, set :ref:`Max FPS<class_ProjectSettings_property_application/run/max_fps>` to ``60``.
|
||||
|
||||
Code blocks and adominitions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Code blocks should use the ``::`` syntax on its own line. Do not use the short
|
||||
form where it's at the end of a paragraph, as the trailing ``::`` would be included
|
||||
in the localizable string otherwise. Weblate would show a warning due to the trailing ``::``,
|
||||
and if the localized string does not end with ``::``, it would break the code block entirely
|
||||
in the translated manual.
|
||||
|
||||
|
||||
**Bad:**
|
||||
|
||||
::
|
||||
|
||||
This is a code block::
|
||||
|
||||
The code block's contents.
|
||||
|
||||
**Good:**
|
||||
|
||||
::
|
||||
|
||||
This is a code block:
|
||||
|
||||
::
|
||||
|
||||
The code block's contents.
|
||||
|
||||
As for admonitions (note, warning, etc. blocks), you should write the admonition tag on its own line,
|
||||
then the admonition's contents indented by 4 spaces. Do not write the first line of the contents
|
||||
on the same line as the admonition tag.
|
||||
|
||||
**Bad:**
|
||||
|
||||
::
|
||||
|
||||
This is an admonition:
|
||||
|
||||
.. note:: First line of the note's contents.
|
||||
Second line of the note's contents.
|
||||
|
||||
**Good:**
|
||||
|
||||
::
|
||||
|
||||
This is an admonition:
|
||||
|
||||
.. note::
|
||||
|
||||
First line of the note's contents.
|
||||
Second line of the note's contents.
|
||||
|
||||
.. _doc_docs_writing_guidelines_manually_wrapping_lines:
|
||||
|
||||
Manually wrapping lines
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In the manual, lines must be manually wrapped to no more than 80-100 characters
|
||||
per line. However, links must not be split into multiple lines, and can exceed
|
||||
100 characters. Tables can also exceed 100 characters.
|
||||
|
||||
When making small changes, you don't need to manually re-wrap the whole paragraph,
|
||||
as long as the lines don't exceed 100 characters.
|
||||
|
||||
**Bad:** Line length exceeds 100 characters:
|
||||
|
||||
.. code-block::
|
||||
|
||||
The best thing to do is to wrap lines to under 80 characters per line. Wrapping to around 80-90 characters per line is also fine.
|
||||
If your lines exceed 100 characters, you definitely need to add a newline! Don't forget to remove trailing whitespace when you do.
|
||||
|
||||
**Good:** Lines are wrapped to 80-90 characters:
|
||||
|
||||
.. code-block::
|
||||
|
||||
The best thing to do is to wrap lines to under 80 characters per line. Wrapping to
|
||||
around 80-90 characters per line is also fine. If your lines exceed 100 characters, you
|
||||
definitely need to add a newline! Don't forget to remove trailing whitespace when you do.
|
||||
|
||||
**Best:** Lines are wrapped to under 80 characters:
|
||||
|
||||
.. code-block::
|
||||
|
||||
The best thing to do is to wrap lines to under 80 characters per line. Wrapping
|
||||
to around 80-90 characters per line is also fine. If your lines exceed 100
|
||||
characters, you definitely need to add a newline! Don't forget to remove
|
||||
trailing whitespace when you do.
|
||||
|
||||
.. tip:: In most text editors, you can add a vertical guide or "ruler" at 80
|
||||
characters. For example, in Visual Studio Code, you can add the following to
|
||||
your ``settings.json`` to add rulers at 80 and 100 characters:
|
||||
|
||||
.. code:: json
|
||||
|
||||
"editor.rulers": [80,100],
|
||||
|
||||
Section header syntax
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Use the following syntax for section headers:
|
||||
|
||||
.. code-block::
|
||||
|
||||
Page title
|
||||
==========
|
||||
|
||||
Renders as h1.
|
||||
Every page has this.
|
||||
|
||||
Section header
|
||||
--------------
|
||||
|
||||
Renders as h2.
|
||||
Usually appears in sidebar. Many pages only need one level of nested headers.
|
||||
|
||||
Sub-section header
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Renders as h3.
|
||||
Appears in sidebar in some pages, depending on how deeply nested the page is.
|
||||
|
||||
Sub-sub-section header
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Renders as h4.
|
||||
Usually won't appear in the sidebar.
|
||||
|
||||
Currently, there are no cases of deeper header nesting than this. Avoid
|
||||
introducing any deeper nesting.
|
||||
|
||||
Note that headers have no inherent meaning. In reStructuredText, headers are
|
||||
parsed based on the order that they initially appear within a page. Make sure
|
||||
that if you use an ``h3`` section header (``~~~``), you include an ``h2``
|
||||
sub-section header (``---``) first.
|
||||
|
||||
See the `Sphinx documentation <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections>`__
|
||||
and the `reStructuredText documentation <https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#sections>`__
|
||||
for more information.
|
||||
|
||||
.. _doc_docs_writing_guidelines_specific_version:
|
||||
|
||||
When to refer to a specific Godot version
|
||||
-----------------------------------------
|
||||
|
||||
Most of the time, the class reference and the manual should not specify the first
|
||||
version in which a feature is added. This is because the documentation describes
|
||||
the *current* features of the engine. Documentation will be read and maintained
|
||||
for many versions after it is initially written, and a reference to a first supported
|
||||
version is only relevant for a few versions after a feature is added. After that,
|
||||
it becomes historical trivia best left to a dedicated changelog.
|
||||
|
||||
Follow these guidelines for when to refer to a specific Godot version:
|
||||
|
||||
- If a feature was added in the current major version (4.x), **you can specify**
|
||||
the feature is new in 4.x.
|
||||
- If a feature or default approach to a problem was changed between major versions
|
||||
(3.x -> 4.x), describe the current feature in the main body of the page, and
|
||||
optionally add a brief sentence or note block to compare 3.x and 4.x.
|
||||
- If a large feature is added in a 4.x minor version, **you can specify** the minor
|
||||
version when it was added. Large features have a whole page or large section of
|
||||
documentation. In many cases it should still be avoided, since it's only relevant
|
||||
for the next few minor versions.
|
||||
- If a small feature is added in a 4.x minor version, **do not specify** the minor
|
||||
version when it was added. Small features have only a short section of
|
||||
documentation, or are minor additions to existing features.
|
||||
- If the default approach to a problem is changed in a 4.x minor version, **do
|
||||
specify** the minor version in which a new default approach was added. For example,
|
||||
the change from ``TileMap`` to ``TileMapLayer`` in 4.3.
|
||||
- If a feature was added in a 3.x major or minor version, **do not specify** when
|
||||
the feature was added. These features are old enough that the exact version
|
||||
in which they were added is not relevant.
|
||||
|
||||
Use roles for editor UI
|
||||
-----------------------
|
||||
|
||||
Much of the manual involves describing a sequence of UI actions in the editor,
|
||||
like clicking a button, opening a menu, or setting a property in the inspector.
|
||||
To keep formatting standardized, we use custom Sphinx roles for UI elements.
|
||||
|
||||
The following roles are defined:
|
||||
|
||||
- ``:button:`` A button, toggle, or other clickable UI element. If the reader
|
||||
is meant to click on it, and it's not a menu, use this. Renders as
|
||||
:button:`bold, with a background`.
|
||||
- ``:menu:`` A series of menus to click through. When listing a series of
|
||||
menus, separate them with ``>``. Renders as :menu:`bold, with a background`.
|
||||
- ``:inspector:`` A property *in the inspector*. When describing a property in
|
||||
*code*, instead either use ``code style`` or link to the property, as
|
||||
described earlier. Renders as :inspector:`bold`.
|
||||
- ``:ui:`` A role for any other editor UI elements. Use this if you would have
|
||||
otherwise just used **bold style**. Use this for input fields, docks, tabs,
|
||||
windows, bottom panels, etc. Also used for nested project settings or
|
||||
inspector sections. Renders as :ui:`bold`.
|
||||
|
||||
The first two roles, ``:button:`` and ``:menu:`` are used for editor UI that the
|
||||
reader is meant to click on, and they use an attention-grabbing visual style. The
|
||||
other roles, ``:inspector:`` and ``:ui:``, are used for other UI and show up
|
||||
often in text, so they just use bold text to be less distracting.
|
||||
|
||||
Our custom roles are inspired by the Sphinx `guilabel <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-guilabel>`_
|
||||
and `menuselection <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-menuselection>`_
|
||||
roles. However, we use our own implementation to better match the specific needs
|
||||
of Godot's documentation, using `custom RST roles <https://docutils.sourceforge.io/docs/ref/rst/directives.html#custom-interpreted-text-roles>`_
|
||||
and some custom CSS.
|
||||
|
||||
Examples
|
||||
~~~~~~~~
|
||||
|
||||
These are some example sections that use the roles, in context. Check the source
|
||||
of this page to see which roles are used.
|
||||
|
||||
Adding a sprite and setting some properties
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In the :ui:`Scene` dock, click :button:`2D Scene` to create a new scene.
|
||||
|
||||
Add a new :ref:`Sprite2D <class_Sprite2D>` to the scene by right-clicking on the
|
||||
root node and choosing :button:`Add Child Node...`. In the :ui:`Create New Node`
|
||||
window, search for "Sprite2D", select it, and then click :button:`Create`.
|
||||
|
||||
On the sprite, under :ui:`Offset`, set :inspector:`Offset` to ``(16, 32)``
|
||||
and enable :inspector:`Flip H`. Set :inspector:`Animation > HFrames` to ``10``.
|
||||
In :ui:`CanvasItem > Visibility`, set the :inspector:`Modulate` color to
|
||||
``ff0000``.
|
||||
|
||||
.. tip::
|
||||
|
||||
Don't forget to save your scene in :menu:`Scene > Save Scene...`. When the
|
||||
:ui:`Save Scene As...` window pops up, enter "my_scene.tscn" in the
|
||||
:ui:`File` field, then click :button:`Save`.
|
||||
|
||||
Setting project settings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Go to :menu:`Project > Project Settings`, then select the
|
||||
:ref:`Max FPS <class_ProjectSettings_property_application/run/max_fps>`
|
||||
setting under :ui:`Application > Run`. Don't forget to click the
|
||||
:button:`Advanced Settings` toggle. Then, in :ui:`Filter Settings`, search for
|
||||
"physics". Under :ui:`Physics > 3D > Solver`, set
|
||||
:inspector:`Solver Iterations` to ``16``.
|
||||
|
||||
All styles in context
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Use this section to see how the custom roles look, particularly within admonitions.
|
||||
|
||||
|styleroles|
|
||||
|
||||
.. note::
|
||||
|
||||
|styleroles|
|
||||
|
||||
.. warning::
|
||||
|
||||
|styleroles|
|
||||
|
||||
.. danger::
|
||||
|
||||
|styleroles|
|
||||
|
||||
.. tip::
|
||||
|
||||
|styleroles|
|
||||
|
||||
.. admonition:: Custom admonition
|
||||
|
||||
|styleroles|
|
||||
|
||||
.. All the inline roles which are used in the docs. External links don't work in a substitution.
|
||||
.. |styleroles| replace:: Built-in styles: ``code``, **bold**, and *italics*.
|
||||
Built-in roles: :kbd:`kbd`, :ref:`ref <doc_about_intro>`, :ref:`ref <class_node>`.
|
||||
Custom roles: :button:`button`, :menu:`menu > submenu`, :inspector:`inspector`, :ui:`ui`.
|
||||
18
documentation/guidelines/index.rst
Normal file
18
documentation/guidelines/index.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
:allow_comments: False
|
||||
|
||||
.. _doc_contributing_writing_documentation:
|
||||
|
||||
Guidelines
|
||||
==========
|
||||
|
||||
Here are the principles and guidelines we strive to follow to write accessible
|
||||
documentation.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:name: toc-contributing-writing-guidelines
|
||||
|
||||
content_guidelines
|
||||
docs_writing_guidelines
|
||||
docs_image_guidelines
|
||||
docs_contribution_checklist
|
||||
194
documentation/manual/building_the_manual.rst
Normal file
194
documentation/manual/building_the_manual.rst
Normal file
@@ -0,0 +1,194 @@
|
||||
.. _doc_building_the_manual:
|
||||
|
||||
Building the manual with Sphinx
|
||||
===============================
|
||||
|
||||
This page explains how to build a local copy of the Godot manual using the
|
||||
Sphinx docs engine. This allows you to have local HTML files and build the
|
||||
documentation as a PDF, EPUB, or LaTeX file, for example.
|
||||
|
||||
Before you get started, make sure that you have:
|
||||
|
||||
- `Git <https://git-scm.com/>`_
|
||||
- `make <https://www.gnu.org/software/make/>`_ (unless you're using Windows)
|
||||
- `Python <https://www.python.org/>`_ 3
|
||||
|
||||
.. note:: Python 3 should come with the ``pip3`` command. You may need to write
|
||||
``python3 -m pip`` (Unix) or ``py -m pip`` (Windows) instead of ``pip3``.
|
||||
If both approaches fail, `make sure that you have pip3 installed
|
||||
<https://pip.pypa.io/en/stable/installation/>`__.
|
||||
|
||||
1. *(Optional)* Set up a virtual environment. Virtual environments prevent
|
||||
potential conflicts between the Python packages in ``requirements.txt`` and
|
||||
other Python packages that are installed on your system.
|
||||
|
||||
a. Create the virtual environment:
|
||||
|
||||
.. tabs::
|
||||
|
||||
.. group-tab:: Windows
|
||||
|
||||
.. code:: pwsh
|
||||
|
||||
py -m venv godot-docs-venv
|
||||
|
||||
.. group-tab:: Other platforms
|
||||
|
||||
.. code:: sh
|
||||
|
||||
python3 -m venv godot-docs-venv
|
||||
|
||||
b. Activate the virtual environment:
|
||||
|
||||
.. tabs::
|
||||
|
||||
.. group-tab:: Windows
|
||||
|
||||
.. code:: pwsh
|
||||
|
||||
godot-docs-venv\Scripts\activate.bat
|
||||
|
||||
.. group-tab:: Other platforms
|
||||
|
||||
.. code:: sh
|
||||
|
||||
source godot-docs-venv/bin/activate
|
||||
|
||||
c. *(Optional)* Update pre-installed packages:
|
||||
|
||||
.. tabs::
|
||||
|
||||
.. group-tab:: Windows
|
||||
|
||||
.. code:: pwsh
|
||||
|
||||
py -m pip install --upgrade pip setuptools
|
||||
|
||||
.. group-tab:: Other platforms
|
||||
|
||||
.. code:: sh
|
||||
|
||||
pip3 install --upgrade pip setuptools
|
||||
|
||||
2. Clone the docs repo:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
git clone https://github.com/godotengine/godot-docs.git
|
||||
|
||||
3. Change directory into the docs repo:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
cd godot-docs
|
||||
|
||||
4. Install the required packages:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
5. Build the docs:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
make html
|
||||
|
||||
.. note::
|
||||
On Windows, that command will run ``make.bat`` instead of GNU Make (or an alternative).
|
||||
|
||||
Alternatively, you can build the documentation by running the sphinx-build program manually:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
sphinx-build -b html ./ _build/html
|
||||
|
||||
The compilation will take some time as the ``classes/`` folder contains hundreds of files.
|
||||
See :ref:`doc_building_the_manual:performance`.
|
||||
|
||||
You can then browse the documentation by opening ``_build/html/index.html`` in
|
||||
your web browser.
|
||||
|
||||
Dealing with errors
|
||||
-------------------
|
||||
|
||||
If you run into errors, you may try the following command:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
make SPHINXBUILD=~/.local/bin/sphinx-build html
|
||||
|
||||
If you get a ``MemoryError`` or ``EOFError``, you can remove the ``classes/`` folder and
|
||||
run ``make`` again.
|
||||
This will drop the class references from the final HTML documentation, but will keep the
|
||||
rest intact.
|
||||
|
||||
.. important::
|
||||
If you delete the ``classes/`` folder, do not use ``git add .`` when working on a pull
|
||||
request or the whole ``classes/`` folder will be removed when you commit.
|
||||
See `#3157 <https://github.com/godotengine/godot-docs/issues/3157>`__ for more detail.
|
||||
|
||||
.. _doc_building_the_manual:performance:
|
||||
|
||||
Hints for performance
|
||||
---------------------
|
||||
|
||||
RAM usage
|
||||
~~~~~~~~~
|
||||
|
||||
Building the documentation requires at least 8 GB of RAM to run without disk swapping,
|
||||
which slows it down.
|
||||
If you have at least 16 GB of RAM, you can speed up compilation by running:
|
||||
|
||||
.. tabs::
|
||||
|
||||
.. group-tab:: Windows
|
||||
|
||||
.. code:: pwsh
|
||||
|
||||
set SPHINXOPTS=-j2 && make html
|
||||
|
||||
.. group-tab:: Other platforms
|
||||
|
||||
.. code:: sh
|
||||
|
||||
make html SPHINXOPTS=-j2
|
||||
|
||||
You can use ``-j auto`` to use all available CPU threads, but this can use a lot
|
||||
of RAM if you have a lot of CPU threads. For instance, on a system with 32 CPU
|
||||
threads, ``-j auto`` (which corresponds to ``-j 32`` here) can require 20+ GB of
|
||||
RAM for Sphinx alone.
|
||||
|
||||
Specifying a list of files
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. warning::
|
||||
|
||||
This section will not work on Windows, since the repository is using
|
||||
a simplified ``make.bat`` script instead of the real GNU Make program.
|
||||
If you would like to get a Linux terminal on your system, consider using
|
||||
`Windows Subsystem for Linux (WSL) <https://learn.microsoft.com/en-us/windows/wsl/>`__.
|
||||
|
||||
You can specify a list of files to build, which can greatly speed up compilation:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
make html FILELIST='classes/class_node.rst classes/class_resource.rst'
|
||||
|
||||
The list of files can also be provided by the ``git`` command.
|
||||
This way you can automatically get the names of all files that have changed since
|
||||
the last commit (``sed`` is used to put them on the same line).
|
||||
|
||||
.. code:: sh
|
||||
|
||||
make html FILELIST="$(git diff HEAD --name-only | sed -z 's/\n/ /g')"
|
||||
|
||||
You can replace ``HEAD`` with ``master`` to return all files changed from the
|
||||
``master`` branch:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
make html FILELIST="$(git diff master --name-only | sed -z 's/\n/ /g')"
|
||||
|
||||
If any images were modified, the output will contain some warnings about them,
|
||||
but the build will proceed correctly.
|
||||
@@ -1,7 +1,7 @@
|
||||
.. _doc_contributing_to_the_documentation:
|
||||
|
||||
Contributing to the documentation
|
||||
=================================
|
||||
Writing the manual
|
||||
==================
|
||||
|
||||
This guide explains how to contribute to Godot's documentation, be it by
|
||||
writing or reviewing pages.
|
||||
16
documentation/manual/index.rst
Normal file
16
documentation/manual/index.rst
Normal file
@@ -0,0 +1,16 @@
|
||||
:allow_comments: False
|
||||
|
||||
.. _doc_contributing_writing_documentation:
|
||||
|
||||
Contributing to the manual
|
||||
==========================
|
||||
|
||||
These articles explain how to contribute to this very documentation, and
|
||||
how to build the online version locally for testing.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:name: toc-contributing-documentation
|
||||
|
||||
contributing_to_the_documentation
|
||||
building_the_manual
|
||||
@@ -1,6 +1,13 @@
|
||||
Overview
|
||||
========
|
||||
|
||||
We always need help to improve the documentation, be it the class reference or
|
||||
the manual. Below, you can find our content and writing guidelines and
|
||||
concrete guides to make changes to the documentation.
|
||||
|
||||
Be sure to also check the :ref:`workflow guidelines <doc_contributing_workflow>`,
|
||||
especially if you're new to using Git or GitHub.
|
||||
|
||||
There are two separate resources referred to as "documentation" in Godot:
|
||||
|
||||
- **The class reference.** This is the documentation for the complete Godot API
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.. _doc_editor_and_docs_localization:
|
||||
|
||||
Contributing translations
|
||||
Contributing Translations
|
||||
=========================
|
||||
|
||||
.. highlight:: none
|
||||
@@ -27,9 +27,10 @@ TODO
|
||||
:name: sec-engine
|
||||
|
||||
documentation/overview
|
||||
documentation/class_reference
|
||||
documentation/documentation
|
||||
documentation/translation
|
||||
documentation/guidelines/index
|
||||
documentation/class_reference/index
|
||||
documentation/manual/index
|
||||
documentation/translation/index
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
Reference in New Issue
Block a user