From b302084395a6d7f3cc8e4102751ced29779f2ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 21 Oct 2017 12:33:50 +0200 Subject: [PATCH] makerst: Fix rst-ization of members and escaping of [Class]s Fixes #11517. --- doc/classes/Area.xml | 4 ++-- doc/classes/Area2D.xml | 4 ++-- doc/classes/BitmapFont.xml | 2 +- doc/classes/CollisionObject.xml | 2 +- doc/classes/CollisionObject2D.xml | 2 +- doc/classes/DynamicFont.xml | 2 +- doc/classes/EditorInterface.xml | 2 +- doc/classes/EditorScript.xml | 2 +- doc/classes/PacketPeerUDP.xml | 2 +- doc/classes/Physics2DDirectSpaceState.xml | 4 ++-- doc/classes/Physics2DShapeQueryParameters.xml | 4 ++-- doc/classes/RigidBody2D.xml | 4 ++-- doc/classes/Thread.xml | 4 ++-- doc/classes/TreeItem.xml | 2 +- doc/classes/Viewport.xml | 2 +- doc/tools/makerst.py | 14 ++++++++++++-- 16 files changed, 33 insertions(+), 23 deletions(-) diff --git a/doc/classes/Area.xml b/doc/classes/Area.xml index 87975750382..bbab7a55474 100644 --- a/doc/classes/Area.xml +++ b/doc/classes/Area.xml @@ -88,14 +88,14 @@ - Returns a list of intersecting [Area]\ s. + Returns a list of intersecting [Area]s. - Returns a list of intersecting [PhysicsBody]\ s. + Returns a list of intersecting [PhysicsBody]s. diff --git a/doc/classes/Area2D.xml b/doc/classes/Area2D.xml index 0cbc0799626..883f952a2ae 100644 --- a/doc/classes/Area2D.xml +++ b/doc/classes/Area2D.xml @@ -88,14 +88,14 @@ - Returns a list of intersecting [Area2D]\ s. + Returns a list of intersecting [Area2D]s. - Returns a list of intersecting [PhysicsBody2D]\ s. + Returns a list of intersecting [PhysicsBody2D]s. diff --git a/doc/classes/BitmapFont.xml b/doc/classes/BitmapFont.xml index 07027c4b429..48e5798008a 100644 --- a/doc/classes/BitmapFont.xml +++ b/doc/classes/BitmapFont.xml @@ -168,7 +168,7 @@ The font's kernings as [PoolIntArray]. - The font's [Texture]\ s. + The font's [Texture]s. diff --git a/doc/classes/CollisionObject.xml b/doc/classes/CollisionObject.xml index 64e9e079255..71b0c5fa7cd 100644 --- a/doc/classes/CollisionObject.xml +++ b/doc/classes/CollisionObject.xml @@ -4,7 +4,7 @@ Base node for collision objects. - CollisionObject is the base class for physics objects. It can hold any number of collision [Shape]\ s. Each shape must be assigned to a [i]shape owner[/i]. The CollisionObject can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the [code]shape_owner_*[/code] methods. + CollisionObject is the base class for physics objects. It can hold any number of collision [Shape]s. Each shape must be assigned to a [i]shape owner[/i]. The CollisionObject can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the [code]shape_owner_*[/code] methods. diff --git a/doc/classes/CollisionObject2D.xml b/doc/classes/CollisionObject2D.xml index 52743bd37d0..ec0554d51fb 100644 --- a/doc/classes/CollisionObject2D.xml +++ b/doc/classes/CollisionObject2D.xml @@ -4,7 +4,7 @@ Base node for 2D collision objects. - CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision [Shape2D]\ s. Each shape must be assigned to a [i]shape owner[/i]. The CollisionObject2D can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the [code]shape_owner_*[/code] methods. + CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision [Shape2D]s. Each shape must be assigned to a [i]shape owner[/i]. The CollisionObject2D can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the [code]shape_owner_*[/code] methods. diff --git a/doc/classes/DynamicFont.xml b/doc/classes/DynamicFont.xml index c130add523a..d7f08c85a1f 100644 --- a/doc/classes/DynamicFont.xml +++ b/doc/classes/DynamicFont.xml @@ -4,7 +4,7 @@ DynamicFont renders vector font files at runtime. - DynamicFont renders vector font files (such as TTF or OTF) dynamically at runtime instead of using a prerendered texture atlas like [BitmapFont]. This trades the faster loading time of [BitmapFont]\ s for the ability to change font parameters like size and spacing during runtime. [DynamicFontData] is used for referencing the font file paths. + DynamicFont renders vector font files (such as TTF or OTF) dynamically at runtime instead of using a prerendered texture atlas like [BitmapFont]. This trades the faster loading time of [BitmapFont]s for the ability to change font parameters like size and spacing during runtime. [DynamicFontData] is used for referencing the font file paths. diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 23a937791c7..3a3fd43b151 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -102,7 +102,7 @@ - Returns mesh previews rendered at the given size as an [Array] of [Texture]\ s. + Returns mesh previews rendered at the given size as an [Array] of [Texture]s. diff --git a/doc/classes/EditorScript.xml b/doc/classes/EditorScript.xml index 39d5ab7254f..8856e3362a5 100644 --- a/doc/classes/EditorScript.xml +++ b/doc/classes/EditorScript.xml @@ -4,7 +4,7 @@ Base script that can be used to add extension functions to the editor. - Scripts extending this class and implementing its [code]_run()[/code] method can be executed from the Script Editor's [code]File -> Run[/code] menu option (or by pressing [code]CTRL+Shift+X[/code]) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using [EditorPlugin]\ s instead. Note that extending scripts need to have [code]tool mode[/code] enabled. + Scripts extending this class and implementing its [code]_run()[/code] method can be executed from the Script Editor's [code]File -> Run[/code] menu option (or by pressing [code]CTRL+Shift+X[/code]) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using [EditorPlugin]s instead. Note that extending scripts need to have [code]tool mode[/code] enabled. Example script: [codeblock] tool diff --git a/doc/classes/PacketPeerUDP.xml b/doc/classes/PacketPeerUDP.xml index 9bff0c9b5e6..0453c165371 100644 --- a/doc/classes/PacketPeerUDP.xml +++ b/doc/classes/PacketPeerUDP.xml @@ -4,7 +4,7 @@ UDP packet peer. - UDP packet peer. Can be used to send raw UDP packets as well as [Variant]\ s. + UDP packet peer. Can be used to send raw UDP packets as well as [Variant]s. diff --git a/doc/classes/Physics2DDirectSpaceState.xml b/doc/classes/Physics2DDirectSpaceState.xml index 9399227d272..5427ed1573b 100644 --- a/doc/classes/Physics2DDirectSpaceState.xml +++ b/doc/classes/Physics2DDirectSpaceState.xml @@ -70,7 +70,7 @@ collider_id: Id of the object the point is in. collider: Object the point is inside of. rid: [RID] of the object the point is in. - Additionally, the method can take an array of objects or [RID]\ s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants). + Additionally, the method can take an array of objects or [RID]s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants). @@ -96,7 +96,7 @@ collider: Object against which the ray was stopped. rid: [RID] of the object against which the ray was stopped. If the ray did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead. - Additionally, the method can take an array of objects or [RID]\ s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants). + Additionally, the method can take an array of objects or [RID]s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants). diff --git a/doc/classes/Physics2DShapeQueryParameters.xml b/doc/classes/Physics2DShapeQueryParameters.xml index d838ff23177..04fe12cc077 100644 --- a/doc/classes/Physics2DShapeQueryParameters.xml +++ b/doc/classes/Physics2DShapeQueryParameters.xml @@ -22,7 +22,7 @@ - Return the list of objects, or object [RID]\ s, that will be excluded from collisions. + Return the list of objects, or object [RID]s, that will be excluded from collisions. @@ -75,7 +75,7 @@ - Set the list of objects, or object [RID]\ s, that will be excluded from collisions. + Set the list of objects, or object [RID]s, that will be excluded from collisions. diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index 3c684e065ff..2bc3fd726be 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -116,7 +116,7 @@ - Returns the body's moment of inertia, which is computed automatically from the body's mass and assigned [Shape2D]\ s during the physics frame. Note that it will not yet have a value in the [code]_ready()[/code] function. + Returns the body's moment of inertia, which is computed automatically from the body's mass and assigned [Shape2D]s during the physics frame. Note that it will not yet have a value in the [code]_ready()[/code] function. @@ -415,7 +415,7 @@ The body's friction. Values range from [code]0[/code] (frictionless) to [code]1[/code] (maximum friction). Default value: [code]1[/code]. - Multiplies the gravity applied to the body. The body's gravity is calculated from the "Default Gravity" value in "Project > Project Settings > Physics > 2d" and/or any additional gravity vector applied by [Area2D]\s. Default value: [code]1[/code]. + Multiplies the gravity applied to the body. The body's gravity is calculated from the "Default Gravity" value in "Project > Project Settings > Physics > 2d" and/or any additional gravity vector applied by [Area2D]s. Default value: [code]1[/code]. Damps the body's [member linear_velocity]. If [code]-1[/code] the body will use the "Default Linear Damp" in "Project > Project Settings > Physics > 2d". Default value: [code]-1[/code]. diff --git a/doc/classes/Thread.xml b/doc/classes/Thread.xml index 2156d046145..b2467bca7f8 100644 --- a/doc/classes/Thread.xml +++ b/doc/classes/Thread.xml @@ -4,7 +4,7 @@ A unit of execution in a process. - A unit of execution in a process. Can run methods on [Object]\ s simultaneously. The use of synchronization via [Mutex], [Semaphore] is advised if working with shared objects. + A unit of execution in a process. Can run methods on [Object]s simultaneously. The use of synchronization via [Mutex], [Semaphore] is advised if working with shared objects. @@ -15,7 +15,7 @@ - Returns the current [Thread]\ s id, uniquely identifying it among all threads. + Returns the current [Thread]s id, uniquely identifying it among all threads. diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index 3cf56bbf11d..47292ec200e 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -4,7 +4,7 @@ Control for a single item inside a [Tree]. - Control for a single item inside a [Tree]. May have child [TreeItem]\ s and be styled as well as contain buttons. + Control for a single item inside a [Tree]. May have child [TreeItem]s and be styled as well as contain buttons. diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 58626356bfa..28a7cb7c8eb 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -303,7 +303,7 @@ - Set the canvas transform of the viewport, useful for changing the on-screen positions of all child [CanvasItem]\ s. This is relative to the global canvas transform of the viewport. + Set the canvas transform of the viewport, useful for changing the on-screen positions of all child [CanvasItem]s. This is relative to the global canvas transform of the viewport. diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index 0c67e3be4ce..94dc8b276b6 100644 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -189,8 +189,11 @@ def rstize_text(text, cclass): post_text = text[endq_pos + 1:] tag_text = text[pos + 1:endq_pos] + escape_post = False + if tag_text in class_names: tag_text = make_type(tag_text) + escape_post = True else: # command cmd = tag_text space_pos = tag_text.find(' ') @@ -218,12 +221,14 @@ def rstize_text(text, cclass): tag_text = ':ref:`' + class_param + '.' + method_param + '`' else: tag_text = ':ref:`' + param + '`' + escape_post = True elif cmd.find('image=') == 0: tag_text = "" # '![](' + cmd[6:] + ')' elif cmd.find('url=') == 0: tag_text = ':ref:`' + cmd[4:] + '<' + cmd[4:] + ">`" elif cmd == '/url': - tag_text = ')' + tag_text = '' + escape_post = True elif cmd == 'center': tag_text = '' elif cmd == '/center': @@ -248,6 +253,11 @@ def rstize_text(text, cclass): inside_code = True else: tag_text = make_type(tag_text) + escape_post = True + + # Properly escape things like `[Node]s` + if escape_post and post_text and post_text[0].isalnum(): # not punctuation, escape + post_text = '\ ' + post_text text = pre_text + tag_text + post_text pos = len(pre_text) + len(tag_text) @@ -459,7 +469,7 @@ def make_rst_class(node): s += make_type(c.attrib['type']) + ' ' s += '**' + c.attrib['name'] + '**' if c.text.strip() != '': - s += ' - ' + c.text.strip() + s += ' - ' + rstize_text(c.text.strip(), name) f.write(s + '\n') f.write('\n')