summaryrefslogtreecommitdiff
path: root/doc/tools
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-07-27 13:24:03 +0200
committerGitHub <noreply@github.com>2022-07-27 13:24:03 +0200
commit1bb56d92980c268a24d826a342ed4c44e7058b5a (patch)
tree59f66f186b2a0a7b92ebb5a2928e637684498ca6 /doc/tools
parenta446d761fb091920e8a9ea5c3db00f866443f11b (diff)
parentf3561696dab862b43ec3a0557e4fa5aa803d6621 (diff)
Merge pull request #63495 from YuriSizov/docs-improve-autogen-note
Diffstat (limited to 'doc/tools')
-rwxr-xr-xdoc/tools/make_rst.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py
index 8fa530f1da..a56e4b338e 100755
--- a/doc/tools/make_rst.py
+++ b/doc/tools/make_rst.py
@@ -10,6 +10,11 @@ import sys
import xml.etree.ElementTree as ET
from collections import OrderedDict
+# Import hardcoded version information from version.py
+script_directory = os.path.dirname(os.path.abspath(__file__))
+sys.path.append(os.path.join(script_directory, "../../")) # Include the root directory
+import version
+
# Uncomment to do type checks. I have it commented out so it works below Python 3.5
# from typing import List, Dict, TextIO, Tuple, Iterable, Optional, DefaultDict, Any, Union
@@ -587,12 +592,26 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
else:
f = open(os.path.join(output_dir, "class_" + class_name.lower() + ".rst"), "w", encoding="utf-8")
- # Warn contributors not to edit this file directly
+ # Remove the "Edit on Github" button from the online docs page.
f.write(":github_url: hide\n\n")
- f.write(".. Generated automatically by doc/tools/make_rst.py in Godot's source tree.\n")
- f.write(".. DO NOT EDIT THIS FILE, but the " + class_name + ".xml source instead.\n")
- f.write(".. The source is found in doc/classes or modules/<name>/doc_classes.\n\n")
+ # Warn contributors not to edit this file directly.
+ # Also provide links to the source files for reference.
+
+ git_branch = "master"
+ if hasattr(version, "docs") and version.docs != "latest":
+ git_branch = version.docs
+
+ source_xml_path = os.path.normpath(os.path.join("doc", class_def.filepath)).replace("\\", "/")
+ source_github_url = "https://github.com/godotengine/godot/tree/{}/{}".format(git_branch, source_xml_path)
+ generator_github_url = "https://github.com/godotengine/godot/tree/{}/doc/tools/make_rst.py".format(git_branch)
+
+ f.write(".. DO NOT EDIT THIS FILE!!!\n")
+ f.write(".. Generated automatically from Godot engine sources.\n")
+ f.write(".. Generator: " + generator_github_url + ".\n")
+ f.write(".. XML source: " + source_github_url + ".\n\n")
+
+ # Document reference id and header.
f.write(".. _class_" + class_name + ":\n\n")
f.write(make_heading(class_name, "=", False))