Browse Source

makerst: Skip generated header for translations

This reduces diff size on branch updates for godot-docs-l10n.

(cherry picked from commit eca3785100cd9b42e000eafa22bf14b41d2e0223)
Rémi Verschelde 1 week ago
parent
commit
6e33e3b7af
1 changed files with 15 additions and 12 deletions
  1. 15 12
      doc/tools/make_rst.py

+ 15 - 12
doc/tools/make_rst.py

@@ -90,6 +90,7 @@ BASE_STRINGS = [
     "[b]Note:[/b] The returned array is [i]copied[/i] and any changes to it will not update the original property value. See [%s] for more details.",
 ]
 strings_l10n: Dict[str, str] = {}
+writing_translation = False
 
 CLASS_GROUPS: Dict[str, str] = {
     "global": "Globals",
@@ -704,6 +705,8 @@ def main() -> None:
 
     # Retrieve heading translations for the given language.
     if not args.dry_run and args.lang != "en":
+        global writing_translation
+        writing_translation = True
         lang_file = os.path.join(
             os.path.dirname(os.path.realpath(__file__)), "..", "translations", "{}.po".format(args.lang)
         )
@@ -898,18 +901,18 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
         if class_def.keywords is not None and class_def.keywords != "":
             f.write(f".. meta::\n\t:keywords: {class_def.keywords}\n\n")
 
-        # Warn contributors not to edit this file directly.
-        # Also provide links to the source files for reference.
-
-        git_branch = get_git_branch()
-        source_xml_path = os.path.relpath(class_def.filepath, root_directory).replace("\\", "/")
-        source_github_url = f"https://github.com/godotengine/godot/tree/{git_branch}/{source_xml_path}"
-        generator_github_url = f"https://github.com/godotengine/godot/tree/{git_branch}/doc/tools/make_rst.py"
-
-        f.write(".. DO NOT EDIT THIS FILE!!!\n")
-        f.write(".. Generated automatically from Godot engine sources.\n")
-        f.write(f".. Generator: {generator_github_url}.\n")
-        f.write(f".. XML source: {source_github_url}.\n\n")
+        if not writing_translation:  # Skip for translations to reduce diff.
+            # Warn contributors not to edit this file directly.
+            # Also provide links to the source files for reference.
+            git_branch = get_git_branch()
+            source_xml_path = os.path.relpath(class_def.filepath, root_directory).replace("\\", "/")
+            source_github_url = f"https://github.com/godotengine/godot/tree/{git_branch}/{source_xml_path}"
+            generator_github_url = f"https://github.com/godotengine/godot/tree/{git_branch}/doc/tools/make_rst.py"
+
+            f.write(".. DO NOT EDIT THIS FILE!!!\n")
+            f.write(".. Generated automatically from Godot engine sources.\n")
+            f.write(f".. Generator: {generator_github_url}.\n")
+            f.write(f".. XML source: {source_github_url}.\n\n")
 
         # Document reference id and header.
         f.write(f".. _class_{sanitize_class_name(class_name)}:\n\n")