xref: /Universal-ctags/man/ctags-lang-gdscript.7.rst.in (revision d0c0924987971a1f9d254812183bf8090fdde620)
1.. _ctags-lang-gdscript(7):
2
3==============================================================
4ctags-lang-gdscript
5==============================================================
6--------------------------------------------------------------------
7Random notes about tagging GDScript source code with Universal Ctags
8--------------------------------------------------------------------
9:Version: @VERSION@
10:Manual group: Universal Ctags
11:Manual section: 7
12
13SYNOPSIS
14--------
15|	**@CTAGS_NAME_EXECUTABLE@** ... --languages=+GDScript ...
16|	**@CTAGS_NAME_EXECUTABLE@** ... --language-force=GDScript ...
17|	**@CTAGS_NAME_EXECUTABLE@** ... --map-GDScript=+.gd ...
18
19DESCRIPTION
20-----------
21This man page gathers random notes about tagging GDScript source code
22with Universal Ctags.
23
24Storing Annotations
25-------------------
26Like the Python parser storing decorations to ``decorations`` field,
27the GDScript parser stores annotations
28starting from `@` to the language specific field, ``annotations``.
29Though the field is enabled explicitly in following examples, the
30field is enabled by default.
31
32"input.gd"
33
34.. code-block:: GDScript
35
36	@export
37	var s = "Hello"
38
39	@master
40	func f(msg):
41		print(msg)
42
43"output.tags"
44with "--options=NONE --sort=no --fields-GDScript=+{annotations} -o - input.gd"
45
46.. code-block:: tags
47
48	s	input.gd	/^var s = "Hello"$/;"	v	annotations:export
49	f	input.gd	/^func f(msg):$/;"	m	annotations:master
50
51Extracting `func`
52-----------------
53A language object defined with `func` keyword is tagged with ``method`` kind.
54Like annotations, the parser stores keywords modifying `func` like `static` to
55the ``annotations`` field.
56
57"input.gd"
58
59.. code-block:: GDScript
60
61	func f(x):
62		return x
63
64	static func f_s(x):
65		reutrn x
66
67	remote func f_r(x):
68		return x
69
70
71"output.tags"
72with "--options=NONE --sort=no --fields=+K --fields-GDScript=+{annotations} -o - input.gd"
73
74.. code-block:: tags
75
76	f	input.gd	/^func f(x):$/;"	method
77	f_s	input.gd	/^static func f_s(x):$/;"	method	annotations:static
78	f_r	input.gd	/^remote func f_r(x):$/;"	method	annotations:remote
79
80Tagging implicitly defined classes
81----------------------------------
82"A file is a class!" in GDScript.  A class is implicitly
83defined. Functions, variables, constants, and signals are parts of the
84class though the class is unnamed by default.
85
86If the language specific extra, ``implicitClass``, is enabled, the
87parser makes a anonymous tag for the class. The parser fills the scope
88fields of the tags for all language objects defined in the file with
89the anonymous tag.
90
91Let's see an example demonstrating the effect of the extra.
92
93Turning off the extra:
94
95"input.gd"
96
97.. code-block:: GDScript
98
99	func f(x):
100		return x
101
102"output.tags"
103with "--options=NONE --fields=+KZ --extras-GDScript=-{implicitClass} -o - input.gd"
104
105.. code-block:: tags
106
107	f	input.gd	/^func f(x):$/;"	method
108
109Turning on the extra:
110
111"input.gd"
112
113.. code-block:: GDScript
114
115	func g(x):
116		return x
117
118"output.tags"
119with "--options=NONE --fields=+KZ --extras-GDScript=+{implicitClass} -o - input.gd"
120
121.. code-block:: tags
122
123	anon_class_84011bee0100	input.gd	/^func g(x):$/;"	class
124	g	input.gd	/^func g(x):$/;"	method	scope:class:anon_class_84011bee0100
125
126Tagging the name specified with `class_name`
127---------------------------------------------
128`class_name` is a keyword for giving a name to the implicitly defined
129class.  If ``implicitClass`` is turned off, the parser just extract
130the name coming after the keyword with ``class`` kind. If
131``implicitClass`` is turned on, the parser converts the anonymous tag
132to a non-anonymous tag with the specified name.  When converting,
133the parser also updates scope fields of the other tags in the file.
134
135Turning off the extra:
136
137"input.gd"
138
139.. code-block:: GDScript
140
141	class_name c
142
143	func f(x):
144		return x
145
146"output.tags"
147with "--options=NONE --fields=+KZ --extras-GDScript=-{implicitClass} -o - input.gd"
148
149.. code-block:: tags
150
151	c	input.gd	/^class_name c$/;"	class
152	f	input.gd	/^func f(x):$/;"	method
153
154Turning on the extra:
155
156"input.gd"
157
158.. code-block:: GDScript
159
160	class_name C
161	func g(x):
162		return x
163
164"output.tags"
165with "--options=NONE --fields=+KZ --extras-GDScript=+{implicitClass} -o - input.gd"
166
167.. code-block:: tags
168
169	C	input.gd	/^class_name C$/;"	class
170	g	input.gd	/^func g(x):$/;"	method	scope:class:C
171
172Filling ``inherits`` field
173--------------------------
174`extends` keyword specifies the super class for the implicitly defined class.
175If `implicitClass` extra is turned on, the parser fills ``inherits`` field
176of the tag for the implicitly defined class with the name of super class.
177
178"input.gd"
179
180.. code-block:: GDScript
181
182	extends B
183	class_name C
184
185"output.tags"
186with "--options=NONE --fields=+Ki --extras-GDScript=+{implicitClass} -o - input.gd"
187
188.. code-block:: tags
189
190	C	input.gd	/^class_name C$/;"	class	inherits:B
191
192When `--extras=+r` is given, the parser extracts the class specified with the
193`extends` keyword as a referece tag of ``class`` kind with ``extended`` role.
194
195"input.gd"
196
197.. code-block:: GDScript
198
199	extends B
200
201"output.tags"
202with "--options=NONE --fields=+rEK --extras=+r -o - input.gd"
203
204.. code-block:: tags
205
206	B	input.gd	/^extends B$/;"	class	roles:extended	extras:reference
207
208SEE ALSO
209--------
210ctags(1)
211