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...
문서의 구조
GDScript에서는 주석을 사용하여 코드를 문서화하고 스크립트 멤버에 설명을 추가할 수 있습니다. 일반 주석과 문서 주석에는 두 가지 차이점이 있습니다. 첫째, 문서 주석은 이중 해시 기호 ``##``로 시작해야 합니다. 둘째, 스크립트 멤버 바로 앞에 배치되어야 하며, 스크립트 설명의 경우 스크립트 맨 위에 배치되어야 합니다. 내보낸 변수가 문서화되면 해당 설명이 편집기에서 도구 설명으로 사용됩니다. 이 문서는 편집기를 통해 XML 파일로 생성될 수 있습니다.
스크립트 실행하기
스크립트를 문서화하는 의견은 회원 문서 앞에 와야 합니다. 스크립트 문서에 권장되는 형식은 세 부분으로 나눌 수 있습니다.
스크립트에 대한 간략한 설명입니다.
설명
튜토리얼 및 더 이상 사용되지 않는/실험적 표시.
이를 서로 분리하기 위해 문서 주석에는 특수 태그를 사용합니다. 태그는 행의 시작 부분에 있어야 하며(이전 공백 무시) @ 형식이어야 하며 그 뒤에 키워드가 와야 합니다.
스크립트 템플릿 만들기
문서화에 해당되는 멤버:
시그널
열거형
열거형 값
제약
변수
함수
내부 클래스
스크립트 멤버의 문서는 멤버 또는 해당 주석(있는 경우) 바로 앞에 있어야 합니다. 설명은 두 줄 이상일 수 있지만 모든 줄은 문서의 일부로 간주되도록 이중 해시 기호 ``##``로 시작해야 합니다.
태그
설명 |
태그가 없습니다. |
사용되지 않음 |
@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
BBCode와 클래스 참조
Godot의 클래스 참조는 BBCode와 유사한 태그를 지원합니다. 문서에도 사용할 수 있는 멋진 서식을 텍스트에 추가합니다. class 참조 bbcode <doc_class_reference_bbcode>`도 참조하세요. 이는 ``RichTextLabel` :ref:`BBCode <doc_bbcode_in_richtextlabel>`과 약간 다릅니다.
다른 클래스의 멤버에 연결할 때마다 클래스 이름을 지정해야 합니다. 동일한 클래스에 대한 링크의 경우 클래스 이름은 선택 사항이며 생략할 수 있습니다.
6 가지 패턴 유형이 있습니다:
설명 |
예제 |
결과 |
|---|---|---|
클래스
라이선스에 대한 링크
|
Sprite |
Sprite |
[annotation Class.name]벡터 연산
|
|
Sprite |
[constant Class.name]상수를 정의합니다.
|
|
|
[enum Class.name]라이선스에 대한 링크
|
|
:ref:`Mesh.ArrayType <enum_Mesh_ArrayType>`을 참조하세요. |
[member Class.name]멤버 편집
|
|
|
메서드
메서드 호출하기
|
|
Sprite |
메서드
내장 생성자로 연결
|
|
|
메서드
벡터 내장 타입
|
|
|
[signal Class.name]바인딩 시그널
|
|
|
[theme_item Class.name]라이선스에 대한 링크
|
|
:ref:`Label.font <class_Label_theme_font_font>`을 참조하세요. |
[param name]매개변수 이름(코드로)
|
|
크기는 ``size``를 사용합니다. |
[br]break
|
Line 1.[br]Line 2. |
1호선.
2호선.
|
<< >>각각
[ 및 ] |
|
[b]텍스트[/b] |
<< >>굵게
|
|
Do not call this method. |
<< >>기울임
|
|
전역 위치를 반환합니다. |
<< >>밑줄
|
|
Always use this method. |
<< >>취소선
|
|
|
<< >>색상
|
|
Error! |
<< >>글꼴
|
|
LICENSE |
<< >>이미지
|
|
|
<< >>하이퍼링크
|
[url]https://example.com[/url][url=https://example.com]Website[/url] |
|
<< >>가로 센터링
|
|
|
[kbd] [/kbd]키보드 단축키
|
|
Ctrl + O |
[code] [/code]인라인 코드 조각
|
|
반환 |
[codeblock][/codeblock]여러 줄 코드 블록
|
아래를 참조하세요. |
아래를 참조하세요. |
참고
현재는 :ref:`class_@GDScript`에만 주석이 있습니다.
[kbd]disables BBCode until the parser encounters[/kbd].[code]disables BBCode until the parser encounters[/code].[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 속성을 사용하여 변경할 수 있습니다. 현재 지원되는 옵션은 다음과 같습니다.