You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Merge pull request #62713 from YuriSizov/docs-scripting-annotations
This commit is contained in:
@@ -178,6 +178,20 @@ void DocTools::merge_from(const DocTools &p_data) {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < c.annotations.size(); i++) {
|
||||
DocData::MethodDoc &m = c.annotations.write[i];
|
||||
|
||||
for (int j = 0; j < cf.annotations.size(); j++) {
|
||||
if (cf.annotations[j].name != m.name) {
|
||||
continue;
|
||||
}
|
||||
const DocData::MethodDoc &mf = cf.annotations[j];
|
||||
|
||||
m.description = mf.description;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < c.properties.size(); i++) {
|
||||
DocData::PropertyDoc &p = c.properties.write[i];
|
||||
|
||||
@@ -960,8 +974,41 @@ void DocTools::generate(bool p_basic_types) {
|
||||
c.constants.push_back(cd);
|
||||
}
|
||||
|
||||
// Get annotations.
|
||||
List<MethodInfo> ainfo;
|
||||
lang->get_public_annotations(&ainfo);
|
||||
|
||||
for (const MethodInfo &ai : ainfo) {
|
||||
DocData::MethodDoc atd;
|
||||
atd.name = ai.name;
|
||||
|
||||
if (ai.flags & METHOD_FLAG_VARARG) {
|
||||
if (!atd.qualifiers.is_empty()) {
|
||||
atd.qualifiers += " ";
|
||||
}
|
||||
atd.qualifiers += "vararg";
|
||||
}
|
||||
|
||||
DocData::return_doc_from_retinfo(atd, ai.return_val);
|
||||
|
||||
for (int j = 0; j < ai.arguments.size(); j++) {
|
||||
DocData::ArgumentDoc ad;
|
||||
DocData::argument_doc_from_arginfo(ad, ai.arguments[j]);
|
||||
|
||||
int darg_idx = j - (ai.arguments.size() - ai.default_arguments.size());
|
||||
if (darg_idx >= 0) {
|
||||
Variant default_arg = ai.default_arguments[darg_idx];
|
||||
ad.default_value = default_arg.get_construct_string().replace("\n", " ");
|
||||
}
|
||||
|
||||
atd.arguments.push_back(ad);
|
||||
}
|
||||
|
||||
c.annotations.push_back(atd);
|
||||
}
|
||||
|
||||
// Skip adding the lang if it doesn't expose anything (e.g. C#).
|
||||
if (c.methods.is_empty() && c.constants.is_empty()) {
|
||||
if (c.methods.is_empty() && c.constants.is_empty() && c.annotations.is_empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1163,6 +1210,9 @@ Error DocTools::_load(Ref<XMLParser> parser) {
|
||||
} else if (name2 == "signals") {
|
||||
Error err2 = _parse_methods(parser, c.signals);
|
||||
ERR_FAIL_COND_V(err2, err2);
|
||||
} else if (name2 == "annotations") {
|
||||
Error err2 = _parse_methods(parser, c.annotations);
|
||||
ERR_FAIL_COND_V(err2, err2);
|
||||
} else if (name2 == "members") {
|
||||
while (parser->read() == OK) {
|
||||
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
|
||||
@@ -1450,6 +1500,8 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
|
||||
_write_string(f, 1, "</constants>");
|
||||
}
|
||||
|
||||
_write_method_doc(f, "annotation", c.annotations);
|
||||
|
||||
if (!c.theme_properties.is_empty()) {
|
||||
c.theme_properties.sort();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user