diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/classes/ArrayMesh.xml | 12 | ||||
-rw-r--r-- | doc/classes/Control.xml | 4 | ||||
-rwxr-xr-x | doc/tools/make_rst.py | 169 |
3 files changed, 174 insertions, 11 deletions
diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index ab948dd0de..b9c8ab0f6c 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -25,10 +25,12 @@ m.mesh = arr_mesh [/gdscript] [csharp] - var vertices = new Godot.Collections.Array<Vector3>(); - vertices.Add(new Vector3(0, 1, 0)); - vertices.Add(new Vector3(1, 0, 0)); - vertices.Add(new Vector3(0, 0, 1)); + var vertices = new Vector3[] + { + new Vector3(0, 1, 0), + new Vector3(1, 0, 0), + new Vector3(0, 0, 1), + }; // Initialize the ArrayMesh. var arrMesh = new ArrayMesh(); @@ -38,7 +40,7 @@ // Create the Mesh. arrMesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, arrays); - var m = new MeshInstance(); + var m = new MeshInstance3D(); m.Mesh = arrMesh; [/csharp] [/codeblocks] diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 2159001a30..8a38deeebe 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -1010,6 +1010,10 @@ <member name="layout_direction" type="int" setter="set_layout_direction" getter="get_layout_direction" enum="Control.LayoutDirection" default="0"> Controls layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew). </member> + <member name="localize_numeral_system" type="bool" setter="set_localize_numeral_system" getter="is_localizing_numeral_system" default="true"> + If [code]true[/code], automatically converts code line numbers, list indices, [SpinBox] and [ProgressBar] values from the Western Arabic (0..9) to the numeral systems used in current locale. + [b]Note:[/b] Numbers within the text are not automatically converted, it can be done manually, using [method TextServer.format_number]. + </member> <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" enum="Control.CursorShape" default="0"> The default cursor shape for this control. Useful for Godot plugins and applications or games that use the system's mouse cursors. [b]Note:[/b] On Linux, shapes may vary depending on the cursor theme of the system. diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py index 492a438d9b..4f41baebf7 100755 --- a/doc/tools/make_rst.py +++ b/doc/tools/make_rst.py @@ -29,6 +29,10 @@ MARKUP_ALLOWED_SUBSEQUENT = " -.,:;!?\\/'\")]}>" # write in this script (check `translate()` uses), and also hardcoded in # `doc/translations/extract.py` to include them in the source POT file. BASE_STRINGS = [ + "Objects", + "Nodes", + "Resources", + "Globals", "Description", "Tutorials", "Properties", @@ -63,6 +67,13 @@ strings_l10n: Dict[str, str] = {} STYLES: Dict[str, str] = {} +CLASS_GROUPS: Dict[str, str] = { + "global": "Globals", + "node": "Nodes", + "resource": "Resources", + "class": "Objects", +} + class State: def __init__(self) -> None: @@ -329,7 +340,7 @@ class State: return cast def sort_classes(self) -> None: - self.classes = OrderedDict(sorted(self.classes.items(), key=lambda t: t[0])) + self.classes = OrderedDict(sorted(self.classes.items(), key=lambda t: t[0].lower())) class TypeName: @@ -601,12 +612,25 @@ def main() -> None: print("Generating the RST class reference...") + grouped_classes: Dict[str, List[str]] = {} + for class_name, class_def in state.classes.items(): if args.filter and not pattern.search(class_def.filepath): continue state.current_class = class_name make_rst_class(class_def, state, args.dry_run, args.output) + group_name = get_class_group(class_def, state) + + if group_name not in grouped_classes: + grouped_classes[group_name] = [] + grouped_classes[group_name].append(class_name) + + print("") + print("Generating the index file...") + + make_rst_index(grouped_classes, args.dry_run, args.output) + print("") if state.num_warnings >= 2: @@ -655,6 +679,39 @@ def translate(string: str) -> str: return strings_l10n.get(string, string) +def get_git_branch() -> str: + if hasattr(version, "docs") and version.docs != "latest": + return version.docs + + return "master" + + +def get_class_group(class_def: ClassDef, state: State) -> str: + group_name = "class" + class_name = class_def.name + + if class_name.startswith("@"): + group_name = "global" + elif class_def.inherits: + inherits = class_def.inherits.strip() + + while inherits in state.classes: + if inherits == "Node": + group_name = "node" + break + if inherits == "Resource": + group_name = "resource" + break + + inode = state.classes[inherits].inherits + if inode: + inherits = inode.strip() + else: + break + + return group_name + + # Generator methods. @@ -672,10 +729,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir: # 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 - + 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" @@ -723,15 +777,30 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir: f.write(make_type(child, state)) f.write("\n\n") + has_description = False + # Brief description - if class_def.brief_description is not None: + if class_def.brief_description is not None and class_def.brief_description.strip() != "": + has_description = True + f.write(f"{format_text_block(class_def.brief_description.strip(), class_def, state)}\n\n") # Class description if class_def.description is not None and class_def.description.strip() != "": + has_description = True + f.write(make_heading("Description", "-")) f.write(f"{format_text_block(class_def.description.strip(), class_def, state)}\n\n") + if not has_description: + f.write(".. container:: contribute\n\n\t") + f.write( + translate( + "There is currently no description for this class. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!" + ) + + "\n\n" + ) + # Online tutorials if len(class_def.tutorials) > 0: f.write(make_heading("Tutorials", "-")) @@ -872,6 +941,14 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir: if m.description is not None and m.description.strip() != "": f.write(f"{format_text_block(m.description.strip(), m, state)}\n\n") + else: + f.write(".. container:: contribute\n\n\t") + f.write( + translate( + "There is currently no description for this annotation. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!" + ) + + "\n\n" + ) index += 1 @@ -904,6 +981,14 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir: if property_def.text is not None and property_def.text.strip() != "": f.write(f"{format_text_block(property_def.text.strip(), property_def, state)}\n\n") + else: + f.write(".. container:: contribute\n\n\t") + f.write( + translate( + "There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!" + ) + + "\n\n" + ) index += 1 @@ -925,6 +1010,14 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir: if m.description is not None and m.description.strip() != "": f.write(f"{format_text_block(m.description.strip(), m, state)}\n\n") + else: + f.write(".. container:: contribute\n\n\t") + f.write( + translate( + "There is currently no description for this constructor. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!" + ) + + "\n\n" + ) index += 1 @@ -945,6 +1038,14 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir: if m.description is not None and m.description.strip() != "": f.write(f"{format_text_block(m.description.strip(), m, state)}\n\n") + else: + f.write(".. container:: contribute\n\n\t") + f.write( + translate( + "There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!" + ) + + "\n\n" + ) index += 1 @@ -967,6 +1068,14 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir: if m.description is not None and m.description.strip() != "": f.write(f"{format_text_block(m.description.strip(), m, state)}\n\n") + else: + f.write(".. container:: contribute\n\n\t") + f.write( + translate( + "There is currently no description for this operator. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!" + ) + + "\n\n" + ) index += 1 @@ -992,6 +1101,14 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir: if theme_item_def.text is not None and theme_item_def.text.strip() != "": f.write(f"{format_text_block(theme_item_def.text.strip(), theme_item_def, state)}\n\n") + else: + f.write(".. container:: contribute\n\n\t") + f.write( + translate( + "There is currently no description for this theme property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!" + ) + + "\n\n" + ) index += 1 @@ -1142,6 +1259,46 @@ def make_link(url: str, title: str) -> str: return f"`{url} <{url}>`__" +def make_rst_index(grouped_classes: Dict[str, List[str]], dry_run: bool, output_dir: str) -> None: + + if dry_run: + f = open(os.devnull, "w", encoding="utf-8") + else: + f = open(os.path.join(output_dir, "index.rst"), "w", encoding="utf-8") + + # Remove the "Edit on Github" button from the online docs page. + f.write(":github_url: hide\n\n") + + # Warn contributors not to edit this file directly. + # Also provide links to the source files for reference. + + git_branch = get_git_branch() + 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\n") + + f.write(".. _doc_class_reference:\n\n") + + for group_name in CLASS_GROUPS: + if group_name in grouped_classes: + group_title = translate(CLASS_GROUPS[group_name]) + + f.write(f"{group_title}\n") + f.write(f"{'=' * len(group_title)}\n\n") + + f.write(".. toctree::\n") + f.write(" :maxdepth: 1\n") + f.write(" :name: toc-class-ref-globals\n") + f.write("\n") + + for class_name in grouped_classes[group_name]: + f.write(f" class_{class_name.lower()}\n") + + f.write("\n") + + # Formatting helpers. |