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

Function _process_doc_line

modules/gdscript/gdscript_parser.cpp:3826–3941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3824};
3825
3826static String _process_doc_line(const String &p_line, const String &p_text, const String &p_space_prefix, DocLineState &r_state) {
3827 String line = p_line;
3828 if (r_state == DOC_LINE_NORMAL) {
3829 line = line.strip_edges(true, false);
3830 } else {
3831 line = line.trim_prefix(p_space_prefix);
3832 }
3833
3834 String line_join;
3835 if (!p_text.is_empty()) {
3836 if (r_state == DOC_LINE_NORMAL) {
3837 if (p_text.ends_with("[/codeblock]")) {
3838 line_join = "\n";
3839 } else if (!p_text.ends_with("[br]")) {
3840 line_join = " ";
3841 }
3842 } else {
3843 line_join = "\n";
3844 }
3845 }
3846
3847 String result;
3848 int from = 0;
3849 int buffer_start = 0;
3850 const int len = line.length();
3851 bool process = true;
3852 while (process) {
3853 switch (r_state) {
3854 case DOC_LINE_NORMAL: {
3855 int lb_pos = line.find_char('[', from);
3856 if (lb_pos < 0) {
3857 process = false;
3858 break;
3859 }
3860 int rb_pos = line.find_char(']', lb_pos + 1);
3861 if (rb_pos < 0) {
3862 process = false;
3863 break;
3864 }
3865
3866 from = rb_pos + 1;
3867
3868 String tag = line.substr(lb_pos + 1, rb_pos - lb_pos - 1);
3869 if (tag == "code" || tag.begins_with("code ")) {
3870 r_state = DOC_LINE_IN_CODE;
3871 } else if (tag == "codeblock" || tag.begins_with("codeblock ")) {
3872 if (lb_pos == 0) {
3873 line_join = "\n";
3874 } else {
3875 result += line.substr(buffer_start, lb_pos - buffer_start) + '\n';
3876 }
3877 result += "[" + tag + "]";
3878 if (from < len) {
3879 result += '\n';
3880 }
3881
3882 r_state = DOC_LINE_IN_CODEBLOCK;
3883 buffer_start = from;

Callers 2

parse_doc_commentMethod · 0.85

Calls 9

strip_edgesMethod · 0.80
trim_prefixMethod · 0.80
ends_withMethod · 0.80
find_charMethod · 0.80
substrMethod · 0.80
begins_withMethod · 0.80
is_emptyMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected