makerst: Skip generated header for translations

This reduces diff size on branch updates for godot-docs-l10n.
This commit is contained in:
Rémi Verschelde
2025-09-30 13:27:18 +02:00
parent d488e962df
commit eca3785100

View File

@@ -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.
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"
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")
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")