From 766e4687e5c47f40aaa94703331146e8e2211d23 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 2 Jan 2020 17:20:33 -0500 Subject: [PATCH] Add file formatting to GDScript style guide Recommend LF, newline at end of file, UTF-8, no BOM, and tabs. The displayed size of tabs does not matter as it does not affect the saved files, so don't mention it. Also slightly change the C# style guide for consistency. --- .../scripting/c_sharp/c_sharp_style_guide.rst | 8 ++++++-- .../scripting/gdscript/gdscript_styleguide.rst | 17 +++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/getting_started/scripting/c_sharp/c_sharp_style_guide.rst b/getting_started/scripting/c_sharp/c_sharp_style_guide.rst index 379fbc977..b864d04f6 100644 --- a/getting_started/scripting/c_sharp/c_sharp_style_guide.rst +++ b/getting_started/scripting/c_sharp/c_sharp_style_guide.rst @@ -31,12 +31,16 @@ Formatting conventions ---------------------- * Use line feed (**LF**) characters to break lines, not CRLF or CR. +* Use one line feed character at the end of each file, except for `csproj` files. * Use **UTF-8** encoding without a `byte order mark `_. * Use **4 spaces** instead of tabs for indentation (which is referred to as "soft tabs"). * Consider breaking a line into several if it's longer than 100 characters. +Code structure +-------------- + Line breaks and blank lines ---------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~ For a general indentation rule, follow `the "Allman Style" `_ which recommends placing the brace associated with a control statement on the next line, indented to @@ -133,7 +137,7 @@ Avoid inserting a blank line: } Using spaces ------------- +~~~~~~~~~~~~ Insert a space: diff --git a/getting_started/scripting/gdscript/gdscript_styleguide.rst b/getting_started/scripting/gdscript/gdscript_styleguide.rst index 417429a35..252d13da0 100644 --- a/getting_started/scripting/gdscript/gdscript_styleguide.rst +++ b/getting_started/scripting/gdscript/gdscript_styleguide.rst @@ -18,18 +18,19 @@ styleguide. .. note:: Godot's built-in script editor uses a lot of these conventions by default. Let it help you. -Code structure --------------- +Formatting conventions +---------------------- -Indentation -~~~~~~~~~~~ - -Indent type: Tabs *(editor default)* - -Indent size: 4 *(editor default)* +* Use line feed (**LF**) characters to break lines, not CRLF or CR. *(editor default)* +* Use one line feed character at the end of each file. *(editor default)* +* Use **UTF-8** encoding without a `byte order mark `_. *(editor default)* +* Use **Tabs** instead of spaces for indentation. *(editor default)* Each indent level should be one greater than the block containing it. +Code structure +-------------- + **Good**: ::