Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
为类参考手册贡献¶
The Class reference is a set of articles describing the public API of the engine. This includes descriptions for various classes, methods, properties, and global objects, available for scripting. The class reference is available online, from the documentation sidebar, and in the Godot editor, from the help menu.
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 encouraged to document all of their work in the class reference when submitting a pull request, we can't expect everyone to be able to write high quality documentation, so there is always work for contributors like you to polish existing and create missing reference material.
The source of the class reference¶
As the class reference is available in two places, online and in the editor, we need to take care to keep things in sync. To achieve this the main Godot repository is picked as the source of truth, and the documentation for the class reference is tracked there.
警告
You should not edit .rst
files in the classes/
folder of the
documentation repository.
These files are generated automatically and are synced manually by project
maintainers. Read further to learn how to correctly edit the class reference.
In the main repository the class reference is stored in XML files, one for each exposed
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/<module_name>/doc_classes/
directory. To learn more about editing XML files refer to Class reference primer.
参见
至于 Git 用法及拉取请求工作流程的详细信息,请参阅 拉取请求工作流程 页面。
If you want to translate the class reference from English to another language, see Editor and documentation localization. This guide is also available as a video tutorial on YouTube.
重要:如果你准备进行大量修改,就应该在 godot-docs 仓库中创建 Issue,或者在已有 Issue 上发表评论。这样别人就会知道你准备处理某个类了。
What to contribute¶
The natural place to start contributing is the classes that you are most familiar with. This ensures that the added description will be based on experience and the necessary know-how, not just the name of a method or a property. We advise not to add low effort descriptions, no matter how appealing it may look. Such descriptions obscure the need for documentation and are hard to identify automatically.
参见
Following this principle is important and allows us to create tools for contributors. Such as the class reference's completion status tracker. You can use it to quickly find documentation pages missing descriptions.
If you decide to document a class, but don't know what a particular method does, don't worry. Leave it for now, and list the methods you skipped when you open a pull request with your changes. Another writer will take care of it.
You can still look at the methods' implementation in Godot's source code on GitHub. If you have doubts, feel free to ask on the Q&A website and Godot Contributors Chat.
警告
Unless you make minor changes, like fixing a typo, we do not recommend using the GitHub web editor to edit the class reference's XML files. It lacks features to edit XML well, like keeping indentations consistent, and it does not allow amending commits based on reviews.
It also doesn't allow you to test your changes in the engine or with validation scripts as described in 如何编辑类 XML.
Updating class reference when working on the engine¶
When you create a new class or modify an existing engine's API, you need to re-generate
the XML files in doc/classes/
.
To do so, you first need to compile Godot. See the 构建系统介绍
page to learn how. Then, execute the compiled Godot binary from the Godot root directory
with the --doctool
option. For example, if you're on 64-bit Linux, the command might be:
./bin/godot.linuxbsd.editor.x86_64 --doctool
The exact set of suffixes may be different. Carefully read through the linked article to learn more about that.
The XML files in doc/classes/
should then be up-to-date with current Godot Engine
features. You can then check what changed using the git diff
command.
Please only include changes that are relevant to your work on the API in your commits.
You can discard changes in other XML files using git checkout
, but consider reporting
if you notice unrelated files being updated. Ideally, running this command should only
bring up the changes that you yourself have made.