MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / parse_class_doc_comment

Method parse_class_doc_comment

modules/gdscript/gdscript_parser.cpp:4009–4120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4007}
4008
4009GDScriptParser::ClassDocData GDScriptParser::parse_class_doc_comment(int p_line, bool p_single_line) {
4010 ERR_FAIL_COND_V(!has_comment(p_line, true), ClassDocData());
4011
4012 const HashMap<int, GDScriptTokenizer::CommentData> &comments = tokenizer->get_comments();
4013 int line = p_line;
4014
4015 if (!p_single_line) {
4016 while (comments.has(line - 1) && comments[line - 1].new_line && comments[line - 1].comment.begins_with("##")) {
4017 line--;
4018 }
4019 }
4020
4021 max_script_doc_line = MIN(max_script_doc_line, line - 1);
4022
4023 String space_prefix;
4024 {
4025 int i = 2;
4026 for (; i < comments[line].comment.length(); i++) {
4027 if (comments[line].comment[i] != ' ') {
4028 break;
4029 }
4030 }
4031 space_prefix = String(" ").repeat(i - 2);
4032 }
4033
4034 DocLineState state = DOC_LINE_NORMAL;
4035 bool is_in_brief = true;
4036 ClassDocData result;
4037
4038 while (line <= p_line) {
4039 String doc_line = comments[line].comment.trim_prefix("##");
4040 line++;
4041
4042 if (state == DOC_LINE_NORMAL) {
4043 String stripped_line = doc_line.strip_edges();
4044
4045 // A blank line separates the description from the brief.
4046 if (is_in_brief && !result.brief.is_empty() && stripped_line.is_empty()) {
4047 is_in_brief = false;
4048 continue;
4049 }
4050
4051 if (stripped_line.begins_with("@tutorial")) {
4052 String title, link;
4053
4054 int begin_scan = String("@tutorial").length();
4055 if (begin_scan >= stripped_line.length()) {
4056 continue; // Invalid syntax.
4057 }
4058
4059 if (stripped_line[begin_scan] == ':') { // No title.
4060 // Syntax: ## @tutorial: https://godotengine.org/ // The title argument is optional.
4061 title = "";
4062 link = stripped_line.trim_prefix("@tutorial:").strip_edges();
4063 } else {
4064 /* Syntax:
4065 * @tutorial ( The Title Here ) : https://the.url/
4066 * ^ open ^ close ^ colon ^ url

Callers

nothing calls this directly

Calls 13

ClassDocDataClass · 0.85
MINFunction · 0.85
_process_doc_lineFunction · 0.85
begins_withMethod · 0.80
repeatMethod · 0.80
trim_prefixMethod · 0.80
strip_edgesMethod · 0.80
substrMethod · 0.80
StringClass · 0.50
hasMethod · 0.45
lengthMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected