summaryrefslogtreecommitdiff
path: root/doc/tools
diff options
context:
space:
mode:
authorYuri Sizov <yuris@humnom.net>2022-07-26 18:20:51 +0300
committerYuri Sizov <yuris@humnom.net>2022-07-27 13:43:06 +0300
commitf3561696dab862b43ec3a0557e4fa5aa803d6621 (patch)
tree4360ee97210efa9acacf1605c05349db96bcee68 /doc/tools
parentb5222c07846b4742425a001121d998fe92050c20 (diff)
Improve the autogenerated note in RST docs for class reference
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 312dffc7ee..93177c7366 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))