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.

문서의 구조

GDScript에서는 주석을 사용하여 코드를 문서화하고 스크립트 멤버에 설명을 추가할 수 있습니다. 일반 주석과 문서 주석에는 두 가지 차이점이 있습니다. 첫째, 문서 주석은 이중 해시 기호 ``##``로 시작해야 합니다. 둘째, 스크립트 멤버 바로 앞에 배치되어야 하며, 스크립트 설명의 경우 스크립트 맨 위에 배치되어야 합니다. 내보낸 변수가 문서화되면 해당 설명이 편집기에서 도구 설명으로 사용됩니다. 이 문서는 편집기를 통해 XML 파일로 생성될 수 있습니다.

스크립트 실행하기

스크립트를 문서화하는 의견은 회원 문서 앞에 와야 합니다. 스크립트 문서에 권장되는 형식은 세 부분으로 나눌 수 있습니다.

  • 스크립트에 대한 간략한 설명입니다.

  • 설명

  • 튜토리얼 및 더 이상 사용되지 않는/실험적 표시.

이를 서로 분리하기 위해 문서 주석에는 특수 태그를 사용합니다. 태그는 행의 시작 부분에 있어야 하며(이전 공백 무시) @ 형식이어야 하며 그 뒤에 키워드가 와야 합니다.

태그

간략한 설명

태그가 없습니다. 문서 섹션의 시작 부분에 있습니다.

설명

태그가 없습니다. 설명과 요약을 구분하려면 빈 줄 하나를 사용하세요.

튜토리얼

@tutorial: https://example.com
@tutorial(제목은 여기에): https://example.com

사용되지 않음

@deprecated
@deprecated: 대신 [AnotherClass]를 사용하세요.

실험적

@experimental
@experimental: 클래스는 불안정합니다.

예를 들면:

extends Node2D
## A brief description of the class's role and functionality.
##
## The description of the script, what it can do,
## and any further detail.
##
## @tutorial:             https://example.com/tutorial_1
## @tutorial(Tutorial 2): https://example.com/tutorial_2
## @experimental

경고

태그 이름과 콜론 사이에 공백이 있으면(예: @tutorial  :) 유효한 태그로 처리되지 않고 무시됩니다.

참고

설명이 여러 줄에 걸쳐 있으면 앞과 뒤의 공백이 제거되어 단일 공백으로 결합됩니다. 줄바꿈을 유지하려면 ``[br]``를 사용하세요. 아래 `BBCode and class reference`_도 참조하세요.

스크립트 템플릿 만들기

문서화에 해당되는 멤버:

  • 시그널

  • 열거형

  • 열거형 값

  • 제약

  • 변수

  • 함수

  • 내부 클래스

스크립트 멤버의 문서는 멤버 또는 해당 주석(있는 경우) 바로 앞에 있어야 합니다. 설명은 두 줄 이상일 수 있지만 모든 줄은 문서의 일부로 간주되도록 이중 해시 기호 ``##``로 시작해야 합니다.

태그

설명

태그가 없습니다.

사용되지 않음

@deprecated
@deprecated: 대신 [member another]를 사용하세요.

실험적

@experimental
@experimental: 메서드는 불완전합니다.

예를 들면:

## The description of the variable.
## @deprecated: Use [member other_var] instead.
var my_var

한 줄 case 명령문에서 콜론 이후.

signal my_signal ## My signal.

enum MyEnum { ## My enum.
    VALUE_A = 0, ## Value A.
    VALUE_B = 1, ## Value B.
}

const MY_CONST = 1 ## My constant.

var my_var ## My variable.


func my_func(): ## My func.
    pass


class MyClass: ## My class.
    pass

스크립트 문서는 스크립트가 업데이트될 때마다 편집기 도움말 창에서 업데이트됩니다. 멤버 변수나 함수 이름이 밑줄로 시작하면 비공개로 처리됩니다. 문서에는 나타나지 않으며 도움말 창에서는 무시됩니다.

완전한 스크립트 예제

extends Node2D
## A brief description of the class's role and functionality.
##
## The description of the script, what it can do,
## and any further detail.
##
## @tutorial:             https://example.com/tutorial_1
## @tutorial(Tutorial 2): https://example.com/tutorial_2
## @experimental

## The description of a signal.
signal my_signal

## This is a description of the below enum.
enum Direction {
    ## Direction up.
    UP = 0,
    ## Direction down.
    DOWN = 1,
    ## Direction left.
    LEFT = 2,
    ## Direction right.
    RIGHT = 3,
}

## The description of a constant.
const GRAVITY = 9.8

## The description of the variable v1.
var v1

## This is a multiline description of the variable v2.[br]
## The type information below will be extracted for the documentation.
var v2: int

## If the member has any annotation, the annotation should
## immediately precede it.
@export
var v3 := some_func()


## As the following function is documented, even though its name starts with
## an underscore, it will appear in the help window.
func _fn(p1: int, p2: String) -> int:
    return 0


# The below function isn't documented and its name starts with an underscore
# so it will treated as private and will not be shown in the help window.
func _internal() -> void:
    pass


## Documenting an inner class.
##
## The same rules apply here. The documentation must
## immediately precede the class definition.
##
## @tutorial: https://example.com/tutorial
## @experimental
class Inner:

    ## Inner class variable v4.
    var v4


    ## Inner class function fn.
    func fn(): pass

@deprecated@experimental 태그

클래스 또는 해당 멤버를 더 이상 사용되지 않거나 실험적인 것으로 표시할 수 있습니다. 그러면 내장 문서 뷰어에 해당 표시기가 추가됩니다. 선택적으로 API가 권장되지 않는 이유를 설명하는 짧은 메시지를 제공할 수 있습니다. 이는 플러그인 및 라이브러리 제작자에게 특히 유용할 수 있습니다.

../../../_images/deprecated_and_experimental_tags.webp
  • **더 이상 사용되지 않음**은 향후 주요 릴리스에서 제거되거나 호환되지 않는 변경이 발생할 수 있는 권장되지 않는 API를 표시합니다. 일반적으로 API는 이전 버전과의 호환성을 위해 유지됩니다.

  • **실험적**은 현재 주요 분기에서 변경되거나 제거될 수 있는 불안정한 새로운 API를 나타냅니다. 프로덕션 코드에서는 이 API를 사용하지 않는 것이 좋습니다.

참고

기술적으로 동일한 클래스/멤버에 @deprecated@experimental 태그를 모두 사용할 수 있지만 이는 일반적인 규칙에 위배되므로 권장되지 않습니다.

BBCode와 클래스 참조

Godot의 클래스 참조는 BBCode와 유사한 태그를 지원합니다. 문서에도 사용할 수 있는 멋진 서식을 텍스트에 추가합니다. class 참조 bbcode <doc_class_reference_bbcode>`도 참조하세요. 이는 ``RichTextLabel` :ref:`BBCode <doc_bbcode_in_richtextlabel>`과 약간 다릅니다.

다른 클래스의 멤버에 연결할 때마다 클래스 이름을 지정해야 합니다. 동일한 클래스에 대한 링크의 경우 클래스 이름은 선택 사항이며 생략할 수 있습니다.

6 가지 패턴 유형이 있습니다:

설명

예제

결과

클래스
라이선스에 대한 링크

Sprite

Sprite

[annotation Class.name]
벡터 연산

See [annotation @GDScript.@rpc].

Sprite

[constant Class.name]
상수를 정의합니다.

See [constant Color.RED].

Color

[enum Class.name]
라이선스에 대한 링크

See [enum Mesh.ArrayType].

:ref:`Mesh.ArrayType <enum_Mesh_ArrayType>`을 참조하세요.

[member Class.name]
멤버 편집

Get [member Node2D.scale].

NodePath

메서드
메서드 호출하기

Call [method Node3D.hide].

Sprite

메서드
내장 생성자로 연결

Use [constructor Color.Color].

Color

메서드
벡터 내장 타입

Use [operator Color.operator *].

Color

[signal Class.name]
바인딩 시그널

Emit [signal Node.renamed].

NodePath

[theme_item Class.name]
라이선스에 대한 링크

See [theme_item Label.font].

:ref:`Label.font <class_Label_theme_font_font>`을 참조하세요.

[param name]
매개변수 이름(코드로)

Takes [param size] for the size.

크기는 ``size``를 사용합니다.

[br]
break
Line 1.[br]
Line 2.
1호선.
2호선.
<< >>
각각 []

[lb]b[rb]text[lb]/b[rb]

[b]텍스트[/b]

<< >>
굵게

Do [b]not[/b] call this method.

Do not call this method.

<< >>
기울임

Returns the [i]global[/i] position.

전역 위치를 반환합니다.

<< >>
밑줄

[u]Always[/u] use this method.

Always use this method.
<< >>
취소선

[s]Outdated information.[/s]

Outdated information.
<< >>
색상

[color=red]Error![/color]

Error!
<< >>
글꼴

[font=res://mono.ttf]LICENSE[/font]

LICENSE
<< >>
이미지

[img width=32]res://icon.svg[/img]

../../../_images/icon.svg
<< >>
하이퍼링크
[url]https://example.com[/url]
[url=https://example.com]Website[/url]
<< >>
가로 센터링

[center]2 + 2 = 4[/center]

2 + 2 = 4
[kbd] [/kbd]
키보드 단축키

Press [kbd]Ctrl + C[/kbd].

Ctrl + O

[code] [/code]
인라인 코드 조각

Returns [code]true[/code].

반환

[codeblock]
[/codeblock]
여러 줄 코드 블록

아래를 참조하세요.

아래를 참조하세요.

참고

  1. 현재는 :ref:`class_@GDScript`에만 주석이 있습니다.

  2. [kbd] disables BBCode until the parser encounters [/kbd].

  3. [code] disables BBCode until the parser encounters [/code].

  4. [codeblock] disables BBCode until the parser encounters [/codeblock].

경고

사전 형식화된 코드 블록에는 [codeblock]``를 사용하세요. ``[codeblock] 내에서는 들여쓰기를 위해 항상 **네 개의 공백**을 사용합니다(파서는 탭을 삭제합니다).

## Do something for this plugin. Before using the method
## you first have to [method initialize] [MyPlugin].[br]
## [color=yellow]Warning:[/color] Always [method clean] after use.[br]
## Usage:
## [codeblock]
## func _ready():
##     the_plugin.initialize()
##     the_plugin.do_something()
##     the_plugin.clean()
## [/codeblock]
func do_something():
    pass

기본적으로 [codeblock]``는 GDScript 구문을 강조 표시합니다. ``lang 속성을 사용하여 변경할 수 있습니다. 현재 지원되는 옵션은 다음과 같습니다.

  • ``[codeblock lang=text]``는 구문 강조 표시를 비활성화합니다.

  • ``[codeblock lang=gdscript]``는 GDScript 구문을 강조합니다.

  • ``[codeblock lang=csharp]``는 C# 구문을 강조 표시합니다(.NET 버전에만 해당).