Skip to content

Commit

Permalink
Add @deprecated and @experimental GDScript annotations pointing t…
Browse files Browse the repository at this point in the history
…o comments

These annotations don't exist at a source level, so the new annotations
are only here to point to the documentation comment syntax.

This makes it easier to discover the feature as it'll now appear
in the help search as well.
  • Loading branch information
Calinou committed Dec 9, 2024
1 parent aa8d9b8 commit bc66a2a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,15 @@ GDScriptParser::AnnotationNode *GDScriptParser::parse_annotation(uint32_t p_vali
bool valid = true;

if (!valid_annotations.has(annotation->name)) {
push_error(vformat(R"(Unrecognized annotation: "%s".)", annotation->name));
if (annotation->name == "@deprecated") {
push_error(R"("@deprecated" annotation does not exist. Use "## @deprecated: Reason here." instead.)");
} else if (annotation->name == "@experimental") {
push_error(R"("@experimental" annotation does not exist. Use "## @experimental: Reason here." instead.)");
} else if (annotation->name == "@tutorial") {
push_error(R"("@tutorial" annotation does not exist. Use "## @tutorial(Title): https://example.com" instead.)");
} else {
push_error(vformat(R"(Unrecognized annotation: "%s".)", annotation->name));
}
valid = false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This annotation should be used within a documentation comment instead:
# ## @deprecated: Reason here.

@deprecated
var some_variable = "value"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
"@deprecated" annotation does not exist at a source level. Use "## @deprecated: Reason here." as a comment instead.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This annotation should be used within a documentation comment instead:
# ## @experimental: Reason here.

@experimental("This function isn't implemented yet.")
func say_hello():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
"@experimental" annotation does not exist at a source level. Use "## @experimental: Reason here." as a comment instead.

0 comments on commit bc66a2a

Please sign in to comment.