-
Notifications
You must be signed in to change notification settings - Fork 11
Update to Godot 4 and highlight.js 11 #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Please do the "upgrade" work in an isolated commit (that doesn't move the file around) so I can properly review the changes. |
Note that I couldn't get the ES module build to work in the browser, so maybe we should remove it.
2ab771b
to
1851cfa
Compare
Done (it turns out we don't need to move any files after rebasing on |
{ | ||
className: "comment", | ||
className: 'string', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context, GDScript does not actually have multiline comments, but only multiline strings. Multiline strings on their own line are standalone expressions, so they have no effect if you use them as comments.
The style guide recommends using ##
for documentation comments, as this makes them display in the inspector when hovering the property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall.
Regarding my comments to document the source of the lists of keywords/built-ins, if it's not suitable to include in gdscript.js
as comments, maybe this could go in a README.
'StringName NodePath Dictionary Array PackedByteArray ' + | ||
'PackedInt32Array PackedInt64Array PackedFloat32Array ' + | ||
'PackedFloat64Array PackedStringArray PackedVector2Array ' + | ||
'PackedVector3Array PackedColorArray PackedVector4Array Variant ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we lost the Godot 3 Pool*Array
s here.
'Vector3 Vector3i Vector4 Vector4i Plane AABB Quaternion Basis ' + | ||
'Transform3D Projection Color RID Object Callable Signal ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also include the old Godot 3 math types?
Rect3 Quat Transform
keyword: | ||
'class class_name const enum extends func namespace signal static ' + | ||
'trait var await breakpoint yield set get and in not or void as ' + | ||
'assert tool export onready break continue if elif else for pass ' + | ||
'return match when while remote sync master puppet remotesync ' + | ||
'mastersync puppetsync', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth documenting where to find those for future syncs.
Maybe use modules/gdscript/gdscript.cpp
GDScriptLanguage::get_reserved_words()
as reference?
BTW Godot 4.5 is adding abstract
too.
There's also namespace
and trait
which are reserved for future use and thus highlighted by Godot, so we should include them too.
keyword: | ||
'class class_name const enum extends func namespace signal static ' + | ||
'trait var await breakpoint yield set get and in not or void as ' + | ||
'assert tool export onready break continue if elif else for pass ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For assert
, gdscript.cpp
has:
// Functions (highlighter uses global function color instead).
"assert",
"preload",
So maybe it should be moved to built_in
like preload
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I see it is also listed under built_in
already, so the one here should probably be removed.
built_in: | ||
'abs absf absi acos acosh angle_difference asin asinh atan atan2 ' + | ||
'atanh bezier_derivative bezier_interpolate bytes_to_var ' + | ||
'bytes_to_var_with_objects ceil ceilf ceili clamp clampf clampi ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to document how to retrieve/update that list in case it changes in the future.
I've got the list for Godot 4 with:
grep "method name=" doc/classes/@GlobalScope.xml | sed 's/.*name="\([^"]*\)".*/\1/'
and
grep "method name=" modules/gdscript/doc_classes/@GDScript.xml | sed 's/.*name="\([^"]*\)".*/\1/'
And confirmed that it matches the list you have here. But that also means we're missing 3.x built-ins.
Assuming we can include comments between lines in this long string, I'd suggest prefacing the blocks like this:
# Godot 4 @GlobalScope methods
# `grep "method name=" doc/classes/@GlobalScope.xml | sed 's/.*name="\([^"]*\)".*/\1/'`
# Godot 4 @GDScript built-ins
# `grep "method name=" modules/gdscript/doc_classes/@GDScript.xml | sed 's/.*name="\([^"]*\)".*/\1/'`
# Godot 3 @GDScript built-ins not in Godot 4
# `grep "method name=" modules/gdscript/doc_classes/@GDScript.xml | sed 's/.*name="\([^"]*\)".*/\1/'``
(there's no @GlobalScope
methods in 3.x, they're all in @GDScript
)
I found the following Godot 3 built-ins missing here:
ColorN
bytes2var
cartesian2polar
db2linear
dectime
deep_equal
deg2rad
dict2inst
funcref
inst2dict
linear2db
ord
parse_json
polar2cartesian
rad2deg
rand_range
rand_seed
range_lerp
stepify
str2var
to_json
validate_json
var2bytes
var2str
yield
(yield
is already a reserved keyword listed above for Godot 4 so it doesn't need to be re-listed here)
keyword: | ||
'@export @export_category @export_color_no_alpha @export_custom ' + | ||
'@export_dir @export_enum @export_exp_easing @export_file ' + | ||
'@export_flags @export_flags_2d_navigation @export_flags_2d_physics ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed the list of annotations is accurate for Godot 4 with:
grep "register_annotation(MethodInfo" gdscript_parser.cpp | sed 's/.*MethodInfo("\([^"]*\)".*/\1/' | sort
Could be documented too for future syncs.
Note that I couldn't get the ES module build to work in the browser, so maybe we should remove it.
Testing project: highlightjs-gdscript-test.zip
Change the path to
dist/gdscript.min.js
inindex.html
to match a location on disk, then openindex.html
in a web browser. No build step needed.Preview
Using
vs2015
theme and the test project linked above.