Merge pull request #63495 from YuriSizov/docs-improve-autogen-note
This commit is contained in:
commit
1bb56d9298
1 changed files with 23 additions and 4 deletions
|
@ -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))
|
||||
|
||||
|
|
Loading…
Reference in a new issue