Ver código fonte

makerst: Fix rst-ization of members and escaping of [Class]s

Fixes #11517.
Rémi Verschelde 8 anos atrás
pai
commit
b302084395

+ 2 - 2
doc/classes/Area.xml

@@ -88,14 +88,14 @@
 			<return type="Array">
 			</return>
 			<description>
-				Returns a list of intersecting [Area]\ s.
+				Returns a list of intersecting [Area]s.
 			</description>
 		</method>
 		<method name="get_overlapping_bodies" qualifiers="const">
 			<return type="Array">
 			</return>
 			<description>
-				Returns a list of intersecting [PhysicsBody]\ s.
+				Returns a list of intersecting [PhysicsBody]s.
 			</description>
 		</method>
 		<method name="get_priority" qualifiers="const">

+ 2 - 2
doc/classes/Area2D.xml

@@ -88,14 +88,14 @@
 			<return type="Array">
 			</return>
 			<description>
-				Returns a list of intersecting [Area2D]\ s.
+				Returns a list of intersecting [Area2D]s.
 			</description>
 		</method>
 		<method name="get_overlapping_bodies" qualifiers="const">
 			<return type="Array">
 			</return>
 			<description>
-				Returns a list of intersecting [PhysicsBody2D]\ s.
+				Returns a list of intersecting [PhysicsBody2D]s.
 			</description>
 		</method>
 		<method name="get_priority" qualifiers="const">

+ 1 - 1
doc/classes/BitmapFont.xml

@@ -168,7 +168,7 @@
 			The font's kernings as [PoolIntArray].
 		</member>
 		<member name="textures" type="Array" setter="_set_textures" getter="_get_textures">
-			The font's [Texture]\ s.
+			The font's [Texture]s.
 		</member>
 	</members>
 	<constants>

+ 1 - 1
doc/classes/CollisionObject.xml

@@ -4,7 +4,7 @@
 		Base node for collision objects.
 	</brief_description>
 	<description>
-		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.
 	</description>
 	<tutorials>
 	</tutorials>

+ 1 - 1
doc/classes/CollisionObject2D.xml

@@ -4,7 +4,7 @@
 		Base node for 2D collision objects.
 	</brief_description>
 	<description>
-		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.
 	</description>
 	<tutorials>
 	</tutorials>

+ 1 - 1
doc/classes/DynamicFont.xml

@@ -4,7 +4,7 @@
 		DynamicFont renders vector font files at runtime.
 	</brief_description>
 	<description>
-		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.
 	</description>
 	<tutorials>
 	</tutorials>

+ 1 - 1
doc/classes/EditorInterface.xml

@@ -102,7 +102,7 @@
 			<argument index="1" name="preview_size" type="int">
 			</argument>
 			<description>
-				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.
 			</description>
 		</method>
 		<method name="open_scene_from_path">

+ 1 - 1
doc/classes/EditorScript.xml

@@ -4,7 +4,7 @@
 		Base script that can be used to add extension functions to the editor.
 	</brief_description>
 	<description>
-		Scripts extending this class and implementing its [code]_run()[/code] method can be executed from the Script Editor's [code]File -&gt; 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 -&gt; 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

+ 1 - 1
doc/classes/PacketPeerUDP.xml

@@ -4,7 +4,7 @@
 		UDP packet peer.
 	</brief_description>
 	<description>
-		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.
 	</description>
 	<tutorials>
 	</tutorials>

+ 2 - 2
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).
 			</description>
 		</method>
 		<method name="intersect_ray">
@@ -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).
 			</description>
 		</method>
 		<method name="intersect_shape">

+ 2 - 2
doc/classes/Physics2DShapeQueryParameters.xml

@@ -22,7 +22,7 @@
 			<return type="Array">
 			</return>
 			<description>
-				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.
 			</description>
 		</method>
 		<method name="get_margin" qualifiers="const">
@@ -75,7 +75,7 @@
 			<argument index="0" name="exclude" type="Array">
 			</argument>
 			<description>
-				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.
 			</description>
 		</method>
 		<method name="set_margin">

+ 2 - 2
doc/classes/RigidBody2D.xml

@@ -116,7 +116,7 @@
 			<return type="float">
 			</return>
 			<description>
-				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.
 			</description>
 		</method>
 		<method name="get_linear_damp" qualifiers="const">
@@ -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].
 		</member>
 		<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale">
-			Multiplies the gravity applied to the body. The body's gravity is calculated from the "Default Gravity" value in "Project &gt; Project Settings &gt; Physics &gt; 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 &gt; Project Settings &gt; Physics &gt; 2d" and/or any additional gravity vector applied by [Area2D]s. Default value: [code]1[/code].
 		</member>
 		<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp">
 			Damps the body's [member linear_velocity]. If [code]-1[/code] the body will use the "Default Linear Damp" in "Project &gt; Project Settings &gt; Physics &gt; 2d". Default value: [code]-1[/code].

+ 2 - 2
doc/classes/Thread.xml

@@ -4,7 +4,7 @@
 		A unit of execution in a process.
 	</brief_description>
 	<description>
-		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.
 	</description>
 	<tutorials>
 	</tutorials>
@@ -15,7 +15,7 @@
 			<return type="String">
 			</return>
 			<description>
-				Returns the current [Thread]\ s id, uniquely identifying it among all threads.
+				Returns the current [Thread]s id, uniquely identifying it among all threads.
 			</description>
 		</method>
 		<method name="is_active" qualifiers="const">

+ 1 - 1
doc/classes/TreeItem.xml

@@ -4,7 +4,7 @@
 		Control for a single item inside a [Tree].
 	</brief_description>
 	<description>
-		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.
 	</description>
 	<tutorials>
 	</tutorials>

+ 1 - 1
doc/classes/Viewport.xml

@@ -303,7 +303,7 @@
 			<argument index="0" name="xform" type="Transform2D">
 			</argument>
 			<description>
-				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.
 			</description>
 		</method>
 		<method name="set_clear_mode">

+ 12 - 2
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 + '<class_' + class_param + '_' + method_param + '>`'
                 else:
                     tag_text = ':ref:`' + param + '<class_' + cclass + "_" + 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')