Repository: godotengine/godot
File: doc/tools/make_rst.py (Python)

Code before:
                tag_text = ""
                inside_code_tabs = False

            elif cmd == "codeblock" or cmd == "gdscript" or cmd == "csharp":
                tag_depth += 1

                if cmd == "gdscript":
                    if not inside_code_tabs:
                        print_error(
                            f"{state.current_class}.xml: GDScript code block is used outside of [codeblocks] in {context_name}.",
                            state,
                        )
                    tag_text = "\n .. code-tab:: gdscript\n"
                elif cmd == "csharp":
                    if not inside_code_tabs:
                        print_error(
                            f"{state.current_class}.xml: C# code block is used outside of [codeblocks] in {context_name}.",
                            state,
                        )
                    tag_text = "\n .. code-tab:: csharp\n"
                else:
                    tag_text = "\n::\n"

                inside_code = True
                inside_code_tag = cmd

            elif cmd == "code":
                tag_text = "``"
                tag_depth += 1
                inside_code = True
                inside_code_tag = cmd
                escape_pre = True

            # Cross-references to items in this or other class documentation pages.
            elif is_in_tagset(cmd, RESERVED_CROSSLINK_TAGS):
                link_type: str = ""
                link_target: str = ""
                if space_pos >= 0:
                    link_type = tag_text[:space_pos]
                    link_target = tag_text[space_pos + 1 :].strip()

                if link_target == "":
                    print_error(
                        f'{state.current_class}.xml: Empty cross-reference link "{cmd}" in {context_name}.',
                        state,
                    )
                    tag_text = ""
                else:
                    if (
                        cmd.startswith("method")
                        or cmd.startswith("constructor")

Review comment (suggestion):
That's not how it should be fixed, `cmd` should just be removed from arguments. That said, we already have a PR that changes interpolated strings to use a different syntax, so you should probably avoid touching that here. See https://github.com/godotengine/godot/pull/64545.

Code after:
                inside_code_tabs = False

            elif cmd == "codeblock" or cmd == "gdscript" or cmd == "csharp":
                tag_depth += 1

                if cmd == "gdscript":
                    if not inside_code_tabs:
                        print_error(
                            f"{state.current_class}.xml: GDScript code block is used outside of [codeblocks] in {context_name}.",
                            state,
                        )
                    tag_text = "\n .. code-tab:: gdscript\n"
                elif cmd == "csharp":
                    if not inside_code_tabs:
                        print_error(
                            f"{state.current_class}.xml: C# code block is used outside of [codeblocks] in {context_name}.",
                            state,
                        )
                    tag_text = "\n .. code-tab:: csharp\n"
                else:
                    tag_text = "\n::\n"

                inside_code = True
                inside_code_tag = cmd

            elif cmd == "code":
                tag_text = "``"
                tag_depth += 1
                inside_code = True
                inside_code_tag = cmd
                escape_pre = True

            # Cross-references to items in this or other class documentation pages.
            elif is_in_tagset(cmd, RESERVED_CROSSLINK_TAGS):
                link_type: str = ""
                link_target: str = ""
                if space_pos >= 0:
                    link_type = tag_text[:space_pos]
                    link_target = tag_text[space_pos + 1 :].strip()

                if link_target == "":
                    print_error(
                        f'{state.current_class}.xml: Empty cross-reference link "{cmd}" in {context_name}.',
                        state,
                    )
                    tag_text = ""
                else:
                    if (
                        cmd.startswith("method")
                        or cmd.startswith("constructor")
                        or cmd.startswith("operator")