.. _doc_docs_writing_guidelines: Docs 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 `content guidelines 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] 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: :: onready var a = preload("res://MyPath") onready var my_node = $MyNode func foo(): # Do stuff **Do** write concrete examples: :: 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]`. 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 `KinematicBody2D class`. And individual lines with key-value pairs are `properties`. E.g. `position` or `modulate color` are both `properties`. 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. On macOS, `Cmd` often replaces `Ctrl` in keyboard shortcuts. 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:`Cmd + Alt + 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. Image contribution guidelines ----------------------------- A significant part of the documentation is images, and there are several important guidelines to follow. First, you should always be using the default editor theme and text when taking screenshots. To improve the appearance of 3D screenshots, use 4× MSAA, enable anisotropic filtering on the project's textures, and set the anisotropic filter quality to 16× in Project Settings. Screenshot sizes should not exceed 1920×1080 to ensure fast loading on slower connections. When you need to highlight an area of the editor to show something, like a button or option, use a 2 pixel-thick yellow outline without a bevel. If the outline is on a dark background, the outline should be yellow so it can be easily seen by colorblind people. Please do not use red as it won't be visible for some users. Before you add or replace any images in the documentation, they should be run through a PNG compressor to save size. You can use the lossless OxiPNG compressor included in `Squoosh ( https://squoosh.app/ )` for this purpose. For heavier images, consider using a lossy compressor like `pngquant ( https://pngquant.org/ )`_. With it, almost no image quality is lost during compression. .. note:: The program pngquant must be installed locally as it's not available in Squoosh.